strategic-compact

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

Updated Mar 25, 2026
One-click install
npx skills add https://github.com/Femad-6/my-skills --skill strategic-compact-femad-6
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: strategic-compact
Source: https://github.com/Femad-6/my-skills/tree/main/.github/skills/strategic-compact
Command: npx skills add https://github.com/Femad-6/my-skills --skill strategic-compact-femad-6

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Long AI coding sessions lose important context when auto-compaction triggers at arbitrary mid-task points, discarding variable names, file paths, and partial reasoning at the worst possible moment. ## 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. - Phase-Aware Compaction Guidance: Provides a decision table for when to compact (research to planning, after debugging, after milestones) and when not to (mid-implementation). - Context Survival Reference: Documents what persists through compaction (CLAUDE.md, TodoWrite tasks, memory files, git state) versus what is lost (conversation context, tool history). - Use Case: During a long multi-phase feature build, the hook reminds you to compact after finalizing your plan, so implementation starts with a fresh context window while the plan survives in TodoWrite. ## Quick Start Add the suggest-compact hook to your Claude settings.json PreToolUse matchers for Edit and Write, then follow its suggestions to run /compact at logical phase transitions.

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 context compaction 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 logical phase boundaries: after research before planning, after finalizing a plan, after debugging, or after completing a milestone. Avoid compacting mid-implementation, since you lose variable names, file paths, and partial state.

What survives context compaction in Claude Code?

CLAUDE.md instructions, the TodoWrite task list, memory files, git state, and files on disk all persist. Lost items include intermediate reasoning, previously read file contents, conversation context, and tool call history.

How do I change the compaction suggestion threshold?

Set the COMPACT_THRESHOLD environment variable to your desired tool call count; the default is 50. After the first suggestion, the hook reminds you every 25 additional tool calls.

Why is manual compaction better than auto-compaction?

Auto-compaction triggers at arbitrary points, often mid-task, losing important context without awareness of task boundaries. Manual compaction at phase transitions preserves the context you still need while clearing stale exploration or debugging history.