Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Cutting Claude Code token usage, the parts that actually matter

Description and use

Token usage in Claude Code is optimized by limiting always‑loaded content, disabling unused MCP servers, clearing history, and using PreToolUse hooks to block unnecessary file reads.

Problem

Claude Code sessions resend all context, causing high token usage for files and commands that are rarely needed.

Outcome

Token usage is reduced by preventing large, unnecessary reads and outputs while maintaining essential functionality.

Workflow

  • Run /context to view current context size
  • Keep CLAUDE.md under 200 lines and move workflow‑specific instructions to skills
  • Disable unused MCP servers with /mcp
  • Use /clear between unrelated tasks or /compact to keep only needed parts
  • Implement a PreToolUse hook to deny full reads of lockfiles, minified files, source maps, node_modules, .venv, .next, coverage, binaries, and allow targeted reads with offset/limit or grep
  • Use quiet reporters and single‑test commands to reduce Bash output
  • Place exact commands in CLAUDE.md for reliable execution

Evidence

Every message you send in a Claude Code session re-sends what's already in context: the system prompt, your CLAUDE.md, MCP server instructions, and every file and command output from earlier in the session.

Source

A PreToolUse hook runs before every tool call and can deny it with a reason the model reads.

Source

I published this as token-diet-lite: one stdlib Python file, MIT.

Source

  • Record date: 2026-10-25T21:11:10.412Z