You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-18Lines changed: 15 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,14 +9,15 @@ Python hooks for Claude Code for projects using:
9
9
The hooks ensure that the quality tools are automatically used:
10
10
11
11
Each time a file is edited:
12
-
- Reformat with `ruff format`
13
-
- Type-check with `mypy`
14
-
- Record the file
12
+
- Record the file for later processing
15
13
16
-
When claude is ready to stop:
17
-
- Repair lints of edited files with `ruff check --fix`. (We do not do this while editing files, becaue it Claude tends to add `import` statements in a dedicated edit, ahead of adding the code that uses it. In this case, `ruff check --fix` would erase the "unused" import.)
18
-
- Run the tests with `pytest`.
14
+
When Claude is ready to stop:
15
+
- Reformat edited files with `ruff format`
16
+
- Repair lints of edited files with `ruff check --fix`
17
+
- Type-check edited files with `mypy`
18
+
- Run the tests with `pytest`
19
19
20
+
Note: We defer `ruff format` and `ruff check` until Claude stops to avoid changing files while Claude is working. Changing files during editing would spoil Claude's edits and force it to reread files.
20
21
## Installation
21
22
22
23
```bash
@@ -29,12 +30,12 @@ This package provides hooks that can be used with Claude Code's hook system.
29
30
30
31
### Available Commands
31
32
32
-
-`edited` - Tracks edited Python files for deferred processing
33
+
-`edited` - Tracks edited Python files for deferred processing (used in PostToolUse hook)
33
34
-`git status` - Shows git status
34
-
-`mypy` - Runs mypy type checking on edited files when used as a PostToolUse hook or all files when used as a Stop hook
35
+
-`mypy` - Runs mypy type checking on edited files (used in Stop hook)
35
36
-`pytest` - Runs pytest
36
-
-`ruff check` - Runs ruff check on collected files with auto-fix
37
-
-`ruff format` - Runs ruff format on edited files
37
+
-`ruff check` - Runs ruff check on collected files with auto-fix (used in Stop hook)
38
+
-`ruff format` - Runs ruff format on collected files (used in Stop hook)
38
39
-`session start` - Prints introductory message about automatic hooks
39
40
40
41
### Claude Code Settings
@@ -61,6 +62,10 @@ Add hooks to your Claude Code settings.json:
61
62
"Stop": [
62
63
{
63
64
"hooks": [
65
+
{
66
+
"type": "command",
67
+
"command": "poetry run python-claude ruff format"
68
+
},
64
69
{
65
70
"type": "command",
66
71
"command": "poetry run python-claude ruff check"
@@ -80,17 +85,9 @@ Add hooks to your Claude Code settings.json:
0 commit comments