strategic-compact

Count tool invocations and trigger manual context compaction prompts via PreToolUse hook.

Updated Nov 17, 2025
One-click install
npx skills add https://github.com/itou-daiki/easy_stat_edu --skill strategic-compact-itou-daiki
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: strategic-compact
Source: https://github.com/itou-daiki/easy_stat_edu/tree/main/.agent/skills/strategic-compact
Command: npx skills add https://github.com/itou-daiki/easy_stat_edu --skill strategic-compact-itou-daiki

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Automatically losing important context during long AI tasks due to automatic or ill-timed compaction, making it hard to maintain continuity.

Core Features & Use Cases

  • Strategic timing: prompts for manual compaction at logical milestones rather than auto-trimming.
  • Context preservation: retains research context, implementation plans, and milestones across phases.
  • Guidance for workflows: suggests where to compact to minimize disruption while keeping necessary details.
  • Use Case: After exploration before execution, compact to start the next phase with a clean slate.

Quick Start

To use this skill, configure the hook and run with your current task to prompt for a manual compact at defined 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 automatic context compaction from losing important AI workflow context?

To prevent automatic context compaction from losing AI workflow context, you can use a PreToolUse hook that tracks tool invocations and prompts manual compaction at logical milestones, preserving research and implementation plans.

What is strategic context compaction in long AI sessions?

Strategic context compaction is prompting manual context reduction at logical workflow milestones rather than auto-trimming, which retains critical task context, implementation plans, and milestones across different execution phases.

How do I configure the context compaction threshold using environment variables?

Configure the context compaction threshold by setting the COMPACT_THRESHOLD environment variable or modifying ~/.claude/settings.json, defaulting to 50 tool invocations with periodic reminders every 25 calls.

When should I manually compact context during an AI task workflow?

You should manually compact context during an AI task workflow after exploration before execution, allowing you to start the next phase with a clean slate while preserving necessary research details and milestones.

Does the PreToolUse hook work without additional dependencies for workflow context tracking?

Yes, the PreToolUse hook works without additional dependencies, executing the suggest-compact.sh script directly to count tool invocations and trigger manual compaction prompts based on your configured threshold.

Why does ill-timed compaction disrupt long AI tasks and how to avoid it?

Ill-timed compaction disrupts long AI tasks by automatically trimming context mid-phase, which you avoid by triggering manual compaction prompts at logical milestones to maintain workflow continuity.