Summary
Skills (SKILL.md) currently have no way to programmatically trigger the built-in /compact command. This means a skill that saves a snapshot and wants to compact the context must ask the user to manually type /compact — breaking the single-command UX.
Use Case
I maintain AuraKit, a Claude Code skill with 33 modes. We have an /aura-compact command that:
- Saves a snapshot of the current work state to
.aura/snapshots/current.md
- Should trigger
/compact to reduce context
Step 2 is currently impossible. We've tried:
echo '/compact' | claude --resume — starts a new process, doesn't affect current session
export CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=1 — only affects Bash child process, not parent harness
- PowerShell
SendKeys — unreliable, platform-specific hack
None of these work because /compact is handled by the harness, and skills/AI have no API to trigger it.
Proposed Solution
One of these would solve the problem:
Option A: Add a compact field to skill/hook output JSON:
When the harness sees this from a skill or hook, it triggers compaction after the current turn.
Option B: Add a triggerCompact() function accessible from hooks:
// In a PostToolUse or Stop hook
const { triggerCompact } = require('claude-code-hooks');
triggerCompact(); // Signals harness to compact after this hook
Option C: Allow the Skill tool to invoke built-in commands:
skill: "compact" // Currently blocked: "Do not use this tool for built-in CLI commands"
Environment
- Claude Code v2.1.84
- Windows 11
- AuraKit v6.2.1
Impact
This affects any skill that wants to offer a "save + compact" workflow. The current workaround (asking users to manually type /compact) breaks the seamless automation that skills are supposed to provide.
Summary
Skills (SKILL.md) currently have no way to programmatically trigger the built-in
/compactcommand. This means a skill that saves a snapshot and wants to compact the context must ask the user to manually type/compact— breaking the single-command UX.Use Case
I maintain AuraKit, a Claude Code skill with 33 modes. We have an
/aura-compactcommand that:.aura/snapshots/current.md/compactto reduce contextStep 2 is currently impossible. We've tried:
echo '/compact' | claude --resume— starts a new process, doesn't affect current sessionexport CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=1— only affects Bash child process, not parent harnessSendKeys— unreliable, platform-specific hackNone of these work because
/compactis handled by the harness, and skills/AI have no API to trigger it.Proposed Solution
One of these would solve the problem:
Option A: Add a
compactfield to skill/hook output JSON:{ "compact": true }When the harness sees this from a skill or hook, it triggers compaction after the current turn.
Option B: Add a
triggerCompact()function accessible from hooks:Option C: Allow the
Skilltool to invoke built-in commands:Environment
Impact
This affects any skill that wants to offer a "save + compact" workflow. The current workaround (asking users to manually type
/compact) breaks the seamless automation that skills are supposed to provide.