Claude Code Settings That Cut Cost: Model Routing, /clear Discipline and Context Hygiene
20 October 2026 · Updated 28 November 2026 · 12 min read · by Yang Kai
Control Claude Code spend at the settings level: route models by task, keep context lean, and build the /clear habit — practical levers, honestly framed.
Checklist inside: Cost-cutting settings and habits checklist
Contents
- Lever 1: set the default model to the workhorse, not the flagship
- Lever 2: turn the effort level down for routine work
- Lever 3: put subagents on a cheaper model
- Lever 4: context hygiene is a settings problem
- Lever 5: /clear discipline
- Lever 6: know which billing shape you are on
- Settings and habits checklist
- Cost-control checklist
You reduce Claude Code cost at the settings level three ways: route each task to the cheapest model that can do it, keep the context window lean so you stop re-sending dead history, and build the /clear habit into how sessions end. This article sets out the exact settings, with no savings figure we cannot back up.
One warning first, because it changes several recommendations you will find elsewhere: some widely copied settings advice is out of date. The thinking on/off switch that older guides recommend no longer switches thinking off on Anthropic’s newest models — the effort level is the dial that replaced it. And the .claudeignore file some guides tell you to create does nothing at all; Anthropic’s documentation says so in plain terms. Everything below is checked against Anthropic’s settings, model configuration and permissions documentation, and its published pricing, in November 2026.
This is the settings-level companion to the Claude Code cost ladder, which maps the bigger decision of plans versus API. Read that for the strategy; use this for the dials. And if you have never measured where your context actually goes, the context budget audit is the diagnostic to run first — settings applied blindly, without knowing your own leak, are just superstition.
The levers at a glance:
| Lever | Setting or command | What it changes |
|---|---|---|
| Default model | model in settings.json |
The tier every session starts on |
| Per-task routing | /model, --model, opusplan |
The tier a specific task deserves |
| Reasoning depth | effortLevel, /effort |
How many thinking tokens a task burns |
| Subagent model | CLAUDE_CODE_SUBAGENT_MODEL |
What exploration and side work costs |
| Context hygiene | CLAUDE.md length, Read deny rules, /clear |
The fixed tax on every request |
| Billing shape | Plan vs API | Whether waste costs allowance or dollars |
Lever 1: set the default model to the workhorse, not the flagship
The single largest cost variable in most sessions is model choice, and the most common waste is running the strongest, most expensive model on work that does not need it. Claude Code’s model setting takes an alias, and the aliases always point at the current model in each family:
| Alias | Resolves to (Anthropic API, Nov 2026) | Sensible use |
|---|---|---|
haiku |
Claude Haiku 5.5 | Mechanical edits, lookups, simple generation |
sonnet |
Claude Sonnet 5.5 | The daily default for most coding work |
opus |
Claude Opus 5.5 | Hard debugging, architecture, high-stakes changes |
opusplan |
Opus in plan mode, Sonnet for execution | Big tasks where the design is the hard part |
fable |
Claude Fable, the top tier | The longest, hardest agent runs |
Set the default to the workhorse:
{
"model": "sonnet"
}
…in ~/.claude/settings.json for your machine, or .claude/settings.json for a project. Then step up deliberately when a task earns it. Know the priority order, because it explains most “my setting is being ignored” mysteries: /model inside a session beats --model at launch, which beats the ANTHROPIC_MODEL environment variable, which beats the settings file.
The opusplan alias deserves a line of its own. Planning is the thinking-heavy phase and execution is usually the typing-heavy phase; opusplan runs the first on Opus and the second on Sonnet automatically. For a large, well-understood change, that is the routing most people try to do by hand, done for you.
One more setting matters if you work in a team or across providers: the aliases can be pinned. ANTHROPIC_DEFAULT_SONNET_MODEL and its Opus and Haiku equivalents fix which exact model an alias resolves to, so sonnet means the same thing on every machine and every provider. Pinning is partly a consistency tool, but it is also cost control — it stops a silent alias upgrade from quietly repricing every session your team runs.
Lever 2: turn the effort level down for routine work
Current models reason at an effort level — low, medium, high, xhigh, max — and effort is a cost setting, because thinking tokens are output tokens. Output is the expensive side of the bill: at API rates checked in November 2026, output costs five times input on every current model ($4/$20 per million tokens on Opus 5.5, $2/$10 on Sonnet 5.5, $0.10/$0.50 on Haiku 5.5).
Set a default in settings.json and override it per session:
{
"effortLevel": "medium"
}
Use /effort in a session, --effort at launch, or the CLAUDE_CODE_EFFORT_LEVEL environment variable, which overrides both. high is the standard default; medium is a reasonable working default for routine implementation, with xhigh reserved for the problems that genuinely need it.
Two details keep effort from backfiring. First, set it at the start of a task, not mid-stream: changing effort partway through a conversation can invalidate the prompt cache, and Claude Code may warn you before it applies the change — the cache you lose can cost more than the thinking you save. Second, effort is per-model common sense, not a global virtue. A low-effort pass on a hard problem produces a fast wrong answer and a second, full-price attempt; the saving only exists when the task was routine to begin with.
This is also where the outdated advice sits. Older guides tell you to set alwaysThinkingEnabled: false or MAX_THINKING_TOKENS=0. On the newest models those switches no longer turn thinking off — Anthropic’s model configuration documentation treats effort as the control now. If your settings file still carries the old keys, they are decoration, not savings.
Lever 3: put subagents on a cheaper model
Exploration is the worst work to run on your main model in your main context: a subagent that reads twenty files to answer one question produces a paragraph, but if it ran in your session, the twenty files came with it. Two settings fix this. Delegate exploration to subagents, and set their model separately:
{
"env": {
"CLAUDE_CODE_SUBAGENT_MODEL": "haiku"
}
}
Research, search and summarising side-work rarely needs the flagship, and it returns summaries instead of raw file dumps. The full economics of the split are in subagents vs one long session.
Lever 4: context hygiene is a settings problem
Every token in your context is re-sent as the conversation grows. Prompt caching discounts the repeated part — cache reads cost 0.05× the input rate on Opus 5.5 and Sonnet 5.5, 0.1× on Haiku 5.5 (checked November 2026) — but the cheapest context is still the context that never enters the session.
Keep CLAUDE.md short. It loads into every request, so a bloated project file is a tax on every message, forever. If a rule is not earning its place weekly, move it into a skill, which loads only when relevant, or delete it. The CLAUDE.md guide covers what earns a line.
Split CLAUDE.md by directory. Project memory is hierarchical: the root file loads at launch, while a CLAUDE.md inside a subdirectory loads on demand, when the agent reads files in that directory. That makes nested files a genuine cost setting, not just tidiness. Monorepo conventions that only matter inside packages/api belong in packages/api/CLAUDE.md, where they are paid for only on the sessions that work there — not in the root file, where every session pays for them.
Use deny rules, not an ignore file. There is no working .claudeignore in Claude Code — Anthropic’s permissions documentation states the file has no effect. The supported mechanism is a Read deny rule in settings, which also keeps generated output and vendored code out of the agent’s reading list:
{
"permissions": {
"deny": [
"Read(./dist/**)",
"Read(./node_modules/**)",
"Read(./.env)"
]
}
}
The full rule syntax — and the deny rules you should write for safety, not just cost — is covered in Claude Code permissions and sandboxing.
Treat compaction as a safety net, not a strategy. A session that compacts repeatedly has been carrying too much for too long, and the summaries are lossy in exactly the places later turns depend on. Run /context occasionally to see what the window actually holds; the number usually ends the argument about whether to clear.
Lever 5: /clear discipline
The most underused cost control in Claude Code costs nothing and needs no configuration: ending sessions. A long session accumulates not just tokens but stale tokens — the abandoned approach from an hour ago, the file you read and then changed twice. The agent weighs all of it, pays for all of it, and occasionally resurrects a dead plan from it.
The rule is simple: new task, new session — with /clear between unrelated tasks as a reflex, not a decision. The fear that stops people is losing context, but that fear is usually misplaced. The durable context lives in your CLAUDE.md, your skills, and the code itself. What lives only in the session is mostly the archaeology of the last task. If a follow-up genuinely needs the thread, keep the session; if it merely might, clear it and restate the two facts that matter. Restating two facts is nearly free. Carrying forty turns is not.
Lever 6: know which billing shape you are on
Whether you are on a subscription plan or API billing changes which waste matters. On a plan — Pro at $20 a month ($17 billed annually), Max at $100, Ultra at $200, prices checked November 2026 — your constraint is the five-hour and weekly usage windows, so the goal is throughput per window: lean context and good routing stretch the same allowance across more finished work. Note that the API credits bundled with Max and Ultra cannot be spent inside Claude Code, so they do not soften a heavy session.
On API billing, the constraint is literal money per token, and the same habits apply with the volume turned up — plus one extra: visibility. The /cost command shows what the current session has used; check it, learn your cost per typical task type, and let that knowledge, not vibes, set your defaults. Either way, decide consciously which shape fits your usage; the cost ladder walks through that comparison properly.
Settings and habits checklist
Apply these once, then review monthly. Settings go in ~/.claude/settings.json (user level) or .claude/settings.json (project level).
{
"model": "sonnet",
"effortLevel": "medium",
"env": {
"CLAUDE_CODE_SUBAGENT_MODEL": "haiku"
},
"permissions": {
"deny": ["Read(./dist/**)", "Read(./.env)"]
}
}
## Cost-control checklist
### Settings (once)
- [ ] Default model = workhorse (sonnet), not flagship
- [ ] Effort level set deliberately; old thinking on/off keys removed
- [ ] Subagent model set cheaper than the main model
- [ ] CLAUDE.md pruned: every line used in the last month?
- [ ] Read deny rules cover generated, vendored and secret files
### Per task (seconds)
- [ ] Ask: is this a think-task or a type-task? Pick model to match
- [ ] Big change? Start with opusplan instead of switching by hand
- [ ] Exploration needed? Delegate it to a subagent, keep the summary
### Per session (habits)
- [ ] /clear between unrelated tasks — no exceptions by default
- [ ] Restate 2 key facts after clearing instead of carrying history
- [ ] /context checked before the window gets unwieldy, not after
- [ ] End of day: glance at usage; note the most expensive session
and what made it expensive
Notice what is not on this checklist: no promised percentage, no “cut your bill in half.” The savings depend entirely on your starting habits — a disciplined user’s are small because there was little waste; a new user’s can be dramatic precisely because the waste was. What we can say, and stand behind, is narrower: these levers are where the money goes. Route the model, set the effort, starve the context, clear the session, and watch your own usage numbers for a month. Your bill will tell you the percentage — and it will be a real one.
Settings set the ceiling; habits decide how close to it you live. The other half of this system is the cost optimisation habits.
FAQ
What does /clear actually do to cost? It empties the conversation context, so the next request stops paying to re-send everything that came before. The trade is real — the agent loses the thread — which is why the habit is to clear at task boundaries, with a short written brief to restart from.
Which settings.json changes matter most?
The model default, the effort level, and the subagent model — in that order. Most other settings are comfort, not cost. This article’s checklist separates the two honestly.
Does a .claudeignore file keep big files out of Claude Code’s context?
No. Anthropic’s documentation says a .claudeignore file has no effect in Claude Code. To keep the agent from reading a path, add a Read deny rule for it in settings.json, as in Lever 4 above.
Does a bigger context window cost more? Only when it fills. The window is a ceiling, not a bill — but agents fill available space with file reads, so a lean working set is a discipline, not a setting.
Should I just switch everything to the cheapest model? No. A cheap model that takes three attempts costs more than a strong model that lands it once, and the rework lands on your time too. Route by task difficulty: flagship for thinking, workhorse for typing, lightest tier for exploration.
Should I set the model in every project’s settings file?
Only where the project genuinely differs. A user-level default covers most work; a project-level model is worth it when a repo’s work is consistently heavier or lighter than your norm — a legacy codebase that always needs the flagship, a docs site that never does. Every extra layer is another place for a stale setting to hide, so keep the stack shallow.
Learn more:
- The Claude Code cost ladder: plans vs API, rung by rung
- Claude Code permissions and sandboxing: the safety settings
- The context budget audit: find where your context goes
- Your first CLAUDE.md: the file that loads into every session
Category: Claude Code & Context Engineering · Tags: #claude-code #pricing #context-engineering #productivity
Next step: this article is part of Claude Code guides, which covers the full topic from first setup to advanced use.