strategic-compact
Suggest context compaction at optimal logical boundaries — between phases, after a research burst, after a debugging session ends — rather than waiting for…
от mhylle★ 20 звёзд на GitHub
Установить strategic-compact в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Strategic Compact
Contents
- Why strategic > automatic
- When to use
- The core heuristic
- Threshold
- Preserve before compact
- Suggestion format
- Integration with other skills
- Core principles (keep these in mind)
- References (loaded on demand)
Reference files (open one when a step points to it):
references/boundary-rules.md: Boundary rules — when to suggest, when not toreferences/hook-setup.md: Hook setup and configuration
Suggest context compaction at logical boundaries — not arbitrary token thresholds. Auto-compaction is a safety net; strategic compaction is a workflow optimization that makes compaction feel like a natural pause instead of an interruption.
Why strategic > automatic
Auto-compaction fires on simple thresholds (token count, time). That creates real problems:
- Mid-task disruption — auto-compact might fire while you're debugging, losing the mental model built up over many interactions.
- Context fragmentation — arbitrary cutoffs create artificial boundaries in session history.
- Lost continuity — "why" decisions get compacted away at random points rather than preserved at meaningful boundaries.
- Incomplete state — mid-implementation compaction can lose partially completed work.
Strategic compaction instead:
- Monitors for logical boundaries (task completion, phase transitions, successful commits).
- Considers semantic state (actively debugging vs. between tasks).
- Provides suggestions — never forces compaction.
- Integrates with
context-saverto preserve critical state first. - Respects workflow rhythm rather than imposing arbitrary limits.
Goal: compaction that feels like a natural pause, not an interruption.
When to use
Passive monitoring — via PreToolUse hook that attaches to every tool call, tracks counters, and evaluates boundaries. Hook setup → references/hook-setup.md.
Direct invocation:
/strategic-compact— check current session state and get a recommendation./strategic-compact status— view tool counts and threshold proximity./strategic-compact now— force a suggestion (auto-invokes context-saver first).
Trigger phrases: "should I compact", "when should I clear context", "getting long", "checkpoint", "context is getting big".
The core heuristic
Two questions:
- Has enough work happened that compaction is worthwhile? (weighted tool-call count vs. threshold)
- Is this moment a good place to compact? (logical boundary vs. mid-task)
Both must be yes before suggesting. The full rule set is in references/boundary-rules.md. Summary:
Suggest when…
| Signal strength | Trigger |
|---|---|
| Strong | Task completion (TaskUpdate → completed), + ≥60% threshold, + >10min since last suggestion |
| Strong | Successful git commit, + ≥70% threshold, + no pending tasks in this feature |
| Medium | New feature starting (TaskUpdate → in_progress after completing previous), + ≥50% threshold |
| Warning (high priority) | Estimated context usage >80% + ≥90% threshold — prevent forced auto-compaction mid-task |
Don't suggest when…
- Active debugging — recent errors, investigation-pattern tool sequence, or task name contains "debug/fix/investigate".
- Active implementation — uncommitted changes, recent edits, unresolved test failures.
- User recently deferred — respect the last "not now".
- Critical operation in progress — rollback, migration, destructive commands.
- Last suggestion was <10 min ago — avoid nagging.
Threshold
Default: 50 weighted tool calls between logical boundaries.
"Significant" means the weighted count — raw tool calls multiplied by the weight table below. A tool call with weight 1.0 contributes 1 significant call; a Read with weight 0.5 contributes 0.5. Weights:
- Edit / Write / Bash / NotebookEdit / TaskUpdate — weight 1.0 (state-modifying or complex)
- Read — 0.5 (inspection, lower cognitive load)
- Glob / Grep — 0.3 (searches, low cost)
- WebFetch / WebSearch — 0.5 (external lookups)
Scenario-tuned thresholds (standard dev 50, debugging 75, quick fixes 30, large refactor 40, docs 60). Full config + dynamic adjustment rules → references/hook-setup.md.
Preserve before compact
When a suggestion is accepted, auto-invoke context-saver before compaction (via integrate_context_saver: true in hook config — default). This produces a handoff doc capturing:
- What was being worked on
- Files mid-edit with line numbers
- Decisions made
- Next steps
T
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
- 01
Read - 02
Bash
Вложенные файлы
- references/boundary-rules.md
- references/hook-setup.md
FAQ
Что делает скилл strategic-compact?
Suggest context compaction at optimal logical boundaries — between phases, after a research burst, after a debugging session ends — rather than waiting for the automatic compaction threshold to hit mid-task. Use when the user asks whether to compact, mentions context is getting long, wants to checkpoint before a big task, or when you notice the session is approaching a natural transition where compacting would preserve the next phase's context. Complements (doesn't replace) Claude Code's built-in auto-compaction. Triggers on "/strategic-compact", "should I compact", "when should I clear context", "getting long", or proactively at phase boundaries and session transitions.
Как установить скилл strategic-compact?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл strategic-compact запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis 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…