ST

strategic-compact

Suggests manual compaction at logical points to preserve context window integrity.

Install

mkdir -p .claude/skills/strategic-compact-hun99999 && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/14209" && unzip -o skill.zip -d .claude/skills/strategic-compact-hun99999 && rm skill.zip

Installs to .claude/skills/strategic-compact-hun99999

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Suggests optimal compaction points during long sessions. Monitors tool call count and recommends manual /compact at phase transitions rather than arbitrary auto-compaction.
172 charsno explicit “when” trigger
Beginner

Key capabilities

  • Monitor tool call count during coding sessions
  • Suggest manual compaction at logical phase transitions
  • Provide periodic reminders for compaction after an initial threshold
  • Configure the tool call threshold for the first compaction suggestion

How it works

The skill uses a PreToolUse hook to increment a per-session tool counter. When the counter reaches a configured threshold, it outputs a message suggesting manual compaction.

Inputs & outputs

You give it
Tool call operations (Edit or Write)
You get back
A message suggesting '/compact'

When to use strategic-compact

  • Maintaining context for long sessions
  • Managing tool call frequency
  • Suggesting /compact at logical transitions
  • Reducing context window churn

About this skill

Strategic Compact Skill

This skill helps maintain context coherence by suggesting manual compaction at strategic points during long coding sessions.

Overview

AI coding assistants have limited context windows. When auto-compaction occurs mid-task, critical context can be lost. This skill tracks session activity and suggests compaction at logical phase transitions rather than arbitrary points.

Why Strategic Compaction?

Auto-CompactStrategic Compact
Happens at arbitrary pointsHappens at logical transitions
Often mid-taskAfter completing milestones
May lose critical contextPreserves phase-relevant context
Unpredictable timingControlled by user

When to Activate

This skill activates via the Claude Code PreToolUse hook when:

  • Tool calls reach the configured threshold (default: 50)
  • Matches Edit or Write tool operations
  • Session is in a stable state for compaction

How It Works

PreToolUse Hook → suggest-compact.sh
                         ↓
              Increment tool counter
                         ↓
              Check against threshold
                         ↓
         (if threshold reached)
                         ↓
    Output: "[StrategicCompact] Consider /compact"

Counter Mechanism

The script maintains a per-session counter in /tmp/claude-tool-count-$$:

  1. Initial threshold (50 calls): First suggestion to compact
  2. Every 25 calls after: Periodic reminders if context feels stale
# First suggestion at 50 tool calls
[StrategicCompact] 50 tool calls reached - consider /compact if transitioning phases

# Subsequent suggestions every 25 calls
[StrategicCompact] 75 tool calls - good checkpoint for /compact if context is stale

Configuration

Environment Variables

VariableDefaultDescription
COMPACT_THRESHOLD50Tool calls before first suggestion

Set custom threshold:

export COMPACT_THRESHOLD=100

Hook Setup

Add to ~/.claude/settings.json:

{
  "hooks": {
    "PreToolUse": [{
      "matcher": "Edit|Write",
      "hooks": [{
        "type": "command",
        "command": "~/.claude/skills/strategic-compact/suggest-compact.sh"
      }]
    }]
  }
}

Matcher Options

MatcherDescription
Edit|WriteOnly during file modifications (recommended)
*All tool calls (more aggressive)

Best Practices

Ideal Compaction Points

  1. After exploration, before implementation

    • Research phase complete
    • Plan finalized
    • Ready to start coding
  2. After completing a milestone

    • Feature implemented
    • Tests passing
    • Ready for next feature
  3. When switching contexts

    • Moving to different component
    • Changing focus area
    • Starting new task

Signs Context is Stale

  • AI repeating previous explanations
  • Confusion about recent changes
  • Asking for information already provided
  • Inconsistent responses

Output Messages

MessageMeaning
N tool calls reachedFirst threshold hit, consider compact
good checkpoint for /compactPeriodic reminder after threshold

Related Skills

  • continuous-learning/ - Extract patterns from sessions
  • tdd-workflow/ - Test-driven development workflow

When not to use it

  • When auto-compaction is preferred over manual control
  • When context loss mid-task is not a concern
  • When short coding sessions do not require strategic compaction

Limitations

  • The skill only suggests compaction; it does not perform compaction automatically
  • The tool call counter is maintained in a temporary file, which may not persist across system restarts
  • Suggestions are based on tool call volume, not direct understanding of task completion

How it compares

This skill suggests compaction at logical phase transitions, preserving phase-relevant context, unlike arbitrary auto-compaction that may occur mid-task.

Compared to similar skills

strategic-compact side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
strategic-compact (this skill)06moReviewBeginner
pptx3936moReviewAdvanced
nano-pdf632moReviewBeginner
video-downloader1017moReviewBeginner

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

pptx

anthropics

Presentation creation, editing, and analysis. When Claude needs to work with presentations (.pptx files) for: (1) Creating new presentations, (2) Modifying or editing content, (3) Working with layouts, (4) Adding comments or speaker notes, or any other presentation tasks

393763

nano-pdf

openclaw

Edit PDFs with natural-language instructions using the nano-pdf CLI.

63300

video-downloader

ComposioHQ

Downloads videos from YouTube and other platforms for offline viewing, editing, or archival. Handles various formats and quality options.

101255

youtube-transcript

michalparkola

Download YouTube video transcripts when user provides a YouTube URL or asks to download/get/fetch a transcript from YouTube. Also use when user wants to transcribe or get captions/subtitles from a YouTube video.

68277

using-superpowers

obra

Use when starting any conversation - establishes mandatory workflows for finding and using skills, including using Skill tool before announcing usage, following brainstorming before coding, and creating TodoWrite todos for checklists

95205

browser-automation

browserbase

Automate web browser interactions using natural language via CLI commands. Use when the user asks to browse websites, navigate web pages, extract data from websites, take screenshots, fill forms, click buttons, or interact with web applications. Triggers include "browse", "navigate to", "go to website", "extract data from webpage", "screenshot", "web scraping", "fill out form", "click on", "search for on the web". When taking actions be as specific as possible.

39230

Search skills

Search the agent skills registry