Guide / Tutorial

Claude Code Best Practices, Rethought for Today’s Models

As Claude models handle hours-long tasks, last year's Claude Code habits start to hurt. This guide explains what to remove from CLAUDE.md, how auto mode decides, which deny rules still matter, why sandboxes and cloud sessions close the remaining gap, how hooks and CI verify work, and how one orchestrator session can run the rest.

Claude CodeThis guide is about Claude Code.
Claude Code Best Practices, Rethought for Today's Models

What changes when Claude Code sessions run for hours on their own: trim CLAUDE.md, let auto mode approve, keep deny rules for what you can’t undo, sandbox or move to the cloud, give Claude pass/fail checkpoints with hooks, and let CI and an orchestrator carry the scale.

Reading map

  • Part I — Get out of the loop: why old habits hurt, updating the model, trimming CLAUDE.md and configuring auto mode (sections 1 to 4).
  • Part II — Keep it safe: deny rules for what you can’t take back, the sandbox, and cloud sessions (sections 5 to 7).
  • Part III — Make sure it’s right: checkpoints, hooks and exit codes (sections 8 and 9).
  • Part IV — Scale it: CI, review by risk, and an orchestrator session (sections 10 to 12).
  • A summary table, a final perspective, a quick reference and a FAQ close the guide.

Why This Matters

Early in the year, a Claude Code session was a conversation with constant interruptions. The model stopped early, needed correcting, and asked permission for almost every command. People compensated with longer CLAUDE.md files full of capital letters and exclamation marks.

The current models work for hours, understand the codebase and check their own results. At Anthropic, the change shows in a single number: code changes merged per day into the company’s monorepo went from about 2,500 in May to more than 30,000 in September. Developers there run dozens of sessions at once, and some sessions coordinate other sessions.

That shift has a consequence. Every job a person used to do inside the session, steering, approving, saying no, checking, starting, must now be done by something else: the model, the tools around it, or the environment it runs in. The practices below are the old ones, moved to new owners.

If you step out of the loop, something else has to take over that job.

Part I — Get Out of the Loop

1. Why yesterday’s habits now hurt

Two questions decide whether you can leave a session alone: is the code good, and is it running safely? Old best practices answered both by keeping a human in every step. With current models, that costs more than it saves, and some habits actively make results worse. Instructions shouted in capitals push a capable model off course, producing more tool calls and weaker work.

Last year's habits: shouting in CLAUDE.md and approving every command.
Last year’s habits: shouting in CLAUDE.md and approving every command.

2. Start from today’s defaults

The first step is the easiest: use the current defaults. Switch the model from an older one such as Opus 4.5 to Opus 5.5, and switch permissions from manual approval to auto mode, which has been the default since August. A model that understands your intent and your codebase needs far less steering during the session.

Today's defaults: a current model and auto mode.
Today’s defaults: a current model and auto mode.

3. Trim CLAUDE.md to what Claude can’t see

A CLAUDE.md written for older models typically looks like this:

Think hard and be thorough.
Keep going until it's done.
IMPORTANT: always use the auth helper
We're on Node 18.
src/legacy still serves our mobile apps

With a current model, only the last line earns its place. The model already thinks carefully, keeps going and reads your stack from the code. What it cannot see is a fact with no trace in the repository, such as a legacy folder that still serves the mobile apps. Keep facts like that; delete the rest.

Claude Code has a command for this clean-up, /doctor prompt audit. Run it with the model you use, and it checks your CLAUDE.md and skills for instructions that model no longer needs.

Delete instructions the model no longer needs; keep facts it can't see in the code.
Delete instructions the model no longer needs; keep facts it can’t see in the code.

4. Configure auto mode in plain language

Auto mode lets reads and edits inside your project through without a check. Everything else goes to a separate classifier: commands it knows are safe, like running tests or installing dependencies, are allowed; anything it is unsure about is blocked.

By default it trusts only the current folder and repository, so a legitimate request such as “push this to staging” can be blocked and pull you back in. The fix is to describe your environment in plain language in the settings. This text is what the classifier reads:

"autoMode": {
  "environment": ["$defaults",
    "Source control: github.com/acme and all repos under it",
    "Trusted cloud buckets: s3://acme-staging",
    "Trusted internal domains: *.internal.acme.com"],
  "allow": ["$defaults", "Deploying to staging is allowed"],
  "hard_deny": ["$defaults", "Never send code to third-party APIs"]
}

If you still approve many commands in auto mode, this is the first place to look.

Auto mode settings: trusted repositories, buckets and domains, plus what to allow and never do.
Auto mode settings: trusted repositories, buckets and domains, plus what to allow and never do.

