Skip to content
Vibecoding Guide

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.

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).

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.

✗ No execution constraints

Claude scans the whole codebase before answering. Every request pays for files you didn't need.

40+ Files read
Targeted
50k Tokens
✓ With execution constraints

Claude reads only the files you named. Context stays tight, output stays focused.

2–3 Files read
Targeted
3k Tokens
⚡ Why this works: Explicit file scope collapses Claude's search space. With nothing to scan, it reads exactly what matters and produces focused, faster output.

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.

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.

Terminal window
/clear

Clears the conversation and resets context. Use it between unrelated tasks.

When a session has been running a while and context is getting large:

Terminal window
/compact

This summarises the conversation history into a shorter representation, reducing token usage without losing the thread of what you’re working on.

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
*.log
coverage/

Files listed here won’t be read even if Claude tries to scan them.

  • 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