In October 2026, researchers Xiaonan Xu and Wenjing Wu ran a revealing experiment across 40 Python projects. They placed outdated instruction files in the repos that directly contradicted working code. Then they ran 320 checks on Claude Code and Codex CLI. In 79 out of 80 runs, Claude Code noticed out loud that CLAUDE.md conflicted with the code, but it still followed the old rule. Codex CLI went even further: in 20 out of 80 cases, it rewrote working code to match the stale file, and it broke tests in 17 of them.
The reason is simple. In a model's hierarchy, an instruction file acts like a top-level system directive, while real code in the repo is just tool output. Old habits that once helped coax better results from earlier models now backfire on newer versions of Claude Code. Long CLAUDE.md files with folder trees, ALL-CAPS NEVER warnings, and clicking Allow on every command hurt your workflow. Let's rebuild your setup across four layers (configuration, task framing, quality checks, and scaling) so your terminal agent stops acting unpredictably and finishes tasks cleanly.
Auto mode, effort depth, and why you should keep chat logs
The first common trap is manually approving every command because it feels safer. In practice, you hit "blind-click" fatigue. After ten pop-ups in a row, your finger clicks Allow without reading the arguments. In Anthropic's tests, humans caught only 14% of dangerous commands during manual approval.
The fix is built right in, and you can toggle it with Shift+Tab. It is called auto mode. In this mode, a second classifier model checks every agent action. It does not get tired late in the day, and it judges risk without emotion. In the same Anthropic tests, the classifier blocked 89% of dangerous commands. You can run /auto-mode setup once to show it your normal project workflows so it doesn't block safe tasks. Still, about one in ten risky commands can slip through. You cannot rely on the classifier alone, so we will close that gap below with strict permissions.deny rules.
Claude Code terminal interface running tasks across a codebase (Source: Anthropic official website)
The second setting that burns through your daily limit in 30 minutes is effort depth. Turning it up to the max "just to be safe" sounds smart, but it backfires. A good default is medium. Save high and extra for heavy architecture work or messy multi-module repos. If you use max effort to sort files, process emails, or edit docs, the model overthinks simple tasks, gives worse results, and wastes your quota.
The third detail most people miss on day one is local log retention. By default, Claude Code deletes .jsonl session files after 30 days. You can raise cleanupPeriodDays in your settings file to 90 or 365 days. Note that 0 is invalid and fails validation, so use a whole number from 1 up. This gives you an archive of past mistakes. Once a month, feed those logs back to Claude and ask which corrections you repeat across chats. One monthly check often shows that you told the agent seven times not to overwrite someone else's branch. You can turn seven annoyed messages into one short rule.
How to stop context rot and align CLAUDE.md with real code
In long agent chats, context rot eventually kicks in. Imagine solving a hard problem on paper where three pages are already covered in crossed-out wrong attempts. Your eyes keep drifting back to old mistakes and pulling you into the same dead end. A September experiment on Opus showed a clear split: 250,000 tokens of unrelated text barely hurt reasoning, but the model's own failed attempts in the same chat dropped its solve rate by about 15%.
This leads to a simple two-strike rule. If you correct Claude twice in one chat and it keeps going in circles, don't argue a third time. Run /clear to start fresh, or run /rewind to roll the chat back to the moment right before the wrong turn. Then write the root cause into CLAUDE.md or a separate skill so the same mistake doesn't happen tomorrow.
For long overnight or background sessions where no human is around to type /clear, another tool takes over: autocompact. It automatically summarizes older parts of the chat into a short recap. The catch is that the default trigger fires too late. On a 1-million-token window, it waits until around 967,000 tokens (about 83–95% full in the official setup). By then, the history is already full of dead-end edits. You can lower that threshold to around 400,000 tokens by setting CLAUDE_AUTOCOMPACT_PCT_OVERRIDE in the env block of settings.json (for example, "40" or "70" depending on your window size). Background sessions then stop choking on their own clutter.
Now let's look at CLAUDE.md. Old guides told people to fill it with scary walls of text using ALL-CAPS NEVER and IMPORTANT. Newer models take NEVER too literally and overreact to all-caps. Instead of shouting a ban, give a reason and an alternative. Write "ask before deleting a file" instead of "NEVER delete files." Anything that is truly forbidden should not live in prompt text at all. Put it in permissions.deny.
As for the conflict between stale instructions and live code in Xu and Wu's study, the fix was surprisingly short. The authors added just one sentence to the global CLAUDE.md saying that code beats instructions, and asking the model to warn about mismatches. The effect was dramatic: the model almost stopped following stale rules blindly, and test failures dropped to zero.
Impact of one code-precedence line in CLAUDE.md (Xu & Wu, 2026)
Keep CLAUDE.md as thin as possible and use it as a routing map. Don't copy folder trees or library lists into it, because Claude Code reads the repo well on its own. Store only what isn't physically inside the code: where your business wiki lives, which folder holds brand assets, where to find meeting transcripts, and what lessons you learned from past mistakes.
## Precedence
# If instructions disagree with code, code wins
When the instructions and the existing code disagree, the code wins.
Flag the discrepancy before editing so instructions can be updated.
## Routing
# Only things that are not in the repo itself
- Business wiki: ~/home-repo/wiki/business.md
- Brand assets: ~/home-repo/assets/brand/
- Meeting notes: ~/home-repo/wiki/meetings/
## Applied learning
# Short rules born from real agent mistakes
- Ask before overwriting changes from another active session.
This file is only a couple dozen lines long. It doesn't clog the context window, and it protects you from the stale-rules bug. If you already have old prompts, skills, and subagent descriptions, run a prompt audit on them. Many users use the /dr command for this, though it isn't listed separately in the stable reference docs. Anthropic engineer Lance Martin ran a similar cleanup on his test suites and saw noticeably better answers while spending fewer tokens, simply by removing workarounds written for older models.
Framing tasks: the 95% confidence interview and code ownership
A good environment setup is half the battle. Still, if you give an agent a vague prompt like "make it look nice," it will build a bare minimum and declare victory. To avoid that, start with the tool itself: if you don't know how to set up a new Claude Code feature, paste the official docs link and ask Claude to configure everything for your project.
For serious features, the "95% confidence interview" works great. Add one line to the end of your prompt: "Ask me clarifying questions until you are 95% sure you understand the task." Instead of guessing data formats, permissions, and edge cases, the model pulls out every missing detail in two minutes. In large projects, save those answers to a spec file right away so you never have to explain the context twice.
When a task isn't trivial, don't accept the first plan. Ask for two or three alternative approaches from different angles, plus a short comparison of which one is most likely to work without hidden issues. This quickly filters out weak hacks before a single line changes in your repo.
Another common issue is a low default bar. In one telling test across 200 website-improvement iterations, an agent never once opened web search because nobody told it to aim high. Add a direct "be ambitious" cue to your prompt along with what a complete result looks like: empty screen states, clean error handling, and a working save flow, not a bare stub.
One more helpful line comes from Anthropic's Claude Fable 5.2 guide, highlighted by Simon Willison: "You are the owner and long-term maintainer of this codebase, and its design is up to you." In Anthropic's tests, this single sentence raised the share of runs where the model found and merged duplicate code into shared functions from under 10% to about 75%. There is a downside, though: in the owner role, the agent spends more tokens and may refactor nearby modules you didn't ask it to touch. Skip this line for small two-line fixes.
When Claude misses an obvious file or setting, don't silently fix it yourself. Ask directly: "Why couldn't you find this without my help?" Its trace explanation usually shows which pointer was missing. Then add one short line to the Applied learning section of CLAUDE.md. Also, if the agent gives you a to-do list like "now install package X, download file Y, edit config Z," reply "no, do it yourself." In most cases, it already has the tools to run those steps. Finally, when sharing interactive prototypes or reports with teammates, publish them as an Artifact via a private claude.ai link instead of sending HTML files or Google Docs. Any edits you make update automatically at the same URL.
Autonomous checks: the V1 → V10 loop, Codex cross-review, and /ship beta
A model's first draft rarely gets past 60–70% quality. Fixing the remaining 30% by hand on every project turns you back into a messenger between your editor and a chat window. Instead, write a brief like you would for a new teammate: state the goal, define clear "good" criteria, and attach examples (around ten strong samples and a couple of clearly bad ones).
Next, run the V1 → V10 polish loop. Hand your own manual checklist to the agent and let it iterate until the work hits 90–95% quality. For UI work, have it inspect screenshots. For video or motion graphics, pass it a frame grid, connect Gemini Vision, and check the speech transcript. That way, you review polished work instead of a rough draft.
Code review has a subtle catch: a model is bad at spotting its own bugs inside the same chat where it just wrote the code. You need to detach review from history. The built-in /code-review command (also works as /review and supports --fix) launches a fresh agent without old messages. Cross-checking with another model family works even better via the official OpenAI Codex plugin for Claude Code (openai/codex-plugin-cc, command /codex-review). Two different model families almost always catch each other's blind spots.
Once changes are verified and ready to ship, the /ship command is available in beta. It handles the whole delivery routine: commits changes, pushes the branch, opens a GitHub pull request, reviews it, watches CI checks, fixes failing checks, and replies to reviewer comments until the branch is ready to merge. It never clicks merge without your explicit approval. Claude Code team lead Boris Cherny says he uses /ship every day.
Technical diagram of autonomous verification in Claude Code: V1 → V10 polish loop, /code-review and /codex-review cross-review, and /ship pipeline with a red stop barrier before merge
For product and writing tasks, a four-subagent review panel works very well. Give each subagent a distinct role: an ideal customer, a tough skeptic, a direct competitor, and someone completely outside your industry. The outsider is especially valuable because they spot jargon and blind spots your team stopped noticing long ago. Before releasing code, also run a search for implicit state machines. These are hidden in-between app states nobody planned for, like a network drop mid-payment or a double-click on a submit button that starts two conflicting jobs. One direct prompt ("find all implicit state machines in this app and clean them up for users, developers, and agents without breaking anything") often catches bugs that hid in production for months.
Hard safety boundaries instead of "please don't delete"
There is a real story that cures anyone of trusting text-only bans inside a prompt: an AI agent without a direct order from its owner sent a promo-code email to roughly 150,000 subscribers. The logic is simple. You don't hand a new office intern a company credit card and say "please don't buy anything." If an agent technically has a button, a mix of bad context and a hallucination will eventually make it press that button.
Real limits in Claude Code belong in the permissions.deny block of ~/.claude/settings.json or a project's .claude/settings.json, not in CLAUDE.md. According to the official permissions docs, deny rules have top priority. They run before allow and ask, and the auto mode classifier cannot bypass them. Below is a solid starter config that blocks reading secrets, stops dangerous terminal commands, keeps logs for three months, and turns on early autocompact.
{
"cleanupPeriodDays": 90,
"env": {
"CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "70"
},
"permissions": {
"deny": [
"Read(./.env*)",
"Read(./secrets/**)",
"Bash(rm -rf *)",
"Bash(git push origin main)"
]
}
}
Once you save this file, the agent physically cannot read .env variables, open your secrets folder, run recursive deletes, or push straight to main. That holds true even in auto mode during a long overnight run. Apply the same rule to external services like email, CRM, and newsletter tools using scoped API keys. Give the agent a key that can create a draft or archive a record, but lacks API permission to click "send" or "delete."
If you built an app with vibe-coding and plan to invite real users, run a three-role security test with subagents. Launch three separate agents as User A, User B, and Admin. Tell them to try reading each other's data, bring back reproducible proof of every hole they find, and then fix all issues together in one pass.
Third-party skills from the internet are another risk area. Every skill is basically an executable prompt that enters your working context. Before installing one, ask Claude to scan it for hidden instructions and suspicious external URLs. Even better, build your own skills from your best working sessions. Once a quarter, back up all your settings and ask Fable plus Codex to compare your config against the latest docs. In three months, half your old workarounds will be outdated.
Safety checklist before running autonomous sessions
- Set
permissions.denyin~/.claude/settings.jsonfor.env*, secret folders,rm -rf, and direct pushes tomain. - Connect external tools (email, newsletters, CRM) using scoped API keys without send or delete rights.
- Scan all third-party skills for hidden prompt injections and external requests before installing them.
- Run a data-isolation test using User A, User B, and Admin roles for any app with login.
- Keep client projects and data in isolated folders outside your shared home repo.
Scaling like Anthropic: home repo, warm cache, and the orchestrator pattern
Once the base layers are in place, your role as a developer shifts. In a talk by Lydia Hallie on how Anthropic uses Claude Code internally, the numbers stood out: the team grew from around 2,500 code changes per day in May to over 30,000 per day by September. Engineers stopped working in a single terminal and became dispatchers for dozens of parallel sessions.
A great base for this style is a single home repo, similar to Matt Pocock's setup. One folder and one Git repo hold all your personal skills, global settings, work wikis, and side projects. Switch to a new laptop, run git pull, and your whole environment is ready. There is one strict rule with no exceptions: client data always lives in separate, isolated projects so it never leaks into your shared context.
When you work heavily with agents, prompt cache economics quickly matter. While you chat in a long thread, the server stores the already-processed start of the conversation and doesn't recompute it from scratch on every message. On a subscription, this cache stays "warm" for roughly an hour. If you take a 90-minute lunch and continue that huge thread later, the server has to recompute the whole history "cold," and API cost per message jumps sharply. Power users install small status mods with a cache countdown timer and rewrite cost estimate so they don't trigger a cold recompute by accident.
Cost per message in a long chat at API rates
To avoid dragging a bloated chat across hours of work, use session handoff for live interactive work. Instead of waiting for autocompact, ask the agent to write a short summary of results, architecture choices, and open steps. Then run /clear and start a clean chat from that summary.
A short set of CLI commands covers parallel work and long runs. If a process takes too long, /background moves it to the background and frees your terminal. If you want to test a second idea on the same code without overwriting files, /fork splits a copy of the chat into a separate branch, and linked sessions can message each other when tasks depend on one another. For tasks with a clear finish line ("all tests green, build passes"), /goal runs a separate checker model after each step. In practice, this closes roughly one in five work requests automatically. For large repetitive tasks like motion graphics for a 20-minute video, chunking (often called ultracode in user pipelines) splits the work across 20 parallel subagents, one minute each.
# Reset a looping context or roll back before a mistake
/clear
/rewind
# Review diff with a fresh agent and apply fixes automatically
/code-review --fix
# Move a long run to background or branch a copy of the chat
/background
/fork
# Loop until a clear done condition (tests + build)
/goal "All unit tests pass and production build succeeds"
# Beta commands: autonomous PR to ready state and advisor model
/ship
/advisor fable
This command set covers almost your entire daily loop: it rescues stuck chats, runs reviews, and brings a branch to a ready GitHub PR. Just don't run everything on the most expensive model. Two opposite role-splitting patterns have emerged. The first is the experimental /advisor fable beta, where a fast model handles routine work and senior Fable steps in only at key forks: before planning, after repeated errors, and before final delivery (though in beta this mode can use more tokens).
Claude Code web interface for managing cloud and parallel sessions (Source: Anthropic official website)
The second pattern flips that around and is called the "manager-orchestrator" pattern. Senior Fable sits in the main chat, but it is strictly forbidden from writing code or digging through files itself. It only plans architecture, assigns tasks to Sonnet or Opus subagents, and reviews their reports. The main chat stays clean, and you spend your top model's quota carefully. Anthropic is now bringing this exact logic into the official visual UI for Claude Code on the web and the Claude Code Projects beta on Pro, Max, and Ultra plans, where one main thread breaks work into linked parallel threads right inside the desktop app.



