0
Auto-format after edits with a PostToolUse hook
Run prettier/ruff/gofmt automatically after Edit/Write tools so Claude never leaves unformatted files.
The problem
Claude writes correct logic but skips the formatter, creating noisy diffs and CI failures.
The hack
Add a PostToolUse hook matched to Edit|Write that formats the touched file via your project formatter.
Why it works
Deterministic post-edit formatting beats reminding Claude in CLAUDE.md for the hundredth time.
Setup
1. Identify the one formatter command your repo already uses. 2. Add a PostToolUse hook in `.claude/settings.json` matching Edit and Write. 3. Pass the edited path from the hook JSON into the formatter. 4. Make a small edit in a session and confirm formatting runs without a prompt.
Additional details
Keep the hook fast; slow hooks show up in /doctor diagnostics.
Discussion
No comments yet. Be the first to say whether this worked for you.