AI Guides Includes our measurements

Claude Code Setup Guide: Context, Tokens, Testing & Better Workflows

Developer workstation representing a Claude Code software workflow

Most wasted Claude Code tokens come from three habits: a bloated project instruction file, sessions that run on long after the task changed, and asking the most expensive model to do routine work. Fix those three and you’ll feel the difference before you touch any advanced setting. One more thing from my check of Anthropic’s repository: Claude Code ships several versions a week, so treat any setup guide, including this one, as a starting point and check your version.

A personal note: I’ve only tried Claude Code a little. Most of my own Claude use is in the regular app, and I’ll admit I usually pick Opus there, which is exactly the habit this guide tells you to question. So read the tips below as what Anthropic’s documentation and other developers recommend, not as long experience of mine with the tool.

Updated 15 October 2026. The commands and settings below come from Anthropic’s official Claude Code documentation and its public GitHub repository; I haven’t run my own token measurements for this guide, and where I quote other writers’ numbers I name them. Disclosure: Claude Code is an Anthropic product, and Claude helped draft this article.

Developer workstation with a terminal open, used for Claude Code

The Seven-Point Setup

  1. Keep CLAUDE.md under about 200 lines; move specialised workflows into skills.
  2. /clear when you switch to unrelated work; /compact with focus instructions inside a long task.
  3. Sonnet for most coding, Opus for hard architecture and multi-step reasoning.
  4. Plan mode (Shift+Tab) before any non-trivial change.
  5. Disable MCP servers you aren’t using.
  6. Give Claude test commands and expected output so it can check its own work.
  7. Review important diffs, keep secrets out of reach, and pin the Claude Code version in shared environments.

1. A Lean Project Instruction File

A short CLAUDE.md at the project root should answer practical questions: what the repository does, which commands validate a change, where the business logic lives, and what must never be changed automatically. Anthropic’s cost documentation says the file is loaded at the start of every session, so detailed instructions for rare jobs, such as PR reviews or migrations, cost tokens even when you’re doing something else. Put those in skills, which load only when needed. A short “Compact instructions” section can tell Claude what to keep when it summarises, such as test output and code changes.

What we found: AGENTS.md is read by default

Method: on 15 October 2026 we cloned Anthropic’s public claude-code repository on GitHub and read its changelog and the source of the built-in mods. We did not run Claude Code for this check.

A built-in mod called agents-md loads a project’s AGENTS.md as instructions, in exactly the place CLAUDE.md would go, when the project has no CLAUDE.md. Options let you load both, only CLAUDE.md, or only managed instructions. So if your team also uses Codex or other agents that read AGENTS.md, one file can serve all of them. If a project has both files, the default reads only CLAUDE.md, so anything that lives only in AGENTS.md is ignored unless you change the option. Loading both works, but duplicated instructions cost tokens on every request.

2. Specific Tasks, Inspect First

“Improve the authentication system” invites wandering. “Find why expired sessions are accepted, add a regression test, and propose the smallest safe fix” doesn’t. Anthropic makes the same point: a narrow request means Claude reads fewer files. On unfamiliar code I’d use this loop:

  1. Inspect the relevant files and explain current behaviour.
  2. Propose a short plan in plan mode, for your approval.
  3. Make the smallest sensible change.
  4. Run focused tests, then the wider suite.
  5. Show and explain the diff.

Press Escape to stop a wrong turn; /rewind (or double Escape) restores the conversation and code to an earlier checkpoint.

3. Cutting Token Use

Token cost scales with context: everything in the conversation is re-sent with each request. Claude Code already uses prompt caching and automatic compaction, but these levers from the documentation still matter, in my order of importance:

LeverWhat to doWhy it helps
Clear between tasks/clear on a topic switch (/rename first if you’ll return)Stale context is re-sent with every message
Compact with focus/compact plus what to keepShrinks a long task without losing decisions
Right-size the modelSonnet for most coding, Opus for hard reasoning, Haiku for simple subagentsOpus costs more per token
Lower thinking effort/effort for simple tasksThinking tokens bill as output
Trim MCP servers/mcp to disable; /context to see what fills the windowLess overhead per request
Filter noisy outputA hook that passes only error lines from long test logsThousands of lines become a few
Delegate verbose workRun tests or log analysis in a subagentOnly a summary comes back

