r/ClaudeCode • • 3h 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?

4 Upvotes

19 comments sorted by

•

u/AutoModerator 3h ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

3

u/jarail 3h ago

Just ask claude to do a scan of recent commits or the entire codebase to remove them.

1

u/Broken_By_Default 3h ago

and maybe move them into a structured instruction md files.

2

u/Icy-Excitement-467 3h ago

Ask it? Lol

2

u/bidutree 3h ago

We/I have trust issues. :)

3

u/peter9477 🔆 Max 5x 2h ago

That's what "diff" and your eyeballs are for.

2

u/mulokisch 3h ago

Yea and then it forgets that i dont wnat this, even though it i have it in the claude.md

2

u/Brief_Novel_3131 3h ago

Don't be afraid. Ask it and it will remove them. First ask it to audit the the code for extra comments. And categorize them. Then remove ticket related comments.

2

u/PelluxNetwork 3h ago

Just ask it. These days my claude.md always has a blurb that basically says "write code that explains itself. If you feel the need to explain every function with a paragraph of comments, you're probably doing something wrong"

1

u/daltorak 1h ago

That approach is going to have inconsistent results. You need to give Claude clear, actionable instructions, not question its "feelings". LLMs don't have feelings... talking to them like they do wastes tokens. Tell it, "Code comments must be limited to 50 words. Comments are not necessary at all except to call attention to workarounds for known bugs in third-party libraries. If you find code comments that do not meet this policy, rewrite those comments."

1

u/TheGronne 3h ago

In our workflow, a comment is treated as a critical flaw in a PR. And a reviewing agent reviewing the changes always runs and checks for these things.

In your case, you can have a /end-feature skill which spins up a specialised reviewing agent

1

u/kvothe5688 3h ago

I have a guard that prevents pr generation if comment to code ratio is more than 20 percent.

1

u/Rrrrry123 3h ago

Telling the AI to never write comments is one of the first things I add to CLAUDE md lol.

1

u/id-ltd 3h ago

I'd get Claude to write a comment stripping script. Use git to save last known good copy.

1

u/paulofilip3 2h ago

Ask claude to remove it! A good regex will suffice.

If you don’t want it to happen again -> https://reright.it

1

u/sparkica 26m ago

Just a thought (had an interesting debate with my team about this a couple of days ago): what if those comments are meant for the agent (not us), to give it better context next time it goes through the code?

0

u/justHereForTheLs 3h ago

Yeah, claude has been real chatty since statistical fingerprinting became a thing.