Back to blog
Claude Code Token Management Skills

Using Claude Code
Masterfully

Token management, essential commands, and the Skills system — a comprehensive guide for an efficient AI developer workflow.

May 2026 · 12 min read · Mustafa Özcan
claude-code
❯ claude
Claude Code v2.1.4
 
❯ /context
System: 18.4K tokens
Skills: 2.1K tokens
History: 44.2K tokens
──────────────────────
Total: 64.7K / 200K
 
❯ /compact
✓ Context compressed.
Saved ~38K tokens.
 
❯ /summarize-changes
Loading Skill...
§ 00 — Introduction

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

⚠ Important

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.

200K
Maximum token
context window
70%
Token savings
with Skill optimization
98%
Token savings
from unused skills

§ 01 — Token Management

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.

terminal
# 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.

💡 Pro Tip

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

01
Auth
Task
completed
→
02
/clear
reset context
→
03
UI
Task
clean start
→
04
/compact
when 70% full
→
05
Continue
compressed

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.

📋 Rule

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.

claude code — command line
# ❌ 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)

§ 02 — Commands

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:

/context
Shows token distribution: system prompt, tools, CLAUDE.md, skills, and conversation history. Run at the start of each session.
Monitoring
/compact
Compresses conversation history by summarizing it. Critical decisions are not deleted, but granular details are lost. Use at 70% fullness.
Critical
/clear
Deletes all conversation history, opens a clean slate. Use when transitioning to a different task.
Critical
/cost
Shows the cumulative token count spent during the session and API cost.
Monitoring
/compact
Automatic compression is triggered at 95% fullness. Using it manually provides better control.
Useful
/debug
Built-in debugging skill. Instructs Claude to debug step-by-step. (Bundled Skill)
Useful
/batch
Batches multiple files or tasks. Much more efficient than running them individually.
Useful
/simplify
Simplifies selected code. Ideal for readability and ease of maintenance.
Useful
/claude-api
Claude API usage examples and integration assistant. Useful for SDK questions.
API
🗂 /clear vs /compact Difference

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


§ 03 — Skills System

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.

🏗 Progressive Disclosure Architecture

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:

🐛
/debug
Debugging guide
Guides Claude through the debugging process step-by-step. Contains instructions optimized for in-system debugging.
🔄
/batch
Batch processing orchestration
Processes multiple files or tasks at once. Dramatically speeds up repetitive tasks.
✂️
/simplify
Code simplification
Makes complex code more readable and easier to maintain. For readability-focused refactoring.
🔁
/loop
Loop-based task execution
Repeatedly runs a task until a specific condition is met. Ideal for automation scenarios.

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:

Slash
Command
Single markdown file (.claude/commands/deploy.md). Ideal for simple, direct instructions. Less flexibility.
Skill
Folder structure (.claude/skills/deploy/SKILL.md). Supports auxiliary files, YAML frontmatter, automatic loading, and dynamic context injection.
Open
Standard
Thanks to the Agent Skills standard (agentskills.io), you can use your skills outside of Claude Code as well: Cursor, Gemini CLI, VS Code, and more.

§ 04 — Creating Skills

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:

📁 ~/.claude/skills/summarize-changes/SKILL.md
--- description: Summarizes uncommitted changes and flags risky situations. # autoInvoke: true --- ## Current Changes !`git diff HEAD` ## Instructions Summarize changes in 2-3 points. List risks such as missing error handling, hardcoded values, or tests that need updating.
YAML frontmatter
Determines when Claude loads the skill. The description field is critical for automatic loading.
!`command` syntax
Dynamic context injection. The command runs before Claude reads the file, and its output is placed inside the skill.
Instructions section
Step-by-step instructions for Claude to follow when the skill is run.
Persistence
Once a skill is loaded, it remains active throughout the session. It is also preserved after compaction (within the 5,000 token limit).

Skill Loading and Compaction Rules

It is important to understand how skills behave after compaction:

📦 Compaction Token Budget

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

terminal — skill usage
# 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

§ 05 — Summary

Golden Rules

The following habits will radically change your Claude Code experience:

Tier 1
Immediate
Start with /context — Learn how many tokens each component consumes at the beginning of each session. Use /clear on task transitions. Target files with @, don't let Claude search. These three habits alone save 30-40%.
Tier 2
Process
Run /compact at 70% fullness. Tell Claude which decisions to preserve before compaction. Simplify CLAUDE.md — keep it under 120 lines. Shut down MCP servers after use.
Tier 3
Long Term
Write your own skills: Running the same workflow manually twice costs double the tokens. Write once, use repeatedly. Use Git commits as checkpoint points — this makes /clear safe.
🎯 One-Sentence Summary

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.