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.zipInstalls 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.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
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-Compact | Strategic Compact |
|---|---|
| Happens at arbitrary points | Happens at logical transitions |
| Often mid-task | After completing milestones |
| May lose critical context | Preserves phase-relevant context |
| Unpredictable timing | Controlled 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-$$:
- Initial threshold (50 calls): First suggestion to compact
- 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
| Variable | Default | Description |
|---|---|---|
COMPACT_THRESHOLD | 50 | Tool 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
| Matcher | Description |
|---|---|
Edit|Write | Only during file modifications (recommended) |
* | All tool calls (more aggressive) |
Best Practices
Ideal Compaction Points
-
After exploration, before implementation
- Research phase complete
- Plan finalized
- Ready to start coding
-
After completing a milestone
- Feature implemented
- Tests passing
- Ready for next feature
-
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
| Message | Meaning |
|---|---|
N tool calls reached | First threshold hit, consider compact |
good checkpoint for /compact | Periodic reminder after threshold |
Related Skills
continuous-learning/- Extract patterns from sessionstdd-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.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| strategic-compact (this skill) | 0 | 6mo | Review | Beginner |
| pptx | 393 | 6mo | Review | Advanced |
| nano-pdf | 63 | 2mo | Review | Beginner |
| video-downloader | 101 | 7mo | Review | Beginner |
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
nano-pdf
openclaw
Edit PDFs with natural-language instructions using the nano-pdf CLI.
video-downloader
ComposioHQ
Downloads videos from YouTube and other platforms for offline viewing, editing, or archival. Handles various formats and quality options.
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.
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
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.