diff --git a/hooks/format-code.sh b/hooks/format-code.sh new file mode 100755 index 0000000..0726d25 --- /dev/null +++ b/hooks/format-code.sh @@ -0,0 +1,12 @@ +#!/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 diff --git a/settings.json b/settings.json index 4468ec0..8c4ef18 100644 --- a/settings.json +++ b/settings.json @@ -103,6 +103,18 @@ }, "effortLevel": "medium", "hooks": { + "PostToolUse": [ + { + "matcher": "Edit|Write|MultiEdit", + "hooks": [ + { + "type": "command", + "command": "/home/cal/.claude/hooks/format-code.sh", + "timeout": 10 + } + ] + } + ], "SessionEnd": [ { "hooks": [