diff --git a/.claude/hooks/check-on-stop.sh b/.claude/hooks/check-on-stop.sh new file mode 100755 index 0000000..318c0e3 --- /dev/null +++ b/.claude/hooks/check-on-stop.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# Stop hook: run the quality gate. On failure, exit 2 so Claude Code blocks the +# stop and hands the output back to the agent to fix; on success, exit 0 to let +# the turn end. It keeps retrying until green — interrupt to break out, or guard +# on the input's stop_hook_active to cap it at one attempt. +set -uo pipefail + +cd "${CLAUDE_PROJECT_DIR:-.}" || exit 0 + +if ! output=$(make check 2>&1); then + printf '%s\n' "$output" >&2 + exit 2 +fi diff --git a/.claude/settings.json b/.claude/settings.json index 953faad..ed666b4 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -5,7 +5,7 @@ "hooks": [ { "type": "command", - "command": "cd \"$CLAUDE_PROJECT_DIR\" && make check" + "command": "\"$CLAUDE_PROJECT_DIR/.claude/hooks/check-on-stop.sh\"" } ] }