I set up this hook once and never format manually again. Every time Claude writes or edits a file, the hook runs Prettier automatically and the saved file already matches your project's style.
Add this to your settings.json:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "prettier --write \"$CLAUDE_TOOL_INPUT_PATH\""
}
]
}
]
}
}
Swap prettier --write for eslint --fix if your project uses ESLint instead. The $CLAUDE_TOOL_INPUT_PATH variable is set by Claude Code to the path of the file just touched, so the command always targets the right file.