Claude Code HookPre-Tool15 installs

Console Log Cleaner

Warns about console.log statements when editing files on production branches (main/master). Helps prevent debug code from reaching production.

Install with the Claude Code Templates CLI
$ npx claude-code-templates@latest --hook="pre-tool/console-log-cleaner" --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": "Warns about console.log statements when editing files on production branches (main/master). Helps prevent debug code from reaching production.",

"hooks": {

"PreToolUse": [

{

"matcher": "Edit",

"hooks": [

{

"type": "command",

"command": "if git rev-parse --git-dir >/dev/null 2>&1 && [[ -n \"$CLAUDE_TOOL_FILE_PATH\" ]]; then BRANCH=$(git branch --show-current 2>/dev/null); if [[ \"$BRANCH\" =~ ^(main|master|production|prod)$ ]]; then EXT=\"${CLAUDE_TOOL_FILE_PATH##*.}\"; if [[ \"$EXT\" =~ ^(js|ts|jsx|tsx|mjs|cjs)$ ]]; then LOGS=$(grep -n 'console\\.' \"$CLAUDE_TOOL_FILE_PATH\" 2>/dev/null); if [[ -n \"$LOGS\" ]]; then echo \"⚠️ WARNING: console statements found on '$BRANCH' branch:\"; echo \"$LOGS\" | head -5; COUNT=$(echo \"$LOGS\" | wc -l); if [[ $COUNT -gt 5 ]]; then echo \"... and $((COUNT-5)) more\"; fi; echo \"Consider removing debug statements before merging.\"; fi; fi; fi; fi"

}

]

}

]

}

}

Type
Hook
Category
Pre-Tool
Installs
15
Source
GitHub ↗

Related Claude Code Hooks

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 →
HookPre-Tool

Backup Before Edit

Create automatic backup of files before any Edit operation for safety. This hook creates a timestamped backup copy (filename.backup.timestamp) of any existing file before Claude modifies it. Provides a safety net to recover previous versions if needed. Only backs up existing files, includes error suppression to handle edge cases gracefully.

214 installsView →
HookPre-Tool

Notify Before Bash

Show notification before any Bash command execution for security awareness. This hook displays a simple echo message '🔔 About to run bash command...' before Claude executes any bash command, giving you visibility into when system commands are about to run. Useful for monitoring and auditing command execution.

27 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 →
HookDevelopment Tools

Smart Formatting

Smart code formatting based on file type. Automatically formats code using Prettier, Black, gofmt, rustfmt, and other language-specific formatters.

326 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.