Feature request: let hooks invoke slash commands (e.g. /compact) via hookSpecificOutput
Problem
Hook output supports systemMessage, additionalContext, permissionDecision, decision: "block", and similar — but no field that triggers a slash command. This blocks a class of useful automations:
- Auto-compact when context crosses a threshold (Stop hook detects size, can't run
/compact). - Auto-
/clearafter a long idle. - Trigger
/memorysave after specific tool patterns. - Run
/<custom-skill>post-condition from a Stop hook.
Today the only way to get any of these is to inject a systemMessage asking the model to run the command, which is brittle (model can ignore it, costs a turn, pollutes transcripts).
Proposed
Add to hookSpecificOutput:
{
"hookSpecificOutput": {
"hookEventName": "Stop",
"invokeCommand": "/compact"
}
}
Harness queues the slash command to run after the current turn settles, same way user-typed slash commands are handled. Should respect the same permissioning as user invocation (no privilege escalation).
Why this matters now
Just filed #54819 (percentage-based autoCompactWindow) — the underlying limitation is that even if you wanted to compute "compact at 55% of any model's window" yourself, a Stop hook can't trigger compaction. invokeCommand would unblock the entire user-land workaround path for compaction and a long tail of other automations.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