feat: add Claude Code post-edit lint hook using prek

Automatically runs `uv run prek` on Python files after Edit/Write
tool usage to catch lint and formatting issues at edit time.
This commit is contained in:
Kevin Turcios 2026-03-27 08:25:36 -05:00
parent 928cbfbcb8
commit c2e37fceb0
3 changed files with 32 additions and 0 deletions

14
.claude/hooks/post-edit-lint.sh Executable file
View file

@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Everyone is on macOS so this should be fine, we don't account for Windows
set -euo pipefail
input=$(cat)
file_path=$(echo "$input" | jq -r '.tool_input.file_path // empty')
if [[ -z "$file_path" || ! -f "$file_path" ]]; then
exit 0
fi
if [[ "$file_path" == *.py ]]; then
uv run prek --files "$file_path" 2>/dev/null || true
fi

16
.claude/settings.json Normal file
View file

@ -0,0 +1,16 @@
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": ".claude/hooks/post-edit-lint.sh",
"timeout": 30
}
]
}
]
}
}

2
.gitignore vendored
View file

@ -269,6 +269,8 @@ tessl.json
# Claude Code - track shared rules, ignore local config
.claude/*
!.claude/rules/
!.claude/settings.json
!.claude/hooks/
**/node_modules/**
**/dist-nuitka/**
**/.npmrc