Add Claude Code hook to auto-run rustfmt after edits
PostToolUse hook runs rustfmt on any .rs file after Edit/Write, ensuring Claude-generated Rust code is always properly formatted. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"hooks": {
|
||||
"PostToolUse": [
|
||||
{
|
||||
"matcher": "Edit|Write",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "FILE=$(jq -r '.tool_input.file_path'); if [[ \"$FILE\" == *.rs ]]; then rustfmt \"$FILE\" 2>/dev/null; fi"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user