Skip to content

Commit 5b66f8e

Browse files
authored
task: Add Claude Code auto-format hook (#311)
* task: Claude formats JavaScript after edits Based on https://code.claude.com/docs/en/hooks-guide#auto-format-code-after-edits Opted to avoid the example's use of `npx` to avoid internet usage. The formatting fails silently if the `prettier` package is not installed. * docs: Remove redundant Claude formatting guidance This is now completed by Claude hooks. * docs: Remove redundant Claude lint directives The lint fix script also verifies lint rules. There is no need to run both scripts.
1 parent c2ceb99 commit 5b66f8e

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

.claude/settings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"hooks": {
3+
"PostToolUse": [
4+
{
5+
"matcher": "Edit|Write",
6+
"hooks": [
7+
{
8+
"type": "command",
9+
"command": "jq -r '.tool_input.file_path' | xargs ./node_modules/.bin/prettier --write"
10+
}
11+
]
12+
}
13+
]
14+
}
15+
}

CLAUDE.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,8 @@ Note: Console logs should be used sparingly. For verbose or development-specific
201201
**IMPORTANT**: Always run these commands after making code changes and before presenting work for review/commit:
202202

203203
```bash
204-
# Format JavaScript code
205-
make format
206-
207-
# Auto-fix linting errors
204+
# Auto-fix linting errors & verify linting passes
208205
make lint-js-fix
209-
210-
# Verify linting passes
211-
make lint-js
212206
```
213207

214208
These commands ensure code quality and prevent lint errors from blocking commits.

0 commit comments

Comments
 (0)