feat(cli): Add Claude Code-style Hooks #5335
Open
+1,712
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
Add Claude Code–style lifecycle hooks to the CLI so users can automate actions around key events (session start/end, prompt submit, stop, pre‑compact), plus document the configuration format and add tests.
Implementation
hooksfield), with schema‑safe typing and persistence updates.SessionStart/SessionEndincli.tsUserPromptSubmitin the message handlerPreCompactbefore condenseStopwhen completion is detectedNote:
PreToolUse,PostToolUse,PermissionRequest, andNotificationare supported in config but intentionally not wired yet.Screenshots
How to Test
cd cli && pnpm test src/hooks/__tests__/config.test.ts src/hooks/__tests__/runner.test.ts src/config/__tests__/persistence.test.ts~/.kilocode/cli/config.json(or<workspace>/.kilocode/cli/config.json):{ "hooks": { "Stop": [ { "matcher": "", "hooks": [{ "type": "command", "command": "afplay /System/Library/Sounds/Glass.aiff" }] } ] } }Get in Touch
Discord: aravhawk