
What Are the Best Practices for Claude Code?
Carlos GarciaPublished What Are the Best Practices for Claude Code?
Most of the Claude Code advice circulating online was written for models that no longer exist.
Add IMPORTANT in capitals. Say think hard. Describe your file layout in a config file.
Delegate to a subagent for a better answer. All of it was reasonable at the time, and almost none of it helps now.
The useful advice has shrunk to something much smaller, and Anthropic's own documentation is unusually blunt about which of the old habits to drop.
What remains falls into three buckets, and the rest of this guide is about those.
What Are the Best Practices for Claude Code?
Tell Claude what it cannot see from the code. Give it a check it can run to prove the work is done.
Enforce the rules that cannot have exceptions in configuration rather than in prose.
Everything else is a default that is already set sensibly.
A fresh session starts in auto mode, runs a current model at medium effort, delegates to subagents when it sees a reason to, and compacts itself before the context window fills.
You are not meant to tune any of that until something costs more than it should.
That is the whole shape of it. The three buckets map onto the three ways a session actually goes wrong.
Claude builds the wrong thing, because it was missing context. Claude says it is done when it is not, because it had nothing to check against.
Claude does something that must never happen, because a sentence in a config file is a guideline rather than a guarantee.
Running an AI-assisted content pipeline? Get a free SEO audit and see whether the output is actually ranking.
Free audit
Where do you stand in AI search?
A manual SEO + AI search audit of your site: how ChatGPT, Gemini, Perplexity and Claude read and cite it today, and what to fix first. Report within 48 hours, no credit card.
Get my free auditOr have it all done: AI SEO services, $999 once
Two Kinds of Instruction, and Why It Matters
This is the distinction that makes the rest of the advice make sense, and it is the one most guides skip.
Every instruction you give Claude Code is one of two things.
A non-deterministic instruction is one the model reads and then decides what to do with.
Your prompt, your CLAUDE.md, a skill. Claude usually follows it. There is no guarantee.
A deterministic instruction is one the harness executes whether the model wanted to or not. A hook, a deny rule, a managed setting. It applies every time.
Most features exist in both forms, and picking the wrong form is the single most common setup mistake.
The Test for Which One You Need
Ask whether the rule has exceptions.
Prefer named exports has plenty of exceptions, so it belongs in CLAUDE.md where Claude can weigh it against the code in front of it.
Never read .env has none, so it belongs in a deny rule where the model's judgement never enters into it.
The documentation offers a useful tell: if you keep adding emphasis to a line in CLAUDE.md and Claude still misses it, that line wants to be a hook.
The reverse holds too. If you have hooks enforcing things that are only preferences, delete them.
Keep CLAUDE.md Short
CLAUDE.md loads into every session, so every line in it spends a little of Claude's attention on every task, relevant or not.
That is why the file works best holding only what Claude could not work out by reading the repo: the exact test and typecheck commands, places where the code is misleading, decisions made in meetings, and anything you have already had to correct twice.
The memory guide recommends staying under 200 lines. Run /init to generate a starting version, then spend your time removing lines rather than adding them.
/doctor suggests cuts, and /doctor prompt-audit flags instructions written for older models or that contradict each other.
Personal preferences go in CLAUDE.local.md, gitignored. Rules that only matter in one directory go in .claude/rules/ with a paths: filter so they load only when Claude is working there.
How to Set Claude Code Up, Step by Step
Six steps, and the first two carry most of the value.
- Put your check command in
CLAUDE.md. The single most useful line in the file is the one that runs your tests or typecheck. Claude needs the command to verify its own work as it goes. - Strip the file down to what Claude cannot find. Delete your architecture description and your file layout. Claude reads the repo faster than you can explain it. Run
/contextin a session to confirm the file loaded. - Write a specific prompt. Name the file, describe the symptom, and say what fixed looks like. If you want the fuller version of something rather than the minimum that satisfies the request, say
be ambitiousand list what you mean by it. - Ask for evidence, not a summary.
All tests passtells you nothing. The command and its output tells you everything, and reading it is faster than rerunning the check yourself. - Turn your two or three hard rules into configuration. Deny rules for files Claude must never read, a
PreToolUsehook for directories it must never edit, aPostToolUsehook for a step that must always run. Keep the enforced set small. - Leave the defaults alone until something hurts. Run
/usagewhen a task costs more time, tokens or interruptions than it should, and change the one default that explains it.
Is your AI-written content earning traffic? Get a free SEO audit and find out which pages are working.
When Each Practice Is Worth the Effort
Not every project needs all of this, and the triggers are fairly specific.
Give Claude a check to run the moment you notice yourself acting as the test suite. If your repo already has tests, a build or a linter, this costs one line. Stricter versions exist when you need them: /goal sets a condition a separate model verifies after every turn, and a Stop hook refuses to let the turn end until your script exits clean.
Reach for /code-review when you want a reviewer that never saw the conversation that produced the code. A fresh pair of eyes genuinely helps, which is different from delegating the same task to a subagent and expecting a better answer.
Raise the effort level with /effort high when the work depends on cases that are easy to overlook: a bug in code you did not write, a flaky test, a schema change where every reader of the old shape has to be found. Lower it with /effort low when you are iterating fast and reviewing each result anyway.
Use /clear between unrelated tasks. Every request sends the whole conversation, so a session carrying three finished tasks re-reads all three on the fourth. Clearing costs nothing and usually improves the answer as well as the bill.
Set up an unattended run only once it can answer five questions: does it know what done looks like, can it check its own work, what is it allowed to touch, what stops it, and who signs off on the result.
Limitations and What to Stop Doing
Several widely repeated practices are now actively counterproductive.
Adding IMPORTANT or capitals to an instruction Claude keeps missing. Current models follow a plainly worded line. Piling on emphasis mostly makes Claude over-apply the rule. If the line is getting lost, the file is too long.
Managing your context window aggressively. Most current models carry a very large context window and compact automatically, so running out is rare. /clear is still worth doing for focus and cost, not because you are about to hit a wall.
Using subagents to protect context. They are excellent for parallel work, for keeping noisy output out of your main conversation, and for independent review. Each one costs extra tokens, and a fresh subagent sometimes runs slower because it has to gather context you already had.
Telling Claude to keep going or not be lazy. Current models carry an agreed task through. Those lines are more likely to cause over-work than to fix a stall. If a run genuinely stops short, say continue, or enforce it with /goal or a Stop hook.
Two real limitations worth knowing. Auto mode is a classifier making judgement calls, so it can be wrong, which is exactly why your never-rules belong in deny rules instead.
And checkpoints only cover files Claude edited with its own file tools, so a file touched only by a Bash command is not restored by /rewind.
Model defaults and effort levels also move between releases. Check the current model configuration docs rather than trusting a number you read in a blog post.
Want the same rigour applied to your search visibility? Get a free SEO audit and we will show you the gaps.
Best Practices vs Just Prompting Well
A fair question: how much of this can you skip by writing better prompts?
More than you might expect, and less than you would like.
A specific prompt is genuinely the highest-leverage thing on this page, because it is the cheapest way to hand Claude information it cannot read from the code.
Naming the file and defining done usually saves a round of corrections.
Where prompting runs out is repetition and guarantees. A fact you state in every session belongs in CLAUDE.md or a skill.
A rule that must hold every time belongs in a hook or a deny rule, because a prompt is advice the model is free to weigh.
Steering is the third piece, and it is pure habit rather than configuration.
Watch the first minute, press Esc the moment Claude drifts, and after two failed corrections run /clear and write one better prompt instead of a third correction into a conversation that already contains two failures.
Final Thoughts
The short version: Claude Code's defaults are good, so configure the three things the defaults cannot know.
What your project decided in a meeting. What proves the work is done. What must never happen.
Everything else on the long lists of tips is either already handled or was a workaround for a model limitation that no longer applies.
If you want the enforcement half in detail, our guide on how Claude Code hooks work covers the exit-code contract and the setup that turns a guideline into a guarantee.
Ready to see where your content stands? Get a free SEO audit and we will map what is ranking and what is not.
Want this done for you?
SEO Stuff gets businesses cited by ChatGPT, Gemini, Perplexity and Claude, and ranking in Google. Start with the free audit, a call, or the package.
See where you stand
A free, manual SEO + AI search audit of your site, with a report within 48 hours. No credit card, no sales call.
Get my free auditTalk it through
A free 15-minute call with the founder about whether AI search is a meaningful opportunity for your business.
Free strategy callHave it done
The Done-For-You Package: audit, 10 pages of content, 3 DR50+ placements, dashboard. $999 once, delivered in 21 business days.
See the package

