Best practices
This is the authority layer: a curated set of habits that separate fluent Claude Code use from fighting the tool. Each tip is a one-line rule and the reason it matters. Guidance is Official (Anthropic) unless explicitly labeled Community.
TIP
If you remember one thing: context is your fundamental constraint. Almost every practice below is really about keeping the context window clean, relevant, and verifiable.
Workflow
- Follow explore → plan → code → commit. Let Claude read the relevant code before it writes any, plan the change, implement, then commit. Skipping the explore step is the most common cause of confidently wrong edits.
- Don't over-plan. If the diff is one sentence to describe, skip the plan and just ask. Planning a trivial change wastes tokens and your attention.
- Always give Claude a verifiable check. Tests, a build, or a screenshot to compare against is "the difference between a session you watch and one you walk away from." Without a check, the model has no signal that it succeeded.
- For big features, interview-me-then-spec, then implement in a FRESH session. Have Claude interview you to produce a spec, then start a clean session to build it. The planning conversation is clutter the implementation doesn't need. → Spec a big feature
- Iterate visually. Paste a screenshot, let Claude compare its result to the target, and fix the differences. The visual loop closes much faster than describing UI in prose.
TIP
If you can't verify it, don't ship it. Unverifiable output is the single highest-risk anti-pattern — see Anti-patterns.
Context and cost
/clearbetween unrelated tasks;/compactmid-task./clearwipes context for a clean start;/compactsummarizes so you keep the thread while shedding weight.- Community: prefer
/clearunless the cache is warm./compactis only cheap inside the ~5-minute prompt-cache warm window; outside it,/clearis the cheaper reset. - Keep CLAUDE.md lean. A "bloated CLAUDE.md causes Claude to ignore your instructions." Litmus test for every line: would removing this cause a mistake? If not, cut it.
- Be specific. Vague prompts cost 50k+ extra tokens as Claude explores to fill the gaps you left. Precision is cheaper than re-rolling.
- Match the model to the job. (Community framing) Sonnet handles ~80% of work; reach for Opus on hard architecture or tricky bugs, Haiku for trivial tasks. See Cost optimization.
- Community: tune
MAX_THINKING_TOKENS. Tuning thinking budget can cut cost ~30–40% on some workloads. This is single-source — test it on your own tasks before trusting it. - Move occasional workflows into skills. Knowledge you need sometimes shouldn't tax every session's context. Skills load on demand; CLAUDE.md loads always.
See The context window for the model behind all of this.
Subagents
- Reach for subagents early — context is the constraint. "Since context is your fundamental constraint, subagents are one of the most powerful tools." They do work in an isolated window and return only a summary, keeping your main thread clean.
- Use them for many-file reads and isolated focus. A subagent can read twenty files and hand back three sentences, so the bulk never touches your context.
- Run adversarial review in a fresh context. A reviewer that sees only the diff catches issues the author's polluted context misses.
- But don't chase every finding. Acting on every nit is its own anti-pattern — over-engineering. Triage, then fix what matters.
See Subagents.
Skills and hooks
- Skills for "sometimes-relevant" knowledge. When something matters occasionally, a skill keeps it out of CLAUDE.md and out of every session until it's actually needed.
- Hooks for what must happen every time, with zero exceptions. Hooks are deterministic where skills are probabilistic — if a step can't be optional, it can't be a skill.
- Community:
PreToolUseexit-2 is a hard guarantee. A non-zero exit blocks the tool call outright, giving you an enforced gate (e.g. "never write to this path") rather than a polite request.
See CLAUDE.md for what belongs there versus in a skill.
MCP
- Community: keep ~3–6 MCP servers. Each server's tool definitions consume context on every turn; too many quietly starve the work you actually care about.
- Prefer the
ghCLI over the GitHub MCP. (Official-leaning) The CLI is more token-efficient than the MCP server's tool surface for the same GitHub operations.
Anti-patterns
- The kitchen-sink session. Many unrelated tasks in one thread bury the signal. Fix:
/clearbetween them. - Correcting more than twice. If you've corrected Claude 2+ times, the context is cluttered, not the model confused. Fix:
/clearand write a better prompt — "a clean session with a better prompt almost always outperforms a long session with accumulated corrections." - The over-specified CLAUDE.md. Every speculative rule is a tax on every session and dilutes the rules that matter.
- Shipping unverifiable work. "If you can't verify it, don't ship it." No test, build, or visual check means no evidence it works.
- The unscoped infinite "investigate." Open-ended exploration eats context without bound. Fix: scope it tightly or delegate it to a subagent.
A note on rigidity
NOTE
These are starting points, not set in stone. "Sometimes you should let context accumulate because you're deep in one complex problem." The rules optimize for the common case; you are allowed to break them deliberately when you know why.
Sources: