cc-best-practices
dboeckli/ai-agent-skills
Master Claude Code with context management, verification strategies, and the explore-plan-implement workflow.
What is cc-best-practices?
Guidance on using Claude Code effectively, covering context management, verification strategies, the explore-plan-implement workflow, prompting techniques, session management, and common failure patterns. Use this when optimizing Claude Code workflows, writing better prompts, managing context windows, or troubleshooting repeated mistakes.
- Teach the explore-plan-implement workflow for structured multi-file changes
- Provide verification strategies to ensure Claude confirms work with runnable checks
- Guide context window management to prevent performance degradation
- Offer prompting techniques for specific, scoped requests
- Explain session management and when to use /clear, /plan, and /compact modes
- Help diagnose and fix common failure patterns like repeated mistakes or lost instructions
How to install cc-best-practices
npx skills add https://github.com/dboeckli/ai-agent-skills --skill cc-best-practicesHow to use cc-best-practices
- 1.Identify your task type: small fix (skip planning) or multi-file change (use /plan mode)
- 2.Add a verification step to your prompt (test suite, build command, linter output)
- 3.Use /plan mode to explore and draft a plan before implementing
- 4.Write specific, scoped prompts with file references (@filename) and symptom descriptions
- 5.Keep CLAUDE.md short and actionable—only include what Claude cannot infer from code
- 6.Use /clear between unrelated tasks or after two failed corrections on the same issue
- 7.Ask Claude to show evidence (test output, command results) rather than assertions
Use cases
- Implementing features correctly by adding verification steps and test runs
- Tackling complex multi-file refactors using plan mode to separate exploration from implementation
- Fixing repeated mistakes by clearing context and rewriting prompts with explicit constraints
- Writing effective CLAUDE.md files that guide Claude without bloating the context window
- Optimizing prompts with specific file references, symptom descriptions, and pattern examples
- Claude Code users seeking to improve workflow efficiency
- Developers managing complex codebases with Claude
- Teams implementing verification and review processes with Claude
- Anyone experiencing context window degradation or repeated Claude mistakes
cc-best-practices FAQ
Use plan mode for non-trivial tasks touching multiple files or unfamiliar code. Skip it for small, obvious changes like typos or single-line fixes. Plan mode separates exploration from implementation, reducing context thrashing.
Run /clear to start a fresh context, identify what was missing from the original prompt (missing constraint, ambiguous scope, missing example), and rewrite the prompt with explicit constraints. Add the constraint to CLAUDE.md if it applies project-wide.
Include bash commands Claude cannot guess, code style rules differing from defaults, testing instructions, repository etiquette, architectural decisions, environment quirks, and common gotchas. Exclude anything Claude can infer from code, standard conventions, detailed API docs, or self-evident practices.
Provide a runnable check (test suite, build exit code, linter, diff script) and ask Claude to run it and show evidence (test output, command result). Use /goal conditions for multi-turn verification or a Stop hook to block turn completion until checks pass.
Name files using @filename, describe symptoms rather than guesses, reference existing patterns, and avoid vague language. Instead of 'add tests for foo.py', say 'write tests for foo.py covering the edge case where the user is logged out, avoid mocks.'
Full instructions (SKILL.md)
Source of truth, from dboeckli/ai-agent-skills.
name: cc-best-practices description: "Guidance on how to use Claude Code effectively — covering context management, verification strategies, the explore-plan-implement workflow, prompting techniques, session management, parallel sessions, and common failure patterns. Use this skill whenever the user asks how to get the most out of Claude Code, how to write better prompts, how to manage context, when to use plan mode, how to automate tasks, or when they describe a frustrating pattern like Claude repeating mistakes or losing track of instructions."
Claude Code Best Practices
Based on the official Anthropic documentation at https://code.claude.com/docs/en/best-practices.
The single most important constraint: Claude's context window fills up fast, and performance degrades as it fills. Every best practice flows from this.
Instructions
Step 1: Always give Claude a way to verify its work
Provide a runnable check (test suite, build exit code, linter, diff script) so Claude can confirm success independently. Ask for evidence (test output, command result), not just assertions.
Step 2: Use the Explore → Plan → Implement workflow for non-trivial tasks
Enter /plan mode, let Claude read the codebase first, then draft a plan before writing any code. Exit plan mode to implement. Skip this only for small, obvious changes.
Step 3: Write specific, scoped prompts
Name files (@filename), describe symptoms rather than guesses, reference existing patterns. Vague prompts produce vague results.
Step 4: Keep CLAUDE.md short and actionable
Include only what Claude cannot infer from the code. Every line should answer: "Would removing this cause Claude to make mistakes?" If not — cut it.
Step 5: Manage context aggressively
Use /clear between unrelated tasks. After two failed corrections on the same issue: clear and write a better prompt. Use /compact <hint> to compact with focus.
Step 6: Use subagents for investigation and review
Let subagents explore unfamiliar code or review your implementation — they run in a fresh context without bias toward the code they just wrote.
Examples
Example 1: Implementing a feature correctly
User says: "I keep getting flaky results when I ask Claude to implement something"
Actions:
- Add a verification step to the prompt: "write a validateEmail function — run the existing test suite after implementing, show me the output"
- If no tests exist: "write the function AND write tests for it, run them, show results"
- Set a Stop hook to block turn completion until tests pass
Result: Claude iterates until tests pass instead of stopping when the code looks done.
Example 2: Tackling a complex, multi-file change
User says: "How should I approach a big refactor across 10 files?"
Actions:
- Enter
/planmode — Claude explores without making changes - Ask: "read the affected files and write a step-by-step implementation plan"
- Edit the plan directly with
Ctrl+Gif needed - Exit plan mode — Claude implements and commits per the plan
- Run a subagent to review the diff in a fresh context
Result: Structured refactor with a reviewable plan, no context-thrashing from mixed explore/write turns.
Example 3: Claude keeps repeating the same mistake
User says: "I've corrected Claude 3 times on the same issue and it keeps doing it wrong"
Actions:
- Run
/clear— start a fresh context - Identify what was missing from the original prompt (missing constraint, missing example, ambiguous scope)
- Write a new initial prompt that includes the constraint explicitly: "IMPORTANT: do not use mocks in these tests — use real database connections"
- Add the constraint to CLAUDE.md if it applies project-wide
Result: Clean session with a better-specified prompt outperforms a long session with accumulated corrections.
1. Give Claude a way to verify its work
Claude stops when the work looks done. Without a runnable check, you become the verification loop. Provide something that returns a pass/fail signal Claude can read: a test suite, a build exit code, a linter, a script that diffs output.
- Ask Claude to run the check and iterate in the same prompt.
- Set
/goalconditions for multi-turn verification. - Use a Stop hook to block the turn from ending until a script passes.
- Use a verification subagent so the reviewer has a fresh context.
Ask Claude to show evidence (test output, command result, screenshot) rather than just asserting success.
Example upgrade:
Before: "implement a function that validates email addresses" After: *"write a validateEmail function. test cases: user@example.com → true,
invalid → false. run the tests after implementing"*
2. Explore first, then plan, then code
Use plan mode (/plan or the UI toggle) to separate reading from writing.
- Explore — enter plan mode; Claude reads files without making changes.
- Plan — ask Claude to write a detailed implementation plan. Press
Ctrl+Gto open the plan in your editor for direct edits. - Implement — exit plan mode; Claude codes and verifies against the plan.
- Commit — ask Claude to commit and open a PR.
Skip planning when the scope is clear and the fix is small (typo, rename, single-line change). Plan mode adds overhead — use it when the change touches multiple files or you are unfamiliar with the code.
3. Provide specific context in your prompts
Claude can infer intent but cannot read your mind.
| Strategy | Vague | Specific |
|---|---|---|
| Scope the task | "add tests for foo.py" | "write a test for foo.py covering the edge case where the user is logged out. avoid mocks." |
| Point to sources | "why does ExecutionFactory have a weird API?" | "look through ExecutionFactory's git history and summarize how its API evolved" |
| Reference patterns | "add a calendar widget" | "look at HotDogWidget.php as a pattern reference and follow it to implement a calendar widget" |
| Describe the symptom | "fix the login bug" | "users report login fails after session timeout. check src/auth/ token refresh. write a failing test, then fix it." |
Rich context techniques:
- Use
@filenameto reference files directly. - Paste screenshots or drag images into the prompt.
- Pipe data:
cat error.log | claude - Give URLs for documentation (allowlist domains via
/permissions).
4. Write an effective CLAUDE.md
CLAUDE.md is read at the start of every session. Keep it short and human-readable — bloated CLAUDE.md files cause Claude to ignore actual instructions.
Include:
- Bash commands Claude cannot guess (e.g., build/test commands)
- Code style rules that differ from language defaults
- Testing instructions and preferred test runners
- Repository etiquette (branch naming, PR conventions)
- Architectural decisions specific to the project
- Developer environment quirks, required env vars
- Common gotchas or non-obvious behaviors
Exclude:
- Anything Claude can figure out by reading the code
- Standard language conventions Claude already knows
- Detailed API documentation (link instead)
- Self-evident practices like "write clean code"
For each line: "Would removing this cause Claude to make mistakes?" If not, cut it.
Use /context to confirm Claude loaded the file. Use @path/to/file imports
in CLAUDE.md to pull in other files selectively.
5. Manage session context aggressively
/clear— reset context between unrelated tasks./compact <instructions>— compact with focus (e.g.,/compact Focus on API changes).Esc + Esc//rewind— open the rewind menu; restore conversation and/or code state to any previous checkpoint./btw— ask a quick side-question; answer appears in an overlay and never enters conversation history.
After two failed corrections on the same issue: run /clear and write a
better initial prompt incorporating what you learned. A clean session with a
better prompt outperforms a long session with accumulated corrections.
Customize compaction in CLAUDE.md:
*"When compacting, always preserve the full list of modified files and any
test commands"*
6. Use subagents for investigation and review
Subagents run in their own context window and report back summaries, keeping your main conversation clean.
Use subagents to investigate how our authentication system handles token
refresh, and whether we have any existing OAuth utilities I should reuse.
After implementation:
use a subagent to review this code for edge cases
Use /code-review skill for a bug-focused adversarial review of the current diff.
7. Automate and scale
Non-interactive mode — integrate Claude into CI, pre-commit hooks, scripts:
claude -p "List all API endpoints" --output-format json
claude -p "Analyze this log file" --output-format stream-json --verbose
Fan out across files — loop through tasks:
for file in $(cat files.txt); do
claude -p "Migrate $file from React to Vue. Return OK or FAIL." \
--allowedTools "Edit,Bash(git commit *)"
done
Parallel sessions — run multiple Claude sessions with git worktrees so edits don't collide. Writer/Reviewer pattern:
- Session A implements a feature.
- Session B reviews the diff in a fresh context (no bias toward the code it just wrote).
Auto mode — uninterrupted execution with background safety checks:
claude --permission-mode auto -p "fix all lint errors"
8. Common failure patterns and quick reference
For the full failure patterns table, all CLI commands, and non-interactive mode examples, consult references/commands.md.
Related skills
More from dboeckli/ai-agent-skills and the wider catalog.

project-references
Look up conventions and patterns from your own GitHub repositories checked out locally.

skill-best-practices
Guide for creating, structuring, and improving Claude skills (SKILL.md).

camel-matrix
Generate Apache Camel Spring Boot compatibility matrices with version range support.

claude-command-converter
Convert Claude Code commands to portable Agent Skills format for multi-runtime compatibility.

speckit-analyze
Analyze spec.md, plan.md, and tasks.md for consistency, coverage gaps, and quality issues.

speckit-baseline
Generate feature specifications by analyzing existing source code.