strategic-compact

Suggests manual context compaction at logical task boundaries using token and tool-call thresholds.

Updated Sep 3, 2026
One-click install
npx skills add https://github.com/CMiller838/meal-planner --skill strategic-compact-cmiller838
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: strategic-compact
Source: https://github.com/CMiller838/meal-planner/tree/main/.claude/skills/strategic-compact
Command: npx skills add https://github.com/CMiller838/meal-planner --skill strategic-compact-cmiller838

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Long Claude Code sessions hit context limits at arbitrary moments, and auto-compaction often fires mid-task, discarding reasoning, file paths, and partial state that the next steps depend on. This Skill replaces arbitrary auto-compaction with timed suggestions at natural phase transitions. ## Core Features & Use Cases - Context-size monitoring: A PreToolUse hook reads the session transcript's usage records and sums input, cache-read, and cache-creation tokens to measure true context size, suggesting /compact at window-scaled thresholds (160k on a 200k window, 250k on a 1M window). - Tool-call fallback signal: Counts tool invocations per session and suggests compaction at a configurable threshold (default 50 calls, then every 25). - Phase-transition guidance: Provides a decision table for when to compact (research to planning, after debugging, after failed approaches) and what survives compaction (CLAUDE.md, TodoWrite, memory files, git state). - Use Case: During a multi-phase feature build, after finishing research and writing the plan to TodoWrite, the hook detects 165k tokens of context and suggests running /compact before implementation, so coding starts with a fresh window. ## Quick Start Ask the assistant to monitor this session's context usage and suggest when to run /compact at logical task boundaries.

Frequently Asked Questions about strategic-compact

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I compact context in Claude Code at the right time?

Run /compact manually at logical phase transitions such as after research, after planning, or after debugging, rather than waiting for auto-compaction. The suggest-compact hook monitors token usage and reminds you when context crosses configurable thresholds.

What survives context compaction in Claude Code?

CLAUDE.md instructions, the TodoWrite task list, memory files, git state, and files on disk all persist through compaction. Intermediate reasoning, previously read file contents, conversation context, and tool call history are lost.

How does the suggest-compact hook measure context usage?

It reads the latest usage record from the session transcript and sums input_tokens, cache_read_input_tokens, and cache_creation_input_tokens for the true context size. It suggests compaction at 160k tokens on a 200k window or 250k on a 1M window.

Can I configure the compaction threshold for large context windows?

Yes, set ECC_CONTEXT_WINDOW_TOKENS to your model's window size so thresholds scale correctly, or tune COMPACT_CONTEXT_THRESHOLD and COMPACT_CONTEXT_INTERVAL directly. The window is otherwise auto-detected from a [1m] model marker.

When should I not compact a Claude Code session?

Avoid compacting mid-implementation, because losing variable names, file paths, and partial state is costly to recover. Write important context to files or memory first if compaction is unavoidable.