strategic-compact

Prompt manual context compaction at logical milestones via PreToolUse hook.

3|Updated Jan 25, 2026
One-click install
npx skills add https://github.com/dongitran/ai-agent-config --skill strategic-compact-dongitran
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: strategic-compact
Source: https://github.com/dongitran/ai-agent-config/tree/main/.agent/skills/strategic-compact
Command: npx skills add https://github.com/dongitran/ai-agent-config --skill strategic-compact-dongitran

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill prompts manual context compaction at logical milestones to preserve task continuity and avoid loss of critical information due to arbitrary auto-compaction.

Core Features & Use Cases

  • Strategic prompts: Suggests manual /compact at key transitions (after exploration, after milestones, before major context shifts) to maintain relevant context.
  • Configurable thresholds: Allows setting COMPACT_THRESHOLD to control when the first prompt appears, with a default of 50 tool calls.
  • Hook-based integration: Works via the PreToolUse hook to provide timely compaction reminders during AI-assisted workflows.
  • Use Case: In a long coding or research session, observe and respond to compact prompts to keep context focused and avoid drift.

Quick Start

Configure Claude to load the strategic-compact skill, ensure the PreToolUse hook is enabled, and set COMPACT_THRESHOLD to your preference (default 50). Then run a multi-step task to see prompts at logical milestones.

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 coding sessions?

Manual context compaction prevents context loss by prompting consolidation at logical milestones. It preserves task continuity by advising compaction during exploration, planning, and milestone transitions before auto-compaction drops critical information.

When should I compact context in a multi-step AI workflow?

Compact context at logical milestones like after exploration, planning, or before major context shifts. Prompting manual compaction at these key transitions prevents context drift and maintains focused task continuity.

How does the PreToolUse hook manage context compaction thresholds?

The PreToolUse hook advises compaction by monitoring tool calls against the COMPACT_THRESHOLD environment variable. It triggers strategic prompts at a default threshold of 50 tool calls to maintain context relevance.

Can I configure when context compaction prompts appear in my workflow?

Yes, you can configure compaction prompt timing by setting the COMPACT_THRESHOLD environment variable. Adjusting this variable controls when the first prompt appears, defaulting to 50 tool calls.

What is the difference between strategic context compaction and auto-compaction?

Strategic context compaction prompts manual consolidation at logical milestones to preserve essential task context, whereas auto-compaction triggers arbitrarily and risks losing critical information during workflow transitions.