| name | strategic-compact |
| description | Promotes recurring feedback into the right skill, then guides /compact at phase boundaries. |
| when_to_use | Activate when the user types /strategic-compact, says "compact", "let's compact",
"we've finished phase X what's next", or when at a clear phase boundary
(PR merged, tests green, plan done) AND main-loop context is >50% full. Runs the
skill-self-improvement pass against accumulated feedback memory before recommending.
|
| disable-model-invocation | true |
| allowed-tools | Bash(ls:*), Bash(cat:*), Bash(grep:*), Bash(find:*), Bash(date:*), Bash(mkdir:*), Bash(bash ~/.claude/skills/strategic-compact/scripts/*), Read, Write, Edit, WebFetch |
User-invoked maintenance + compaction checkpoint. Two phases, in order:
- Self-improvement pass. Scan recent feedback memories + this session for rules that belong in a skill. Promote, shrink the source, mark MEMORY.md.
- Compaction recommendation. Suggest
/compact at a logical phase boundary with a paste-ready summary.
The skill is disable-model-invocation: true — zero context cost until the user types /strategic-compact.
Run at invocation. Output replaces these lines before Claude sees the body.
Skills on disk:
!ls -1 ~/.claude/skills/ 2>/dev/null
Subagents on disk:
!ls -1 ~/.claude/agents/ 2>/dev/null
Commands on disk:
!ls -1 ~/.claude/commands/ 2>/dev/null
Rules on disk:
!ls -1 ~/.claude/rules/ 2>/dev/null
Hook scripts on disk:
!ls -1 ~/.claude/hooks/ 2>/dev/null
Hooks + MCP + plugins configured in settings.json:
!bash ~/.claude/skills/strategic-compact/scripts/settings-features.sh
Today:
!date -u +%Y-%m-%dT%H:%M:%SZ
The work splits into two phases that have DIFFERENT context requirements:
- SCAN phase is a heavy file-read sweep across ALL Claude-extension types (skills, subagents, hooks, commands, rules, MCP, plugins — see
features-overview doc). Per references/claude-code-best-practices.md, the audit must cover the full extension surface, not just skills. Delegate to a subagent so the main loop's context stays small.
- APPLY phase needs per-candidate
AskUserQuestion prompts. Forked subagents CANNOT call AskUserQuestion. APPLY runs in the main loop.
This skill does NOT use context: fork in frontmatter (that would forbid AskUserQuestion across the whole run). Instead the body spawns a subagent for SCAN only, then continues in main-loop context for APPLY.
Execute in order:
-
SCAN — Spawn a general-purpose subagent with this prompt:
Read ~/.claude/skills/strategic-compact/workflows/self-improvement-pass.md and execute it end-to-end. Your final output must be the candidate-list Markdown described in the "Output contract" section. ALSO write the same content to ~/.claude/tmp/strategic-compact-candidates-<UTC-timestamp>.md (create the dir if missing). Return only the candidate list — no prose preamble.
Wait for the agent return. Save the file path it created.
-
APPLY — Read ~/.claude/skills/strategic-compact/workflows/apply-edits.md and execute it against the candidate list (prefer the subagent return; fall back to the file if truncated). Use AskUserQuestion for each candidate.
-
DECIDE — Read ~/.claude/skills/strategic-compact/workflows/compaction-decision.md and emit a compaction recommendation with a paste-ready /compact <summary> line.
If the SCAN phase returns an empty candidate list AND the self-healing sweep found nothing, skip directly to DECIDE.
<skip_when>
- User explicitly says "skip self-improvement" or "just compact" → run only DECIDE.
- No
feedback_* memories exist AND the session contained no corrections worth promoting → SCAN will report empty; skip to DECIDE.
- All candidate rules are project-specific (e.g., "PR #196 ships behind flag X") → SCAN drops them; skip to DECIDE.
</skip_when>
<workflows_index>
| Workflow | Role |
|---|
workflows/self-improvement-pass.md | SCAN — runs in a delegated subagent; produces candidate list |
workflows/apply-edits.md | APPLY — runs in main loop; per-candidate y/n prompts + Edit + shrink source |
workflows/compaction-decision.md | DECIDE — phase-boundary table + paste-ready /compact summary |
| </workflows_index> | |
<references_index>
| Reference | When to read |
|---|
references/promotion-quality-gates.md | During SCAN step 7b — every candidate must clear all 6 gates |
references/self-healing-checks.md | During SCAN step 1c (early) and APPLY late-sweep |
references/claude-code-best-practices.md | Pre-SCAN freshness check + drift-watch surfacing |
| </references_index> | |
<scripts_index>
The SCAN agent runs these EVERY invocation. Each replaces a multi-step inline bash block in the workflow doc — one tool call instead of six. Both emit === SECTION === prefixes for cheap parsing.
| Script | Replaces | Run during |
|---|
scripts/scan-inventory.sh | Steps 1, 1d, 1e, 1f, 1g, 1h, 1i (extension-universe dump) | Step 1 of SCAN |
scripts/self-healing-sweep.sh | Checks 1, 2, 4, 7 from references/self-healing-checks.md (mechanical-only) | Step 1c of SCAN |
scan-inventory.sh is also redundant when the SKILL.md <universe> block's dynamic context injection already ran — skip it in that case. Useful for fresh-fork invocations.
self-healing-sweep.sh honors SCAN_STRICT_XREF=1 to disable the known-optional-path filter (debugging only). Honors MEMORY_DIR=<path> to override project-memory auto-detection.
</scripts_index>
<success_criteria>