← Back to catalog
HookQuality↓ 1,345

Smart Formatting

Formats code automatically after each edit, picking the right formatter per language.

Installation
npx claude-code-templates@latest --hook development-tools/smart-formatting --yes

This hook fires on the PostToolUse event, right after an Edit or MultiEdit change. It detects the language from the file extension.

It applies Prettier to JS, TS, JSON, CSS and HTML, Black to Python, gofmt to Go, rustfmt to Rust and php-cs-fixer to PHP. The file ends up formatted to the language standard, with no manual step.

When to use

  • When you want consistent formatting across many file types.
  • When the team mixes languages and each one has its own formatter.

How to use

After installing, it formats on its own after each edit. Keep the matching formatters installed so every language is covered.