Why is Token Management Important?
Claude Code is an AI coding tool that runs through the terminal. It reads your files, executes commands, debugs, and interacts directly with your codebase. However, all this power has a limit: the context window.
Every message you send, every response received, every file read, and the output of every command executed is added to this window. As the 200,000 token limit fills up, quality decreases, responses slow down, and previously made decisions are forgotten. This situation is called "context rot".
Filling the context window is not just a cost issue, but a quality issue. When you use your tokens efficiently, Claude works much more accurately and focused.
context window
with Skill optimization
from unused skills
Keeping the Context Clean
Token efficiency is not about having expensive resources, but about using the resources we have correctly. Here are the fundamental principles for keeping token consumption under control:
1. Measure Every Input
Before optimizing, you need to know how many tokens each component consumes. The /context command shows exactly this.
# Display token distribution /context # Example output: System prompt: 18.400 tokens (9%) Tool definitions: 14.200 tokens (7%) CLAUDE.md files: 4.800 tokens (2%) Skills: 2.100 tokens (1%) Conversation: 44.200 tokens (22%) ────────────────────────────────────────── Total: 83.700 / 200.000 tokens # Cumulative cost report /cost
2. Compress the Conversation with /compact
After completing a large task, run the /compact command before moving on to the next one. This reduces the conversation history to a summary and preserves important decisions in the context.
Before running /compact, tell Claude what to preserve: "Before compacting, note the optimistic locking decision and the decision not to make schema changes."
3. Use /clear on Task Transitions
The /clear command deletes the entire conversation history and opens a clean slate. Use it when transitioning to a different task (e.g., from auth coding to CSS styling).
Task
Task
4. Simplify the CLAUDE.md File
The CLAUDE.md file is automatically loaded at the beginning of each session and added to the context with every message. An inflated CLAUDE.md steals tokens in every turn. Keep only truly essential information.
If the folder name is already components/, don't write "this folder contains components". Claude already knows this. Add only information that Claude cannot infer to CLAUDE.md.
5. Target Files with @ References
Instead of letting Claude explore the code, directly reference the file. This can save 30-40% tokens.
# ❌ Inefficient: Claude searches for code "find the bug in the auth code" # ✅ Efficient: Direct targeting "fix the refresh token bug in @src/api/auth.js" # Disable MCP servers when not needed # Linear MCP: consumes ~14K tokens (7% context)
Essential Slash Commands
New monitoring commands have been added with Claude Code v1.0.86. Below is a list of commands grouped by usage frequency and importance level:
/clear — The nuclear option. Deletes all history, starts from scratch. Use when switching to different topics.
/compact — Intelligent compression. Summarizes history, preserves important decisions. Use to narrow down the context within the same task.
Skills: Reusable AI Workflows
Skills are one of the most powerful features of Claude Code. A skill is a SKILL.md file containing detailed instructions that Claude must follow for a specific task.
The architecture of Skills is built on the principle of progressive disclosure: Only the YAML frontmatter (name + description) is loaded in each session. The rest of the content is not added to the context until you call the skill.
When 10 skills are installed, only ~1,000 tokens are consumed — if all were loaded upfront, you would spend 50,000+ tokens. This means unused skills provide 98% token savings.
Built-in (Bundled) Skills
Claude Code comes with built-in skills ready for use in every session:
Skill vs Slash Command Difference
With Claude Code 2.1, skills and slash commands have been largely unified. Both are called with the /skill-name syntax. The fundamental difference is:
Command
.claude/commands/deploy.md). Ideal for simple, direct instructions. Less flexibility..claude/skills/deploy/SKILL.md). Supports auxiliary files, YAML frontmatter, automatic loading, and dynamic context injection.Standard
Write Your Own Skill
Personal skills are saved in the ~/.claude/skills/ folder, while project-based skills are saved in the .claude/skills/ folder. Each skill consists of two parts:
description field is critical for automatic loading.Skill Loading and Compaction Rules
It is important to understand how skills behave after compaction:
After compaction, each skill is re-added with a maximum of 5,000 tokens. The shared budget for all skills is 25,000 tokens. The budget is filled starting from the most recently called skill — if there are too many skills, older skills may be dropped entirely.
Calling Skills
# Manual call /summarize-changes # Or with natural language (automatic if autoInvoke: true) "look at my latest changes and suggest a commit message" # Display personal skill list /help # Remove a skill (project-based) rm -rf .claude/skills/skill-adi
Golden Rules
The following habits will radically change your Claude Code experience:
Immediate
Process
Long Term
Those who get the best results in Claude Code are not those with the largest context window — they are those who keep that window the cleanest.