npx skills add ...
npx skills add dboeckli/ai-agent-skills --skill cc-best-practices
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.
npx skills add dboeckli/ai-agent-skills --skill cc-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.
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.
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.
Name files (@filename), describe symptoms rather than guesses, reference existing patterns. Vague prompts produce vague results.
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.
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.
Let subagents explore unfamiliar code or review your implementation — they run in a fresh context without bias toward the code they just wrote.
User says: "I keep getting flaky results when I ask Claude to implement something"
Actions:
Result: Claude iterates until tests pass instead of stopping when the code looks done.
User says: "How should I approach a big refactor across 10 files?"
Actions:
/plan mode — Claude explores without making changesCtrl+G if neededResult: Structured refactor with a reviewable plan, no context-thrashing from mixed explore/write turns.
User says: "I've corrected Claude 3 times on the same issue and it keeps doing it wrong"
Actions:
/clear — start a fresh contextResult: Clean session with a better-specified prompt outperforms a long session with accumulated corrections.
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.
/goal conditions for multi-turn verification.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"*
Use plan mode (/plan or the UI toggle) to separate reading from writing.
Ctrl+G
to open the plan in your editor for direct edits.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.
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:
@filename to reference files directly.cat error.log | claude/permissions).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:
Exclude:
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.
/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"*
Subagents run in their own context window and report back summaries, keeping your main conversation clean.
After implementation:
Use /code-review skill for a bug-focused adversarial review of the current diff.
Non-interactive mode — integrate Claude into CI, pre-commit hooks, scripts:
Fan out across files — loop through tasks:
Parallel sessions — run multiple Claude sessions with git worktrees so edits don't collide. Writer/Reviewer pattern:
Auto mode — uninterrupted execution with background safety checks:
For the full failure patterns table, all CLI commands, and non-interactive mode examples, consult references/commands.md.
for file in $(cat files.txt); do
claude -p "Migrate $file from React to Vue. Return OK or FAIL." \
--allowedTools "Edit,Bash(git commit *)"
doneclaude --permission-mode auto -p "fix all lint errors"