Skip to content

commandCode quality

Remove Console Logs

Finds and removes leftover debug logging and prints while keeping the intentional logger calls and CLI output.

npx workspacetemplates add remove-console-logs --tool claude-code

Writes 1 file to .claude/commands/

.claude/commands/remove-console-logs.md14 lines · 1.2 KBFile
---
description: Finds and removes leftover debug logging and prints while keeping the intentional logger calls and CLI output.
argument-hint: "[folder, default whole project]"
---

Remove leftover debug output in: $ARGUMENTS (whole project if empty).

1. Search for debug output by language: console.log, console.debug, debugger, print(, pprint, var_dump, dd(, puts, fmt.Println, System.out.println, println!, dbg!, and commented-out copies. Skip node_modules, vendor and build folders.
2. Classify each hit. **Remove:** bare prints of variables, "here" or "test" markers, dumps of objects, commented-out logging. **Keep:** calls to the project's logger, output in files whose purpose is to print (CLI scripts, build tools), deliberate console.error in a catch, and test helpers.
3. Flag any hit that logs a token, password, email or full request body as a leak, even if you keep it.
4. Do not delete a line that has side effects inside the call, such as `console.log(i++)`; mention it instead.
5. Remove the confirmed ones, tidy now-unused imports and variables, then run the linter and tests.

First show a table of hits with file, line, the decision and the reason. Apply only after I say go. Finish with counts removed, kept and flagged.

What it does

Debug prints sneak into commits and end up in production logs, sometimes with data that should never be logged. This command finds them and removes the ones that were clearly for debugging.

It leaves alone anything that goes through your logger, command-line tools whose job is to print, and test output. Doubtful cases are listed for you instead of deleted.

Example

you › /remove-console-logs src/

agent › 38 hits: 29 remove, 7 keep (logger calls, scripts/seed.ts output), 2 questionable.
Leak risk: src/auth/session.ts:64 logs the full token.
Remove the 29 and fix the leak?

Questions

Will it delete my real logging?
Calls through your logger and files that exist to print output are kept. Anything doubtful goes in a list for you to decide.
Does it deal with secrets in logs?
It flags lines that print tokens, passwords or full request bodies, even in places it keeps.
  • Add Error Handling

    CommandCode quality

    Free
  • Add Logging

    CommandCode quality

    Free
  • Add Types

    CommandCode quality

    Free
  • Extract Function

    CommandCode quality

    Free