Skip to content

Comments

fix(hooks): use plugin root path and deterministic stop script#34

Merged
MacAttak merged 1 commit intomainfrom
work/fix-hooks-reliability
Feb 16, 2026
Merged

fix(hooks): use plugin root path and deterministic stop script#34
MacAttak merged 1 commit intomainfrom
work/fix-hooks-reliability

Conversation

@MacAttak
Copy link
Contributor

Summary

  • Fix SessionStart hook to resolve script path from ${CLAUDE_PLUGIN_ROOT} instead of relative CWD (caused MODULE_NOT_FOUND in every non-Specwright project)
  • Replace Stop hook's non-deterministic LLM prompt (type: "prompt") with a deterministic Node.js script (type: "command") that outputs clean JSON

Acceptance Criteria

# Criterion Status Evidence
AC-1 SessionStart hook resolves from plugin root PASS hooks/hooks.json:8 — uses ${CLAUDE_PLUGIN_ROOT}/hooks/session-start.mjs
AC-2 Stop hook produces deterministic JSON PASS hooks/hooks.json:18type: "command", hooks/session-stop.mjs:26console.log(JSON.stringify(...))
AC-3 Stop hook degrades gracefully PASS hooks/session-stop.mjs:13-16 (missing file), :33-35 (parse error), :23-29 (active work)

Gate Results

Gate Status Findings (B/W/I)
build SKIP No build command configured
tests SKIP No test runner configured
security SKIP Quick intensity
wiring SKIP Quick intensity
spec WARN 0/1/0 — no automated test coverage (project has no test runner)

Evidence

  • Spec compliance report: .specwright/work/fix-hooks-reliability/evidence/spec-compliance.md

Work unit: fix-hooks-reliability | Intensity: quick

🤖 Generated with Claude Code

SessionStart used a relative path that resolved against project CWD
instead of the plugin root, causing MODULE_NOT_FOUND in every non-
Specwright project. Stop hook used type:prompt which produced non-
deterministic JSON from LLM output, failing validation intermittently.

- SessionStart: node ./hooks/... → node ${CLAUDE_PLUGIN_ROOT}/hooks/...
- Stop: type:prompt → type:command with new session-stop.mjs script
- session-stop.mjs reads workflow.json directly, outputs clean JSON

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@MacAttak MacAttak merged commit 4527bf4 into main Feb 16, 2026
2 checks passed
@MacAttak MacAttak deleted the work/fix-hooks-reliability branch February 16, 2026 04:05
@github-actions github-actions bot mentioned this pull request Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant