#!/usr/bin/env bash # auto-test.sh - Run corresponding test file after Write/Edit tool calls. # Reads PostToolUse JSON from stdin, maps source files to test files by convention. # Outputs [auto-test] prefixed results to stderr so Claude can see pass/fail. # Exits 2 when tests fail so Claude Code surfaces the stderr output. set -euo pipefail input=$(cat) file_path=$(echo "$input" | jq -r '.tool_input.file_path // ""') if [ -z "$file_path" ] || [ ! -f "$file_path" ]; then exit 0 fi has_failures=0 # Run a test command and emit prefixed output to stderr. # Usage: report