#!/bin/bash # Run oxlint on the edited file and inject errors back into Claude's context. # Reads the PostToolUse JSON payload from stdin. # Exits 0 silently on pass or non-TS file; outputs JSON additionalContext on failure. set -euo pipefail FILE=$(python3 -c " import sys, json d = json.load(sys.stdin) print(d.get('tool_input', {}).get('file_path', '')) ") # Only lint TypeScript files case "$FILE" in *.ts|*.tsx) ;; *) exit 0 ;; esac cd /home/chris/Projects/brackt.com OUTPUT=$(npm run lint:path -- "$FILE" 2>&1) && exit 0 # Lint failed — inject errors into Claude's context so it fixes them immediately python3 -c " import json, sys out = sys.argv[1] f = sys.argv[2] print(json.dumps({ 'hookSpecificOutput': { 'hookEventName': 'PostToolUse', 'additionalContext': 'Lint errors found in ' + f + ' — fix before continuing:\n' + out } })) " "$OUTPUT" "$FILE"