Back to Hooks

Format Javascript Files

Hooks post-tool 735

Automatically format JavaScript/TypeScript files after any Edit operation using prettier. This hook runs 'npx prettier --write' on any .js, .ts, .jsx, or .tsx file that Claude modifies, ensuring consistent code formatting. Uses npx so prettier doesn't need to be globally installed. Includes error suppression so it won't fail if prettier is not available.

Install Command
npx claude-code-templates@latest --hook post-tool/format-javascript-files
View on GitHub
claude-code — format-javascript-files

Content

JSON
{
"description": "Automatically format JavaScript/TypeScript files after any Edit operation using ..."
"hooks": {
"PostToolUse": [1 item]
}
}

Stack Builder

0 components

Your stack is empty

Browse components and click the + button to add them to your stack for easy installation.