cc-context-budgeting
БесплатноБез исполняемых скриптовНе проверенManage Claude Code's context window — token arithmetic, /compact strategy, anchor preservation, progressive loading, session analytics. Use this skill…
от TheLobbi★ 22 звезды на GitHubОб этом скилле
Context Budgeting
Every token in context is a cost you pay every turn. This skill is the discipline that keeps long sessions cheap and coherent.
Token arithmetic
Rough budget on a 200K-context model:
| Consumer | Typical | Budget |
|---|---|---|
| System prompt + CLAUDE.md | 3–8 K | ≤ 10 K |
| Skills frontmatter (all active) | 2–6 K | ≤ 8 K |
| MCP tool schemas (passive) | 5–25 K | ≤ 15 K |
| Hook definitions | <1 K | <1 K |
| Conversation history | variable | ~120 K |
| Working headroom | — | ≥ 20 K |
If passive context (everything before conversation history) exceeds 30 K, optimize.
Three-tier loading (skill-creator canonical)
| Tier | What | Size | Loaded |
|---|---|---|---|
| 1 — Frontmatter | name + description |
~50 tokens | always |
| 2 — Body | SKILL.md after frontmatter |
≤ 500 lines | on activation |
| 3 — References | references/*.md, MCP KB artifacts |
unlimited | on demand |
Rule: if content doesn't change Claude's behavior every session, it belongs in tier 3.
/compact strategy
/compact condenses conversation history when it's filling up. It does NOT touch system prompt, CLAUDE.md, or skills.
When to /compact:
- Conversation > 60 K tokens.
- About to start a new phase (logical break).
- Many long tool outputs in history.
When NOT to /compact:
- Mid-debugging where specific earlier context matters.
- Right before an important decision — the lost nuance might bite.
- After a fresh
/clear(nothing to compact).
Anchor preservation: before /compact, save anything you'd lose to engram via mem_save. After compact, the post-compact-context-restoration hook re-loads memory rules and recent context.
/clear vs /compact
| Command | What it does |
|---|---|
/compact |
Summarize history, keep system prompt + CLAUDE.md |
/clear |
Wipe everything including CLAUDE.md — fresh session |
Use /clear between unrelated tasks. Use /compact mid-task.
Subagent delegation for context pressure
When a single subtask would consume too much context (e.g. scanning a huge codebase), delegate to a subagent. The agent gets a fresh window; you only see its report.
Agent({
description: "Inventory all API endpoints",
prompt: "Scan src/api/ recursively, list every route with method, auth requirement, and response schema. Report under 500 words."
})
Net: the scan consumes agent tokens; your session only pays for the 500-word summary.
Session analytics
Track cost patterns:
| Metric | Target |
|---|---|
| Passive context (pre-conversation) | ≤ 30 K |
| Cost per turn | ≤ $0.05 (Sonnet), ≤ $0.15 (Opus) |
| Tools loaded but never called per session | 0 (prune unused MCPs) |
| /compact frequency | every 20–30 exchanges on long sessions |
| Subagent delegation rate | ~1 per 5 substantive turns |
Session analytics isn't automatic — periodically review what's consuming tokens and trim.
MCP delegation
| Need | Tool |
|---|---|
| Settings schema for compact config | cc_docs_settings_schema |
| Compact/budget troubleshooting | cc_docs_troubleshoot("context") |
| Model cost for budgeting | cc_docs_model_recommend(task, budget) |
Anti-patterns
- Loading every skill body "just in case" → tier-2 explosion.
- Massive CLAUDE.md with all conventions inline → routing fails + budget bloat.
- Never compacting → session hits wall, Claude forgets the plan.
- Compacting mid-critical-reasoning → loses the thread.
- Global MCPs for project-specific work → 15 K tokens for tools you never call.
Reference
- compact-strategies.md — when to compact, anchor checklist, post-compact recovery
Установить cc-context-budgeting в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл cc-context-budgeting?
Manage Claude Code's context window — token arithmetic, /compact strategy, anchor preservation, progressive loading, session analytics. Use this skill whenever a session gets long, context approaches limits, after /compact, when deciding what to load into CLAUDE.md vs leave in references, or when analyzing session cost/token usage. Triggers on: "context full", "compact", "too many tokens", "budget", "session analytics", "save tokens", "context window", "/compact strategy".
Как установить скилл cc-context-budgeting?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cc-context-budgeting запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic