Productivity
strategic-compact avatar

strategic-compact

Enhance workflow efficiency by performing manual context compaction at logical task boundaries instead of relying on unpredictable auto-compaction.

Introduction

Strategic Compact is a specialized skill for Claude Code that replaces arbitrary, disruptive auto-compaction with intentional, user-controlled memory management. By monitoring tool usage through PreToolUse hooks, this skill tracks interaction volume and suggests compaction specifically when logical task boundaries occur—such as after finishing research, before starting a new implementation phase, or upon debugging completion. This approach ensures that vital task context remains preserved during complex multi-step operations where standard auto-compaction might otherwise purge necessary historical data prematurely. It provides developers with granular control over the agent's context window, optimizing token usage while maintaining task continuity.

  • Tracks tool invocations such as Edit and Write to provide data-driven suggestions.

  • Configurable threshold detection (default 50 calls) with periodic 25-call follow-up reminders.

  • Enables cleaner session states by allowing users to flush exploration noise before moving to execution phases.

  • Integrates directly into ~/.claude/settings.json using the PreToolUse hook architecture.

  • Supports custom tuning via environment variables like COMPACT_THRESHOLD for different workflow intensities.

  • Recommended for developers managing large, multi-file software projects requiring long-term session context.

  • Best used after planning phases or error-resolution cycles to clear temporary context without losing the main project state.

  • Avoid usage mid-implementation to ensure the model retains immediate code-change history.

  • Provides a manual safety valve; the system prompts the user, but the final decision to compact remains with the developer.

  • Ideal for environments where tokens must be optimized to keep core project logic in memory while discarding transient exploration traces.

Repository Stats

Stars
675
Forks
150
Open Issues
27
Language
Shell
Default Branch
main
Sync Status
Idle
Last Synced
May 1, 2026, 09:32 AM
View on GitHub