Smart Formatting
Smart code formatting based on file type. Automatically formats code using Prettier, Black, gofmt, rustfmt, and other language-specific formatters.
$ npx claude-code-templates@latest --hook="development-tools/smart-formatting" --yesRequires 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": "Smart code formatting based on file type. Automatically formats code using Prettier, Black, gofmt, rustfmt, and other language-specific formatters.",
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command": "if [[ \"$CLAUDE_TOOL_FILE_PATH\" == .js || \"$CLAUDE_TOOL_FILE_PATH\" == .ts || \"$CLAUDE_TOOL_FILE_PATH\" == .jsx || \"$CLAUDE_TOOL_FILE_PATH\" == .tsx || \"$CLAUDE_TOOL_FILE_PATH\" == .json || \"$CLAUDE_TOOL_FILE_PATH\" == .css || \"$CLAUDE_TOOL_FILE_PATH\" == .html ]]; then npx prettier --write \"$CLAUDE_TOOL_FILE_PATH\" 2>/dev/null || true; elif [[ \"$CLAUDE_TOOL_FILE_PATH\" == .py ]]; then black \"$CLAUDE_TOOL_FILE_PATH\" 2>/dev/null || true; elif [[ \"$CLAUDE_TOOL_FILE_PATH\" == .go ]]; then gofmt -w \"$CLAUDE_TOOL_FILE_PATH\" 2>/dev/null || true; elif [[ \"$CLAUDE_TOOL_FILE_PATH\" == .rs ]]; then rustfmt \"$CLAUDE_TOOL_FILE_PATH\" 2>/dev/null || true; elif [[ \"$CLAUDE_TOOL_FILE_PATH\" == *.php ]]; then php-cs-fixer fix \"$CLAUDE_TOOL_FILE_PATH\" 2>/dev/null || true; fi"
}
]
}
]
}
}
Related Claude Code Hooks
Lint On Save
Automatically run linting tools after file modifications. Supports ESLint for JavaScript/TypeScript, Pylint for Python, and RuboCop for Ruby.
Nextjs Code Quality Enforcer
Enforce Next.js best practices, proper file structure, component patterns, and TypeScript usage with automated code reviews and suggestions. Validates Next.js App Router conventions, Server/Client component patterns, proper imports, and TypeScript usage. Provides real-time feedback on code quality and adherence to Next.js best practices.
Change Tracker
Track file changes in a simple log. Records which files were modified and when for easy tracking of Claude Code activity.
File Backup
Automatically backup files before editing. Creates timestamped backups in a .backups directory when files are modified.
Command Logger
Log all Claude Code commands to a file for audit and debugging purposes. Simple logging that records tool usage with timestamps.
Worktree Ghostty
Worktree Ghostty Layout. Opens a 3-panel Ghostty layout when creating worktrees: Claude Code (left) | lazygit (top-right) / yazi (bottom-right). Creates worktrees in a sibling directory (../worktrees/<repo>/<name>/) and cleans up on removal. macOS only. Requires: jq, Ghostty terminal, lazygit, yazi. Ghostty keybindings required: super+d = new_split:right, super+shift+d = new_split:down.
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.