claude-configs/hooks/format-code.sh
Cal Corum efebbc7a95 Add PostToolUse hook for auto-formatting Python with uvx black
- New hooks/format-code.sh: reads file path from stdin JSON, dispatches
  by extension (*.py → uvx black, *.js/ts → prettier)
- Updated settings.json: PostToolUse hook on Edit/Write/MultiEdit

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 21:49:54 -06:00

13 lines
291 B
Bash
Executable File

#!/bin/bash
# Read tool input from stdin (JSON with tool_input.file_path)
FILE=$(jq -r '.tool_input.file_path // empty' 2>/dev/null)
[ -z "$FILE" ] && exit 0
case "$FILE" in
*.py)
uvx black --quiet "$FILE" ;;
*.js|*.ts|*.jsx|*.tsx)
prettier --write "$FILE" 2>/dev/null ;;
esac