Token Control
Every file Claude reads consumes tokens. On a large codebase, an unconstrained Claude will read dozens of files before answering a simple question — slowing responses, increasing cost, and often producing worse results because the context is too noisy.
Token control is about giving Claude exactly what it needs, and nothing more.
The core principle
Section titled “The core principle”You decide what Claude reads. By default, Claude will scan your project to build context. You can override this at two levels: in your CLAUDE.md (always applies) and in individual prompts (applies to that request).
In CLAUDE.md: execution constraints
Section titled “In CLAUDE.md: execution constraints”Add a constraints section to your CLAUDE.md that limits how Claude reads your project:
## Execution Constraints
- Read ONLY files explicitly named in the prompt, plus their direct imports.- Do NOT use Glob or Grep to scan the project unless the task is about project structure.- If a task requires reading more than 3 unspecified files, state what you need and why first.These run every session automatically — you don’t have to repeat them in prompts.
Claude scans the whole codebase before answering. Every request pays for files you didn't need.
Claude reads only the files you named. Context stays tight, output stays focused.
In prompts: be explicit
Section titled “In prompts: be explicit”Name the exact file and scope in your prompt:
Look at src/auth/login.js lines 40–80. Fix the token validation logic only.Compare this to a vague prompt that invites broad scanning:
Fix the login bug.The first gives Claude a precise target. The second triggers a search across the codebase.
/clear between tasks
Section titled “/clear between tasks”When you switch from one task to another, Claude carries the full context of everything it read during the previous task. This bloats the context window and can cause Claude to conflate the two tasks.
/clearClears the conversation and resets context. Use it between unrelated tasks.
/compact when context grows long
Section titled “/compact when context grows long”When a session has been running a while and context is getting large:
/compactThis summarises the conversation history into a shorter representation, reducing token usage without losing the thread of what you’re working on.
.claudeignore
Section titled “.claudeignore”You can create a .claudeignore file at your project root to tell Claude which files and directories to skip entirely — similar to .gitignore.
node_modules/dist/.env*.logcoverage/Files listed here won’t be read even if Claude tries to scan them.
What this buys you
Section titled “What this buys you”- Faster responses — less reading means faster answers
- Better answers — focused context produces more accurate output
- Lower cost — fewer tokens consumed per request
- Predictability — you know what Claude is working with