Two details are easy to miss: extended thinking can’t be switched off on the current Opus, Sonnet, Haiku and Fable models, only lowered; and agent teams use roughly seven times the tokens of a normal session when teammates run in plan mode, so keep them small and short.

Why long sessions get expensive

  • Long context: a one-line question late in a session still draws on everything before it.
  • Cache misses: the first message after a break longer than the cache lifetime reprocesses the full context. The documented lifetime is one hour on a subscription and five minutes on an API key or usage credits.
  • Background requests: scheduled tasks, subagents and compaction all send their own, and compacting a big context is itself a big request.

/usage shows token use; on Pro, Max, Team and Enterprise it breaks recent usage down by skills, subagents, plugins and MCP servers and flags long context or cache misses. For subscribers, the session dollar figure isn’t your bill; watch the plan usage bars.

4. Protect the Repository

Keep version control clean, review important diffs, and don’t give the agent secrets or production credentials unless the task truly needs them. Migrations, mass file changes, dependency upgrades and deploys deserve a human review. Since October, Claude Code mods can change permissions and tool calls, which makes these boundaries even more important.

5. Give It Something to Check Against

Standard commands for formatting, linting, unit tests, integration tests and builds give both people and agents a predictable feedback loop. Anthropic recommends supplying verification targets, such as test cases or expected output, and working incrementally: write one file, test it, continue. When a task goes wrong, give the missing information rather than a longer prompt.

6. Pin Your Version

From the same repository check: the official changelog gained 74 version entries in the 90 days to 15 October 2026, from 2.1.212 to 2.1.300, more than five a week. Settings and defaults in any guide go stale quickly. Check claude --version, skim the changelog before relying on a tip, and pin the version in CI and shared setups so everyone gets the same behaviour.

Common Mistakes

  • Treating passing tests as proof. They only cover what they were written to cover.
  • A bloated CLAUDE.md that costs tokens in sessions where it’s irrelevant.
  • Running everything on Opus. Anthropic says Sonnet handles most coding well for less.
  • One endless session: context grows, cache misses pile up, results get fuzzier.
  • Judging by diff size. Correct, understandable and tested beats small.

What Other Practitioners Report

Other writers’ published experiences, summarised in my own words. I haven’t repeated them.

  • Amit Kothari, a founder on the Max 20x plan, writes that his root CLAUDE.md of about 3,900 words would add roughly 150,000 tokens across a 30-message session, versus about 7,800 for a 200-word version. In a small Haiku test the same trivial command cost about $0.014 outside his project and about $0.069 inside it, roughly five times more. He advises compacting around 60% context use and warns that fast mode bills at a premium.
  • Samy Ben Sadok of GEO Toolbox, in his token-cost guide, cites a 2026 paper reporting that the same agentic coding task can vary up to 30 times in token use between runs, and concludes that context discipline pays off most.

FAQ

What’s the difference between /clear and /compact?

/clear resets the conversation for unrelated work; /compact summarises it so a long task can continue.

How big should CLAUDE.md be?

Anthropic suggests under about 200 lines, with situational instructions moved into skills.

Does Claude Code read AGENTS.md?

Yes, by default when there’s no CLAUDE.md, through the built-in agents-md mod.

Which model should I use for coding?

Sonnet for most work; Opus for complex architecture or multi-step reasoning. Switch with /model.

Does Claude Code cost extra on Pro or Max?

It’s included, but usage counts against your plan limits. On an API key it’s billed per token; Anthropic reports an average of about $13 per developer per active day across enterprise deployments.

How do I install it?

Follow Anthropic’s current installation docs for your OS; commands in older tutorials may be out of date.

Related: Claude Code vs Cursor · Claude Code mods explained · Claude vs ChatGPT for coding · AI tool pricing compared · A 30-day plan for Sonnet 5.5 · Claude Haiku 5.5

Sources (checked 12 to 15 October 2026)

Published October 1, 2026. Last updated October 15, 2026. How we work

3 comments

Leave a comment

Your email address will not be published. Required fields are marked *