← Back to catalog
HookQuality↓ 76

Console Log Cleaner

Warns about console.log when editing files on production branches.

Installation
npx claude-code-templates@latest --hook pre-tool/console-log-cleaner --yes

This hook fires on the PreToolUse event, before an Edit change. It checks which branch the repository is on.

If the branch is main, master, production or prod and the file is JavaScript or TypeScript, it looks for console calls and warns how many there are. The goal is to keep debug code from reaching production.

When to use

  • When you want to avoid forgotten console.log on production branches.
  • When the team works directly on main and needs a reminder.

How to use

After installing, it inspects every edit on the production branch. When you see the warning, remove the debug calls before moving on.