Back to Hooks

Format Python Files

Hooks post-tool 1,382

Automatically format Python files after any Edit operation using black formatter. This hook runs 'black' on any .py file that Claude modifies, ensuring consistent Python code formatting. Requires black to be installed ('pip install black'). The command includes error suppression (2>/dev/null || true) so it won't fail if black is not installed.

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

Content

JSON
{
"description": "Automatically format Python files after any Edit operation using black formatter..."
"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.