strategic-compact

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

Updated Jul 22, 2026
One-click install
npx skills add https://github.com/Chau165/local_skill --skill strategic-compact-chau165
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: strategic-compact
Source: https://github.com/Chau165/local_skill/tree/main/plugins/ecc/skills/strategic-compact
Command: npx skills add https://github.com/Chau165/local_skill --skill strategic-compact-chau165

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Long AI coding sessions lose important context when auto-compaction fires at arbitrary points mid-task, discarding variable names, file paths, and partial reasoning needed to finish the work. ## Core Features & Use Cases - Context-size monitoring: Reads token usage from the session transcript and suggests /compact at window-scaled thresholds (160k on a 200k window, 250k on a 1M window), re-reminding every 60k tokens of growth. - Tool-call counting: Tracks tool invocations per session and suggests compaction at a configurable threshold (default 50 calls, then every 25). - Phase-aware guidance: Provides a decision table for compacting at logical boundaries such as research-to-planning or after a failed approach, plus a reference of what survives compaction. - Use Case: During a multi-phase feature build, the PreToolUse hook detects context crossing 160k tokens after the research phase and reminds you to run /compact before implementation, preserving the plan while clearing bulky exploration context. ## Quick Start Install the suggest-compact.js hook for Edit and Write tool calls in your settings.json and let it remind you 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 boundaries such as after research or planning, rather than waiting for auto-compaction. The suggest-compact.js hook monitors token usage and tool calls, reminding you when context crosses configurable thresholds.

How do I set up the strategic compact hook in settings.json?

Add a PreToolUse hook entry in ~/.claude/settings.json with matchers for Edit and Write, each running node on the suggest-compact.js script. The hook then evaluates context size and tool-call count before those tools execute.

What survives after running /compact in a session?

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

Can I configure the context compaction threshold?

Yes, set environment variables to tune behavior: COMPACT_THRESHOLD for tool calls (default 50), COMPACT_CONTEXT_THRESHOLD for tokens (default 160000 on a 200k window), COMPACT_CONTEXT_INTERVAL for repeat reminders, and COMPACT_STATE_TTL_DAYS for state cleanup.

When should I avoid compacting context mid-task?

Avoid compacting mid-implementation, because losing variable names, file paths, and partial state is costly to recover. Compact after completing milestones, after debugging sessions, or after a failed approach before trying a new one.