Claude Code Best Practices: The Complete 2026 Guide
TL;DR: The biggest Claude Code mistake isn't a bad prompt - it's a missing system. Boris Cherny, the engineer who built Claude Code at Anthropic, says most people treat it like a search box. The teams getting 2–3× better results treat it like a new hire: they give it memory, structure, and a way to verify its own work. This guide shows you exactly how.
What Makes Claude Code Different From Other AI Coding Tools
Claude Code isn't just "Claude in a terminal." It's a full agentic coding environment - it reads files, runs bash commands, manages git, spawns subagents, and loops autonomously for days. That changes how you should prompt it.
Most AI coding tools are stateless. You paste code, get a suggestion, move on. Claude Code is stateful. It can hold your entire repo in context, remember your conventions via CLAUDE.md, and run verification loops until the output actually passes your tests.
That power cuts both ways. Give it a weak prompt and it'll confidently go in the wrong direction for 20 minutes. Give it a rich, structured prompt and it'll one-shot complex refactors you'd normally spend hours on.
Three things set it apart from a regular AI chat window:
- Long-context reasoning - it can read dozens of files and maintain coherent state across them
- Agentic tool use - it runs your tests, checks the browser, queries BigQuery, posts to Slack
- Verification loops - Boris Cherny calls this his #1 tip: give Claude a way to check its own work and quality improves 2–3×
The #1 Claude Code Prompting Mistake (And Why It Kills Your Results)
Cherny put it plainly in a January 2026 thread, and it's the one line worth remembering from this whole guide:
"The most important thing to get great results out of Claude Code - give Claude a way to verify its work. If Claude has that feedback loop, it will 2–3x the quality of the final result."
But there's a second mistake that comes before verification: starting without context.
Most people open Claude Code and type something like: "Fix the auth bug." Claude has no idea what auth system you're using, what the bug looks like, which files matter, or what "fixed" means to you. It guesses. And guesses compound.
Cherny's team at Anthropic does the opposite. They maintain a shared CLAUDE.md file checked into git. Every time Claude does something wrong, they add a rule so it never happens again. They call this Compounding Engineering - the model gets smarter about your codebase over time, not just over the conversation.
Put plainly: most people treat Claude Code like a search box they'll forget by tomorrow, instead of a system worth investing ten minutes in.
Claude Code Best Practices - The Full Framework
1. Always Provide Rich Context Upfront
Claude Code is brilliant but new to your project. Think of it like onboarding a senior engineer on day one - they're capable, but they need to know your stack, your conventions, and your constraints before they touch anything.
How to do it:
- Create a
CLAUDE.mdfile in your repo root with: build commands, test commands, coding conventions, and non-negotiables ("never use enums - use string literal unions") - Point Claude to the specific files relevant to the task before asking it to act
- State the why behind your request, not just the what - Claude makes better architectural decisions when it understands the goal
Boris's exact CLAUDE.md structure includes:
That's the whole file. A few lines, not a 3,000-word manual nobody will read.
2. Use XML Tags to Structure Complex Prompts
Anthropic's own prompt engineering docs are explicit: XML tags are the most reliable way to separate instructions, context, and examples in a complex prompt. Claude is trained to parse them cleanly.
This isn't bureaucratic overhead. It's the difference between Claude reading your intent correctly the first time versus needing three rounds of corrections.
3. Break Tasks Into Explicit Steps
For multi-file or multi-step work, always ask Claude to plan first, then implement. Boris Cherny starts almost every complex session in Plan Mode (Shift+Tab twice) and iterates on the plan before letting Claude touch any files.
The workflow:
- Describe the goal
- Ask Claude to propose a plan - no file edits yet
- Review and refine the plan
- Approve, then let Claude implement in auto-accept mode
One engineer on Cherny's team takes this further: they have one Claude write the plan, then spin up a second Claude instance to review it as a staff engineer before implementation begins.
4. Tell Claude What NOT to Do
Negative constraints are underused and extremely effective. Claude is trained to follow explicit instructions - including prohibitions.
Add these to your prompts or CLAUDE.md:
Do not add new dependenciesDo not modify public APIsDo not touch files outside src/auth/Do not add docstrings to code you didn't changeDo not create helper scripts - use the standard tools directly
The last one matters. Without it, Claude sometimes creates workaround scripts instead of solving the underlying problem. Anthropic's own docs flag this: "Do not create helper scripts or workarounds to accomplish the task more efficiently."
5. Iterate With Feedback, Not Rewrites
When Claude produces a mediocre result, most people rewrite the whole prompt. That's slower and less effective than targeted feedback.
Instead, try Cherny's exact phrasing:
- "Knowing everything you know now, scrap this and implement the elegant solution."
- "Grill me on these changes and don't make a PR until I pass your test."
- "Prove to me this works - diff the behavior between main and this branch."
What these do is push Claude out of "just finish the task" mode and into actually checking its own work. The output holds up better.
Before/After Prompt Examples (Real Comparisons)
Example 1: Bug Fix
❌ Before (weak prompt):
✅ After (rich context prompt):
Example 2: Code Refactor
❌ Before:
✅ After:
The difference isn't just length - it's specificity of constraints and a built-in verification step. That's what makes Claude's output usable on the first pass.
Claude Code vs ChatGPT - Which Responds Better to These Techniques?
Both tools improve with structured prompting, but they respond differently. Here's how they compare on the techniques above:
| Dimension | Claude Code | ChatGPT (GPT-5.4) |
|---|---|---|
| Rich context (CLAUDE.md / system files) | Native support, reads automatically | Requires manual pasting each session |
| XML tag parsing | Trained on XML structure, highly reliable | Works but less consistent |
| Plan-first mode | Built-in (Shift+Tab), team-tested | Requires explicit prompting every time |
| Negative constraints | Follows precisely, flags violations | Generally follows, occasionally drifts |
| Verification loops | Native: runs tests, browser, bash | Sandbox available but less repo-aware |
| Long-context reasoning | Stronger on large, multi-file codebases | Better for fast prototyping, quick snippets |
| Coding benchmark (SWE-bench 2026) | Claude Opus 4.6: ~80.8% | GPT-5.4: ~77.2% |
Bottom line: For deep, repo-aware work - refactors, debugging, architecture - Claude Code's native tooling gives it a structural advantage. For fast prototyping or Python/data tasks where you want immediate execution, ChatGPT's sandbox is still strong.
Advanced Claude AI Prompt Engineering Tips for 2026
These are the techniques that separate good Claude Code users from great ones. Claude AI prompt engineering in 2026 has moved well beyond "write a clear prompt."
Run parallel sessions. Boris Cherny runs 5 Claude instances simultaneously in separate git worktrees. Each handles a different task - feature, tests, code review, debugging, docs. Use claude --worktree or the Desktop app's worktree checkbox.
Use /compact and /clear strategically. Long conversations accumulate noise. When switching to an unrelated task, start fresh. When a session gets unwieldy, /compact compresses context without losing state.
Set up PostToolUse hooks. Cherny's team runs bun run format || true automatically after every file write. This catches formatting edge cases before CI fails - without adding it to every prompt.
Use subagents for parallelizable work. Append "use subagents" to any request where you want Claude to throw more compute at the problem. For large migrations, /batch fans out work to dozens of parallel agents, each in its own worktree.
Enable auto mode. Instead of approving every permission, Anthropic's built-in safety classifiers evaluate each action. Safe operations auto-approve. Risky ones still get flagged. It's the middle ground between micromanaging and --dangerously-skip-permissions.
Voice dictation. You speak 3× faster than you type. Cherny's team uses macOS voice dictation (fn × 2) for prompts - and reports that prompts get significantly more detailed as a result.
Common Claude Code Mistakes - Full Checklist
Run through this before your next session:
- No
CLAUDE.md- Claude has no memory of your conventions between sessions - Vague task description - "fix the bug" instead of specifying which bug, which file, what "fixed" means
- No negative constraints - Claude adds dependencies, touches unrelated files, creates helper scripts
- No verification step - you're not telling Claude which tests to run or how to check its work
- One giant session - mixing unrelated tasks in one long conversation degrades context quality
- Rewriting prompts instead of giving feedback - slower and less effective than targeted correction
- Skipping plan mode - jumping straight to implementation on complex multi-file tasks
- Not committing before major changes - no recovery point if Claude goes in the wrong direction
- Accepting the first solution - push back with "implement the elegant solution" before approving
- No parallel sessions - doing sequential work that could run simultaneously
FAQ - Claude Code Best Practices
Do I need a separate CLAUDE.md for every project, or can I reuse one?
Every project needs its own, since build commands, conventions, and non-negotiables differ per codebase. What you can reuse is the structure - once you've written one good CLAUDE.md, copying the format (commands, conventions, prohibitions) to a new project takes a few minutes, not a rewrite from scratch.
What happens if I skip Plan Mode and let Claude just start editing?
For small, well-scoped tasks, nothing bad - Plan Mode is overhead you don't need for a one-line fix. For multi-file or architectural work, skipping it is exactly how you end up with 20 minutes of confident work in the wrong direction, which is the failure mode Cherny warns about directly.
Is running 5 parallel Claude Code sessions actually practical for a solo developer, or just for teams?
It works fine solo, but the tasks need to be genuinely independent - feature work, test writing, and documentation rarely conflict. Trying to parallelize tightly coupled changes (like two sessions editing the same file) usually creates more merge pain than it saves.
Does giving Claude negative constraints slow it down compared to just letting it work freely?
Barely, and it saves time overall. A few lines like "don't add dependencies" or "don't touch unrelated files" cost seconds to write and routinely save the 10-15 minutes it takes to notice and undo an unwanted change later.
How is "verification loops" different from just asking Claude to double-check its work?
Asking Claude to "double-check" relies on the model re-reading its own output, which catches some but not all mistakes. A verification loop means Claude actually runs something external - your test suite, a type checker, a browser - and reacts to real pass/fail results. That's a meaningfully stronger signal than self-review.
Key Takeaways
- Rich context beats clever wording. A
CLAUDE.mdfile and specific file references outperform any prompt trick. - Structure your prompts with XML tags. Claude is trained to parse them - use
<instructions>,<context>,<constraints>. - Plan before you implement. Use Plan Mode on complex tasks. Iterate on the plan before Claude touches files.
- Negative constraints are underused. Tell Claude what not to do - it follows prohibitions precisely.
- Verification is the multiplier. Give Claude a test to run or a browser to check. Quality jumps 2–3×.
- Iterate with feedback, not rewrites. "Implement the elegant solution" beats starting over.
- Run parallel sessions. Worktrees let multiple Claude instances work simultaneously without conflicts.
Related Reading on AI Tech Safar
- The #1 AI Prompting Mistake Everyone Makes — And Claude's Creator Just Exposed It — the broader prompting mistake behind everything in this guide
- Cursor vs Claude Code vs GitHub Copilot: Which AI Coding Tool Should You Use?
Useful Sources
- How Boris Cherny Uses Claude Code - 132+ Tips - fan-curated collection of Cherny's public workflow threads
- Claude Prompting Best Practices - Anthropic Official Docs - XML tags, long-context guidance, agentic system prompts
- Boris Cherny's January 2, 2026 Thread - the original 13-tip workflow thread
- Boris Cherny's January 31, 2026 Thread - 10 more tips including plan mode and CLAUDE.md investment
- Claude Code Official Docs - hooks, permissions, subagents, and verification setup

Comments
Post a Comment