Claude Code HookPost-Tool153 installs

Format Python Files

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 with the Claude Code Templates CLI
$ npx claude-code-templates@latest --hook="post-tool/format-python-files" --yes

Requires Claude Code. The command adds this hook to your project's .claudedirectory — nothing runs on ToolZip's servers.

What's inside this hook

Component source

{

"description": "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.",

"hooks": {

"PostToolUse": [

{

"matcher": "Edit",

"hooks": [

{

"type": "command",

"command": "if [[ \"$CLAUDE_TOOL_FILE_PATH\" == *.py ]]; then black \"$CLAUDE_TOOL_FILE_PATH\" 2>/dev/null || true; fi"

}

]

}

]

}

}

Type
Hook
Category
Post-Tool
Installs
153
Source
GitHub ↗

Related Claude Code Hooks

HookPost-Tool

Run Tests After Changes

Automatically run quick tests after code modifications to ensure nothing breaks. This hook executes 'npm run test:quick' silently after any Edit operation and provides feedback on test status. Helps catch breaking changes immediately during development. Only runs if package.json exists and the test:quick script is available.

237 installsView →
HookPost-Tool

Format Javascript Files

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.

90 installsView →
HookPost-Tool

Git Add Changes

Automatically stage changes in git after file modifications for easier commit workflow. This hook runs 'git add' on any file that Claude edits or writes, automatically staging changes for the next commit. Includes error suppression so it won't fail in non-git repositories. Helps streamline the development workflow by preparing files for commit.

80 installsView →
HookAutomation

Simple Notifications

Send desktop notifications when Claude Code finishes working or needs user input. Works on macOS and Linux systems.

1k installsView →
HookGit Workflow

Smart Commit

Intelligent git commit creation with automatic message generation and validation. Creates meaningful commits based on file changes.

398 installsView →
HookPre-Tool

Update Search Year

Automatically adds current year to WebSearch queries when no year is specified. This hook intercepts WebSearch tool usage and appends the current year to queries that don't already contain a year, ensuring search results are current and relevant.

361 installsView →

Catalog data and component content are sourced from the open-source davila7/claude-code-templates project (MIT license). ToolZip curates the listing and writes original descriptions; every component links back to its original source. Claude Code is a product of Anthropic. ToolZip is an independent catalog and is not affiliated with or endorsed by Anthropic.