strategic-compact

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

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/erwinv2k-TKG/AgentesVSC --skill strategic-compact-erwinv2k-tkg
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: strategic-compact
Source: https://github.com/erwinv2k-TKG/AgentesVSC/tree/main/packs/everything-claude-code/docs/zh-TW/skills/strategic-compact
Command: npx skills add https://github.com/erwinv2k-TKG/AgentesVSC --skill strategic-compact-erwinv2k-tkg

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Automatic context compaction triggers at arbitrary points, often mid-task, losing important context and interrupting complex multi-step operations. This Skill helps you compact at logical boundaries instead, preserving the context that matters for each task phase. ## Core Features & Use Cases - Tool Call Tracking: A PreToolUse hook script counts tool calls in the session and detects when a configurable threshold is reached. - Threshold-Based Suggestions: Recommends running /compact after a default of 50 tool calls, then reminds every 25 calls afterward. - Configurable Behavior: Adjust the first-suggestion threshold with the COMPACT_THRESHOLD environment variable. - Use Case: After finishing codebase exploration and locking in an implementation plan, the hook reminds you to compact research context so execution starts with a clean, focused window. ## Quick Start Add the suggest-compact.sh script as a PreToolUse hook for Edit and Write tools in your Claude settings.json so you receive compaction suggestions at logical intervals.

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 the /compact command manually at logical boundaries, such as after exploration before execution or after completing a milestone. The suggest-compact.sh hook tracks tool calls and reminds you when a threshold is reached.

How do I set up the strategic compaction hook?

Add a PreToolUse hook in your ~/.claude/settings.json matching Edit and Write tools, pointing to the suggest-compact.sh script. The hook then monitors tool usage and prints compaction suggestions during the session.

Can I change the compaction suggestion threshold?

Yes, set the COMPACT_THRESHOLD environment variable to control how many tool calls occur before the first suggestion. The default is 50 calls, with reminders every 25 calls afterward.

When should I avoid compacting context?

Avoid compacting in the middle of implementation, since related changes depend on the surrounding context. Compact after planning is finalized or after debugging is resolved, when the prior context is no longer needed.

Does the hook compact context automatically?

No, the hook only suggests when compaction may be appropriate. You decide whether to run /compact, keeping control over which context is preserved for the current task.