بنقرة واحدة
strategic-compact
Hook-based compaction suggestions at logical task boundaries
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Hook-based compaction suggestions at logical task boundaries
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Convert PDF/EPUB library to Markdown and generate Obsidian MOC notes
Context window management — track spend, decide when to compact, preserve state
Session-start orientation — loads context, surfaces learnings, confirms registry
Quality and semantic review — catches what automated tools miss
Planner → Architect → Critic deliberation loop — produces a formally validated ADR
Dual-dimension document quality gate — presentation rubric + hallucination grounding check
| name | strategic-compact |
| description | Hook-based compaction suggestions at logical task boundaries |
| version | 0.1.0 |
| level | 2 |
| triggers | ["compact now","context getting full","running out of space","should i compact"] |
| context_files | ["context/learnings.md"] |
| steps | [{"name":"Tool Invocation Count","description":"Track tool calls since last compact or session start"},{"name":"Boundary Detection","description":"Identify if current state is at a logical task boundary"},{"name":"Compact Decision","description":"Apply decision guide to recommend compact or defer"},{"name":"State Preservation","description":"Remind user to capture critical state before compacting"},{"name":"Context Documentation","description":"Update learnings.md with pre-compact state if needed"}] |
Suggests /compact at logical task boundaries. Prevents premature compaction that loses critical context.
Without strategic compaction guidance, Claude either:
Strategic compaction maintains context hygiene without disrupting workflow.
Compaction suggestions triggered by tool call count:
Count these tools:
Don't count: TodoWrite, AskUserQuestion (metadata operations)
Integration with existing preserve-on-compact.sh hook: hook fires on /compact; this skill decides when to suggest it.
| Transition | Compact? | Reasoning |
|---|---|---|
| Research → Planning | YES | Research artifacts captured, planning starts fresh |
| Planning → Implementation | YES | Plan finalized, implementation is new phase |
| Mid-Implementation | NO | Variable state, error traces, partial progress would be lost |
| After Failed Approach | YES | Dead end documented in learnings.md, fresh start needed |
| Feature Complete → Testing | YES | Implementation done, testing is verification phase |
| Bug Hunt in Progress | NO | Debugging requires full context (stack traces, state, prior attempts) |
| After Successful PR Merge | YES | Work complete, next task starts clean |
General Rule: Compact at phase transitions where the prior phase's working context is no longer needed for the next phase.
Claude Code's compaction preserves:
Lost during compaction:
Before compacting, ensure these are captured:
In context/learnings.md:
In context/decisions.md:
In code comments:
In test files:
The preserve-on-compact.sh hook prompts for this, but this skill provides the content checklist.
preserve-on-compact.sh (PreCompact hook):
Recommended enhancement: Add tool invocation counter to preserve-on-compact.sh:
TOOL_COUNT=$(grep -c "Tool:" .claude/session.log 2>/dev/null || echo 0)
if [ "$TOOL_COUNT" -gt 50 ]; then
echo "50+ tool calls since last compact. Consider capturing state."
fi
(Note: session.log doesn't exist in current Claude Code. This is aspirational for future hook enhancements.)
Compacting mid-debugging: You're investigating a bug, have a stack trace, tried 3 approaches. Compacting now loses all that context. Finish the investigation first.
Compacting to "clean up": Compaction isn't for aesthetics. Only compact at task boundaries or when context pressure is real (100+ tool calls).
Ignoring the 50-call reminder: If you're at 50 calls and still in the same task, that's a signal the task might be too large. Consider checkpointing or breaking it down.
Compacting without preserving dead ends: "I tried X but it failed because Y" is critical for the next session. Write it to learnings.md before compacting.