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>
16 lines
312 B
JSON
16 lines
312 B
JSON
{
|
|
"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"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|