mirror of
https://github.com/codeflash-ai/codeflash.git
synced 2026-05-04 18:25:17 +00:00
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:
parent
928cbfbcb8
commit
c2e37fceb0
3 changed files with 32 additions and 0 deletions
14
.claude/hooks/post-edit-lint.sh
Executable file
14
.claude/hooks/post-edit-lint.sh
Executable 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
16
.claude/settings.json
Normal 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
2
.gitignore
vendored
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue