Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .claude/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ understood on its own. This file documents the hooks that are currently wired up
skips silently if it is not present)
- **`async: true`**: runs in the background so formatting never blocks the conversation

### 2. Build check (Stop + SubagentStop)
- **Script**: `hooks/check-build.sh`
- **Trigger**: when Claude (or a subagent) finishes responding
- **Action**: runs `make compile` to catch syntax/compilation errors early
- **Failure mode**: blocking — feeds a parsed error summary back to Claude so it
can fix the breakage before yielding

## Enabling / disabling

Hooks are configured in `.claude/settings.json`. Disable one by removing its entry;
Expand Down
32 changes: 32 additions & 0 deletions .claude/hooks/check-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
#
# Build check hook for Nextflow development.
#
# On Stop / SubagentStop, run `make compile` to catch syntax and compilation
# errors. On failure, block and feed a parsed error summary back to Claude.
#
# Reads the Claude Code hook payload as JSON on stdin (requires `jq`).

set -uo pipefail

command -v jq >/dev/null 2>&1 || exit 0

input=$(cat)
event=$(jq -r '.hook_event_name // ""' <<<"$input")

case "$event" in
Stop|SubagentStop) ;;
*) exit 0 ;;
esac

start=$SECONDS
if out=$(make compile 2>&1); then
jq -n --arg s "$(( SECONDS - start ))" \
'{suppressOutput: true, systemMessage: ("✓ Build check passed (" + $s + "s)")}'
else
summary=$(printf '%s\n' "$out" | grep -iE 'error|failed|exception' | tail -n 10)
[[ -n "$summary" ]] || summary=$(printf '%s\n' "$out" | tail -n 20)
jq -n --arg r "Build check failed:
$summary" \
'{decision: "block", reason: $r, stopReason: "Build compilation failed"}'
fi
22 changes: 22 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,28 @@
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/check-build.sh",
"timeout": 120
}
]
}
],
"SubagentStop": [
{
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/check-build.sh",
"timeout": 120
}
]
}
]
}
}
Loading