strategic-compact

Prompt manual compaction at configurable thresholds to preserve context.

1|Updated Mar 20, 2024
One-click install
npx skills add https://github.com/flag3/dotfiles --skill strategic-compact
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: strategic-compact
Source: https://github.com/flag3/dotfiles/tree/main/.claude/skills/strategic-compact
Command: npx skills add https://github.com/flag3/dotfiles --skill strategic-compact

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Auto-compaction can cause loss of important context by triggering at arbitrary points during a task. This Skill prompts strategic, manual compaction to preserve exploration context through task phases.

Core Features & Use Cases

  • Strategic prompts at logical boundaries to compact research data before execution.
  • Hook-driven integration via PreToolUse to remind and guide when to compact.
  • Configurable thresholds (COMPACT_THRESHOLD) to tailor prompts to session length and complexity.
  • Use Case: In a multi-phase AI-assisted project, compact after planning to start execution with a clean context and after milestones to reset context for the next phase.

Quick Start

Activate the strategic-compact skill by ensuring the SKILL.md and suggest-compact.sh script are present in the skill's root. Set COMPACT_THRESHOLD in your environment (default 50). The tool will count invocations and emit prompts at the threshold and then every 25 calls thereafter.

Frequently Asked Questions about strategic-compact

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

FAQPage Schema
How do I prevent context loss during long AI-assisted tasks?

Strategic compaction preserves context by prompting manual compaction at logical task boundaries rather than at arbitrary points. This maintains coherent exploration data through research-to-execution transitions and milestone handoffs, preventing information loss that auto-compaction can cause.

When should I compact context in a multi-phase project?

Compact context after planning phases before execution begins, and after major milestones to reset context for the next phase. This approach keeps each phase focused while retaining the reasoning needed to proceed, controlled by setting COMPACT_THRESHOLD in your environment.

How does hook-driven context compaction work?

The Skill integrates via PreToolUse hooks to count tool invocations and emit compaction prompts at your configured threshold, then every 25 calls thereafter. This guides you to compact at predictable intervals aligned with task complexity rather than on a fixed schedule.

What setup is required to use strategic compaction?

Add a SKILL.md file with name and description metadata, include a suggest-compact.sh script in the root directory, and set the COMPACT_THRESHOLD environment variable (default 50). The Skill activates once these components are present.

Can I customize when compaction prompts appear?

Yes. The COMPACT_THRESHOLD environment variable controls prompt frequency. Set it lower for shorter sessions or higher for complex tasks; the tool then prompts at that threshold and every 25 invocations after, tailoring prompts to your session length.

What's the difference between strategic and automatic context compaction?

Automatic compaction triggers at arbitrary points and risks losing important exploration context. Strategic compaction gives you control by prompting at logical task boundaries, preserving research data and reasoning through decision points and phase transitions.