strategic-compact

Suggests manual context compaction at logical task boundaries using a PreToolUse hook counter.

1|Updated Oct 11, 2025
One-click install
npx skills add https://github.com/ibytechaos/claude --skill strategic-compact-ibytechaos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: strategic-compact
Source: https://github.com/ibytechaos/claude/tree/main/plugins/everything-claude-code/skills/strategic-compact
Command: npx skills add https://github.com/ibytechaos/claude --skill strategic-compact-ibytechaos

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Auto-compaction in Claude Code triggers at arbitrary points, often mid-task, losing important context like variable names, file paths, and partial state. This Skill helps you compact at logical phase transitions instead, preserving the context that matters. ## Core Features & Use Cases - Threshold-Based Suggestions: A PreToolUse hook counts Edit/Write tool calls and suggests running /compact after a configurable threshold (default 50 calls), with reminders every 25 calls afterward. - Compaction Decision Guide: Provides a phase-transition table (research → planning → implementation → testing) indicating when compacting is safe versus costly. - Context Survival Reference: Documents what persists across compaction (CLAUDE.md, TodoWrite tasks, memory files, git state) versus what is lost (conversation history, file contents read). - Use Case: During a long multi-phase session, after finalizing your implementation plan in TodoWrite, the hook reminds you to compact research context so you start implementation with a fresh, focused context window. ## Quick Start Add the suggest-compact hook to your Claude Code settings.json for Edit and Write matchers, then follow its suggestions to run /compact at logical phase boundaries.

Frequently Asked Questions about strategic-compact

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

FAQPage Schema
How do I set up strategic compaction suggestions in Claude Code?

Add a PreToolUse hook in ~/.claude/settings.json matching Edit and Write tools, pointing to the suggest-compact script. The hook counts tool calls per session and prints a suggestion to stderr when the threshold is reached.

When should I run /compact during a long coding session?

Compact at phase transitions: after research before planning, after finalizing a plan in TodoWrite, and after debugging before starting new work. Avoid compacting mid-implementation, since you lose variable names, file paths, and partial state.

What context survives after running /compact in Claude Code?

CLAUDE.md instructions, the TodoWrite task list, memory files under ~/.claude/memory/, git state, and files on disk all persist. Conversation history, previously read file contents, and tool call history are lost.

How do I change the tool call threshold for compact suggestions?

Set the COMPACT_THRESHOLD environment variable before the session; the default is 50 tool calls. After the threshold, the hook reminds you every 25 additional calls.

Why is manual compaction better than auto-compaction?

Auto-compaction triggers at arbitrary points with no awareness of task boundaries, often interrupting multi-step operations. Manual compaction at logical milestones keeps the distilled output of each phase while discarding bulky intermediate context.