Part II — Keep It Safe

5. Deny rules for what you can’t take back

Auto mode is good, but it is not a guarantee. In a study Anthropic published in August, people reviewing commands caught only about 14 percent of clearly dangerous ones, while auto mode blocked 89 percent. That is far better than humans, and still means about one in ten got through.

A guarantee has to come from the system. Deny rules are checked before the auto mode classifier sees a tool call; a matching call never reaches it. To decide what deserves a rule, ask one question: can I take it back?

Can I take it back? Examples What to do
Yes Edits to code, tests, docs; anything git can revert Leave it to the model
No Deletes something for good, exposes a secret, sends something outside Make it a rule

For example:

"permissions": {
  "deny": ["Bash(git reset --hard *)", "Read(./.env)"]
}

With the .env rule in place, even a cat .env cannot open the file.

Deny rules run before the classifier; the test is whether you can take it back.
Deny rules run before the classifier; the test is whether you can take it back.

6. The sandbox closes the side-effect gap

Permissions decide whether a command runs, not what it touches while running. npm test looks harmless, but it runs your test runner, your tests and code from node_modules that you did not write. A compromised dependency could read .env or ~/.ssh and send it to an outside server, and a human approving commands would have clicked allow anyway.

You cannot block npm test, because tests are how Claude checks its own work. Instead, limit the environment. With the sandbox enabled ("sandbox": {"enabled": true} or /sandbox), shell commands and every process they start can only read, write and reach the files, folders and hosts you allow, enforced by the operating system. Your deny rules are passed down too, so the dependency’s attempt to open .env simply fails. By default the sandbox can still read most files on the machine, so add a rule such as Read(~/.ssh/**) for your keys.

The sandbox covers shell commands. Claude’s own Read, Edit and WebFetch tools, MCP servers and hooks still run outside it, on your machine with everything on it.

The sandbox: limits enforced by the operating system, with what still runs outside it.
The sandbox: limits enforced by the operating system, with what still runs outside it.

7. Cloud sessions: nothing to steal, nothing to wait for

The cleanest answer is to run the session where your secrets do not exist. A cloud session gets its own machine with a fresh copy of the repository. Your .env, SSH keys and GitHub token are simply not there, and the session keeps running after you close the laptop, which long sessions need anyway.

If the task needs an API key, add it as a network secret: the session can use it without the model ever seeing the value. Network access is limited by default to resources such as package registries, so add any other domains explicitly.

The machine is temporary; what leaves it is not. A commit or a message sent through a connector is still there when the machine is gone, so keep auto mode and commit your deny rules to the repository, where they also stop things like force-pushes or secrets in commits.

A cloud session: its own machine, a fresh repo, no local secrets.
A cloud session: its own machine, a fresh repo, no local secrets.

Part III — Make Sure It’s Right

8. Give Claude checkpoints, not a vague goal

When you approved every step, you knew what happened. When a session runs for hours, you will not reread every file. And a clear request still leaves room for many plausible results. “Move auth over to the new API” can end with the old API still in place, with only new logins migrated, without token refresh, or with everyone logged out.

So give the session checkpoints: anything that returns pass or fail. A test, a build, a screenshot. A failing check sends the run back to look for another way, long before you would have noticed. The simplest version lives in the prompt:

Move auth over to the new API.
It's done when the auth tests pass and nobody gets logged out.
Split it into tasks, each with its own test.
Show me the test output.

Asking for the output matters, because you did not watch the work happen.

One request, several plausible results: checkpoints decide which one is right.
One request, several plausible results: checkpoints decide which one is right.

9. Hooks for checks that must happen, and exit code 2

A prompt is a request, not a guarantee. For checks that must run, use hooks: scripts Claude Code runs at specific moments.

Moment Hook event Run
Every edit PostToolUse the linter
Every task marked done TaskCompleted the tests for that area
The end of the session Stop all tests

One detail trips many people up. When a test fails, most tools exit with code 1, and with code 1 Claude Code still marks the task as completed. Make your hook scripts exit with code 2: that is what sends Claude back to fix the problem.

npm test || exit 2
Hook exit codes: 1 marks the task done, 2 sends Claude back to fix it.
Hook exit codes: 1 marks the task done, 2 sends Claude back to fix it.

Part IV — Scale It

10. CI is the common checkpoint

Once a session can be left alone, you can run many. Each cloud session has its own machine, so they never share a folder and worktrees stop being a concern. What ties them together is CI: every session ends in a pull request, and CI runs the same checks on every one of them, regardless of what happened inside the session.

With CI auto-fix, Claude sees when a check fails and goes back to fix it. For suitable repositories, GitHub’s merge-when-ready setting can merge a pull request as soon as all checks pass.

Every session ends in a pull request; CI checks them all.
Every session ends in a pull request; CI checks them all.

11. Review by risk

How much people review is a question of risk, not habit. On the Claude Code team, every pull request is first reviewed by Claude, but not by the session that wrote it: a fresh context, plus a separate group of agents that verify each bug before it is posted, so only the real ones reach the pull request.

Change Human review
Smaller changes, such as a typo, docs or a lint fix None; merge when checks pass
Most changes One person
Riskiest changes More than one person
Review effort follows risk.
Review effort follows risk.

12. One orchestrator instead of eight tabs

Managing many sessions yourself means constant context switching. The direction at Anthropic is one main session that acts as an orchestrator. You tell it what needs doing; it breaks the work down, starts a separate session for each piece, tracks the results and sends unfinished work back until it passes verification.

The orchestrator does not write code, so it needs a model that is good at deciding and judging, such as Fable. The workers need a model that builds well, such as Opus 5.5. They can be configured separately, and the orchestrator manages context automatically, so you no longer decide when to compact or clear.

One orchestrator session splits the work and checks the workers.
One orchestrator session splits the work and checks the workers.

Old Jobs, New Owners

What you used to do Now done by
Steering it The model
Approving every tool call Auto mode
Saying no Deny rules, the environment
Checking it’s done Tests, hooks, CI
Starting every session Claude (an orchestrator)

Final Perspective

None of the old best practices disappeared. Permissions, tests, review and careful setup still matter; they simply moved from a person watching every step to the system around the model. The model steers, auto mode approves, deny rules and the environment refuse, tests and hooks and CI verify, and an orchestrator can even start the sessions. The person starts the first session and reviews the result.

The practical way in is gradual. Take one task much bigger than you would normally give Claude. Make sure your CI actually catches what matters to you. Set up the environment: network access, secrets and a setup script. Then run it in the cloud and notice where you still get pulled back in. That spot is the next thing to hand off.

Quick Reference

Area What to do
Model and permissions Current model (e.g. Opus 5.5) + auto mode
CLAUDE.md Keep only facts Claude can’t see in the code; run /doctor prompt audit
Auto mode blocks real work Describe trusted repos, buckets, domains, allow and hard_deny in settings
Irreversible actions Deny rules, e.g. Bash(git reset --hard *), Read(./.env)
Side effects of commands Enable the sandbox; deny Read(~/.ssh/**)
Long or risky sessions Cloud session; network secrets; allow domains explicitly
Prompt Define done, split into tasks with tests, ask for the output
Hooks PostToolUse → lint, TaskCompleted → its tests, Stop → all tests; exit 2 on failure
Many sessions CI on every PR, CI auto-fix, merge when ready where safe
Review Claude review first; humans by risk (0 / 1 / 2+)
Orchestration Judge model for the main session, builder model for workers

FAQ

What should go in CLAUDE.md for current Claude models?

Only what Claude cannot see in the code, such as a legacy folder that still serves an app with no reference in the repository. Generic instructions like “think hard”, “keep going” or “IMPORTANT” can make current models worse. /doctor prompt audit checks CLAUDE.md and skills against the model you use.

Is Claude Code’s auto mode safe?

It blocks far more dangerous commands than people reviewing them did in Anthropic’s study (89 percent against 14 percent), but about one in ten still got through. Use deny rules for anything you cannot undo, and a sandbox or cloud session to limit side effects.

What is the difference between deny rules and the sandbox?

Deny rules decide whether a tool call runs at all and are checked before auto mode. The sandbox limits what a running shell command, and every process it starts, can read, write and reach, enforced by the operating system.

Why does Claude Code mark a task done when my hook’s tests fail?

Because the hook exited with code 1. Make the hook script exit with code 2 on failure; that sends Claude back to fix the problem.

How do I run many Claude Code sessions without watching them?

Run them as cloud sessions, give each a clear definition of done with tests and hooks, let CI check every pull request with auto-fix enabled, review by risk, and consider one orchestrator session that starts and checks the others.

Further Reading

  • Claude Code documentation: best practices, auto mode, permissions, sandboxing, hooks and cloud sessions.
  • On AIBotRadar: more guides on Claude, Claude Code and AI coding workflows.

Model names, commands, settings and numbers change often; check the current Claude Code documentation before changing your setup.

Claude Code GUIDES

More Claude Code guides

Continue with practical guides about Claude Code.

View all Claude guides