Auto-Format on Save
Auto-Format on Save triggers after every Write or Edit tool invocation and runs Prettier on the affected file. This ensures all code Claude produces matches your project's formatting rules without requiring Claude to remember to format. It respects your .prettierrc and .prettierignore configurations, handles TypeScript, JavaScript, JSON, CSS, Markdown, and other supported file types. The hook runs silently on success and only reports when formatting changes are applied.
Hook Code
Add this hook to your Claude Code settings or .claude/settings.json to activate.
Terminal Preview
About Auto-Format on Save
Claude Code hooks let you run custom shell commands automatically in response to specific events during Claude's operation. Auto-Format on Save is a Post-Tool hook at the Beginner level that automates tasks at key moments in your development workflow, reducing manual steps and enforcing consistency across your team.
Related Hooks
Post-Edit Test Runner
Automatically run relevant tests after Claude edits source files to catch regressions immediately.
TypeScript Type Checker
Run TypeScript type checking after file edits to catch type errors before they accumulate.
Auto Changelog Appender
Automatically extract commit messages and append structured entries to CHANGELOG.md after each commit.