Summary
npx codachi init writes the hook under the event key PostToolExecution, but Claude Code's canonical hook event name is PostToolUse. As a result:
claude /doctor flags an unknown settings key (Found 1 settings issue).
- The hook never fires, so
events.json stays empty and the pet has no events to react to (defeats the main selling point).
The entry shape is also flat ({matcher, command}); Claude Code's canonical form is {matcher, hooks: [{type, command}]}.
Repro
On a fresh box:
npx codachi init
claude /doctor # → "Found 1 settings issue"
Then inspect ~/.claude/settings.json — you'll see "PostToolExecution" where "PostToolUse" should be.
Evidence
src/init.ts:65 currently:
hooks.PostToolExecution = cleaned;
…and cleaned.push({ matcher: '', command: hookCmd }) on line 64 produces the flat shape.
Suggested fix
// init.ts — around lines 62–66
const postHooks = Array.isArray(hooks.PostToolUse) ? hooks.PostToolUse : [];
const cleaned = postHooks.filter(/* existing codachi filter */);
cleaned.push({
matcher: '',
hooks: [{ type: 'command', command: hookCmd }],
});
hooks.PostToolUse = cleaned;
Plus a one-off migration in runInit() to move any old PostToolExecution entries onto PostToolUse so existing users upgrade cleanly.
Canonical hook event names from Claude Code docs: PreToolUse, PostToolUse, UserPromptSubmit, Notification, Stop, SubagentStop, SessionStart, SessionEnd, PreCompact.
Happy to open a PR if useful — small change, plus a test against the expected settings.json shape.
Discovered while setting up codachi on Claude Code v2.
Summary
npx codachi initwrites the hook under the event keyPostToolExecution, but Claude Code's canonical hook event name isPostToolUse. As a result:claude /doctorflags an unknown settings key (Found 1 settings issue).events.jsonstays empty and the pet has no events to react to (defeats the main selling point).The entry shape is also flat (
{matcher, command}); Claude Code's canonical form is{matcher, hooks: [{type, command}]}.Repro
On a fresh box:
Then inspect
~/.claude/settings.json— you'll see"PostToolExecution"where"PostToolUse"should be.Evidence
src/init.ts:65currently:…and
cleaned.push({ matcher: '', command: hookCmd })on line 64 produces the flat shape.Suggested fix
Plus a one-off migration in
runInit()to move any oldPostToolExecutionentries ontoPostToolUseso existing users upgrade cleanly.Canonical hook event names from Claude Code docs:
PreToolUse,PostToolUse,UserPromptSubmit,Notification,Stop,SubagentStop,SessionStart,SessionEnd,PreCompact.Happy to open a PR if useful — small change, plus a test against the expected settings.json shape.
Discovered while setting up codachi on Claude Code v2.