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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Once installed, use the skills with the `nextflow:` namespace:
/nextflow:launch-workflow
```

## Hooks

A `PostToolUse` hook runs `nextflow lint` on any `.nf` or `.config` file the plugin writes or edits, feeding errors back so they get fixed automatically. It requires `nextflow` on `PATH` and skips silently when Nextflow isn't installed.

## Local Development

To test the plugin locally without installing:
Expand Down
16 changes: 16 additions & 0 deletions hooks/hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/scripts/nextflow-lint.sh",
"timeout": 120
}
]
}
]
}
}
31 changes: 31 additions & 0 deletions hooks/scripts/nextflow-lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# PostToolUse hook: lint Nextflow files after Claude writes or edits them.
# Surfaces `nextflow lint` errors back to Claude (exit 2) so it can self-correct.
set -euo pipefail

input="$(cat)"
file_path="$(printf '%s' "$input" | jq -r '.tool_input.file_path // empty')"

[ -n "$file_path" ] || exit 0

case "$file_path" in
*.nf | *.config) ;;
*) exit 0 ;;
esac

[ -f "$file_path" ] || exit 0

# Skip silently if Nextflow isn't installed; the install-nextflow skill covers setup.
command -v nextflow >/dev/null 2>&1 || exit 0

if output="$(nextflow lint "$file_path" 2>&1)"; then
exit 0
fi

{
echo "nextflow lint reported issues in ${file_path}:"
echo "$output"
echo
echo "Fix the lint errors above."
} >&2
exit 2