context-budgeting
БесплатноБез исполняемых скриптовНе проверенAdvanced context window management — token arithmetic, anchor budget math, compact strategies, progressive loading, and large codebase partitioning
от TheLobbi★ 22 звезды на GitHubОб этом скилле
Context Budget Mastery
Master the art of managing Claude Code's context window for maximum productivity.
Goal
Help users understand exactly where context is consumed, plan sessions that avoid hitting limits, and recover gracefully when context gets tight.
Context Window Sizes
| Model | Context Window | Practical Limit |
|---|---|---|
| Opus 4.6 | 200,000 tokens | ~180,000 usable |
| Sonnet 4.6 | 200,000 tokens | ~180,000 usable |
| Haiku 4.5 | 200,000 tokens | ~180,000 usable |
The ~20k overhead comes from system prompt, tool definitions, and framework messages that are always present.
Token Arithmetic
What consumes context
Every request to Claude includes ALL of the following:
| Component | Loaded When | Typical Size | Cached? |
|---|---|---|---|
| System prompt | Every turn | 3-5k tokens | Yes (after turn 1) |
| CLAUDE.md (all levels) | Every turn | 2-20k tokens | Yes (after turn 1) |
| Rules (unconditional) | Every turn | 1-10k tokens | Yes (after turn 1) |
| Rules (path-scoped) | When matching files opened | 0-5k tokens | Partially |
| Skill descriptions | Every turn | 1-5k tokens | Yes |
| MCP tool schemas | Every turn | 2-15k tokens | Yes |
| Conversation history | Every turn (grows) | 5-150k tokens | Partially |
| Tool results (latest) | Current turn | 0-10k tokens | No |
The growth problem
Context grows with every turn because conversation history accumulates:
- Turn 1: ~30k (system + CLAUDE.md + rules + skills + MCP + message)
- Turn 5: ~50k (+ 4 turns of Q&A and tool calls)
- Turn 15: ~100k (+ tool outputs, file reads)
- Turn 30: ~180k (approaching limit — auto-compact triggers)
Fixed vs. variable budget
Fixed overhead (always loaded):
System prompt ≈ 4,000 tokens
CLAUDE.md files ≈ 5,000 tokens (varies)
Unconditional rules ≈ 3,000 tokens (varies)
Skill descriptions ≈ 2,000 tokens (varies)
MCP tool schemas ≈ 5,000 tokens (varies)
─────────────────────────────────────────────────
Total fixed overhead ≈ 19,000 tokens
Variable (grows with session):
Conversation history = grows per turn
Tool results = per tool call
Loaded skill bodies = when skills activated
Path-scoped rules = when matching files read
Your effective working budget = 200,000 - fixed overhead - safety margin
Anchor Budget Math
What are anchors?
Anchors are pieces of context you want to survive /compact. Without anchoring, compaction summarizes everything, potentially losing critical state.
Calculating anchor budget
Rule of thumb: anchors should consume < 10% of your context window.
Context window: 200,000 tokens
Target anchor budget: 20,000 tokens (10%)
Available for conversation: 180,000 - fixed overhead
What to anchor
Priority anchoring targets:
- Current task definition and constraints
- Key decisions made during the session
- File paths and line numbers of changes in progress
- Error messages being investigated
- Architecture notes discovered during exploration
What NOT to anchor
- File contents (can be re-read)
- Full conversation history (that's what compact summarizes)
- Tool output (can be regenerated)
- Generic instructions (already in CLAUDE.md)
Compact Strategies
When to compact
| Signal | Action |
|---|---|
| Auto-compact triggers (system message) | Let it happen, but consider manual compact first |
| Context utilization > 70% | Good time for proactive compact |
| Shifting to a new sub-task | Compact to clear old context |
| After a long research phase | Compact before implementation |
| After reading many files | Compact to summarize findings |
Focus strings
When compacting, provide a focus to guide summarization:
/compact Focus on the auth middleware refactor: keep the API contract, test failures, and migration plan
Good focus strings:
- Name the specific task
- List what must survive
- Mention key file paths
Bad focus strings:
- Empty (default summarization may miss important details)
- Too broad ("keep everything important")
- Too narrow ("only keep line 42 of auth.ts")
What survives compact automatically
- CLAUDE.md content (re-read from disk)
- Rules files (re-read from disk)
- Skill descriptions (re-injected)
- MCP tool schemas (re-injected)
- Auto-memory notes (persisted to disk)
What does NOT survive compact
- Conversation details (summarized, not preserved verbatim)
- Tool outputs (lost unless anchored)
- In-progress reasoning (summarized)
- File contents you read (must re-read)
Progressive Loading
The 82% savings pattern
Skills use progressive loading:
- At startup: only frontmatter (name, description, triggers) loaded — ~50 tokens per skill
- When activated: full skill body loaded — ~500-2000 tokens per skill
With 30 skills:
- All loaded: 30 × 1000 = 30,000 tokens
- Progressive: 30 ×
Установить context-budgeting в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobBashFAQ
Что делает скилл context-budgeting?
Advanced context window management — token arithmetic, anchor budget math, compact strategies, progressive loading, and large codebase partitioning
Как установить скилл context-budgeting?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл context-budgeting запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic