PostToolUse hooks run after every file edit: - Backend: ./mvnw compile (Checkstyle Google Style + javac) - Frontend: vue-tsc --noEmit + oxlint + ESLint Stop hook runs test suites when source files changed, blocks the agent on failure and re-engages it to fix the issue. Output is filtered to [ERROR] lines only for context efficiency. Static analysis: Checkstyle (validate phase), SpotBugs (verify phase), ArchUnit (9 hexagonal architecture rules as JUnit tests). Fail-fast: Surefire skipAfterFailureCount=1, Vitest bail=1. Test log noise suppressed via logback-test.xml (WARN level), redirectTestOutputToFile, and trimStackTrace. Existing Java sources reformatted to Google Style (2-space indent, import order, Javadoc on public types). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
24 lines
945 B
Bash
Executable File
24 lines
945 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Read hook input from stdin (JSON with tool_input.file_path)
|
|
INPUT=$(cat)
|
|
FILE_PATH=$(echo "$INPUT" | python3 -c "import sys,json; print(json.load(sys.stdin).get('tool_input',{}).get('file_path',''))" 2>/dev/null || echo "")
|
|
|
|
# Only run for Java files under backend/
|
|
case "$FILE_PATH" in
|
|
*/backend/src/*.java|backend/src/*.java) ;;
|
|
*) exit 0 ;;
|
|
esac
|
|
|
|
cd "$CLAUDE_PROJECT_DIR/backend"
|
|
|
|
# Run compile (includes validate phase -> Checkstyle if configured)
|
|
# Context-efficient: suppress output on success, show full output on failure
|
|
if OUTPUT=$(./mvnw compile -q 2>&1); then
|
|
echo '{"hookSpecificOutput":{"hookEventName":"PostToolUse","additionalContext":"✓ Backend compile passed."}}'
|
|
else
|
|
ESCAPED=$(echo "$OUTPUT" | python3 -c "import sys,json; print(json.dumps(sys.stdin.read()))")
|
|
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PostToolUse\",\"additionalContext\":$ESCAPED}}"
|
|
fi
|