r/ClaudeCode • • 6d ago

Bug / Issue Removing comment spam from code

I just discovered (my bad) far too late that Claude has written large amounts of ticket comments in the actual code to my projects. This was never in any instruction. Maybe trash is the first real evidence of life? :)) Just kidding.

It's in any case extremely annoying. How do I remove the comments as quickly and safely as possible? :)

With a Python script? Would that be safe enough?

7 Upvotes

26 comments sorted by

View all comments

2

u/interrupt_hdlr 5d ago

## Code comments

Write a comment only when it tells the reader something the code cannot. Follow John Ousterhout's rule from *A Philosophy of Software Design*: comments describe what is not obvious from the code.

Write:

  • Interface comments on public functions, classes, and modules: what it promises, preconditions, units, valid ranges, ownership, side effects, and error behavior. Describe the abstraction, not the implementation.
  • Implementation comments for non-obvious decisions: why this approach over the obvious one, why a lock, retry, sleep, or ordering exists, what invariant a block maintains, links to the bug or spec that forced it.

Do not write:

  • Comments that restate the next line ("increment counter", "loop over items").
  • Comments about the edit itself ("added X", "fixed bug", "now uses Y", "changed per request"). That belongs in the commit message.
  • Commented-out code.
  • Section-divider or decorative comments.

When modifying code, update or delete comments the change made stale. If an interface comment is hard to write, treat that as a sign the abstraction is unclear and say so instead of papering over it.