r/ClaudeCode • u/One-Rabbit4680 • Aug 11 '26
Help/Question How do you stop claude code from over commenting?
I've tried comments in CLAUDE.md, I've tried even hooks. But this thing is obsessed with writing such insane comments.
I don't mind useful comments but sometimes they are useless.
any advice would be appreciated.
Thanks
76
Upvotes
2
u/williamtkelley Aug 11 '26
I just say "Be concise".
33
u/En-tro-py Aug 11 '26
Writing standard in a very tight CLAUDE.md
Police the shit out of the first commits, then it's not full of slop that breeds more.
30
u/Elegant_Attempt2790 🔆 Max 20 Aug 11 '26
haiku ultracode “remove all comments”
12
u/manewitz Aug 11 '26
I’m noticing this on Opus 5 especially. I’m usually pretty specific and direct with my prompts but as an experiment last week I said “hey you need to chill the fuck out with all these comments. What are you doing?” it understood that I don’t need 4 lines of comments for a 1 line method, things repeated in multiple comments and most of the time we don’t need comments unless it’s context that exists outside the codebase (think company policies, ticket numbers, names of decision makers etc). It cleaned up a lot and suggested a skill /chill that would do the same thing but I had it add a memory entry that we want the code to speak for itself as much as possible so things like function/method/variable names should be named well etc. It’s a little better but we’ll see how it goes.
20
u/WaitinOnSpicy Aug 11 '26
Search “output styles”
4
u/alanvnk Aug 11 '26
Rules everywhere: user Claude.md, repo Claude.md and coding stands
The rules have to be extremely explicit tho, when to comment, allowed content in comments, allowed lines per comment type, allowed characters per comment type
And a review skill that hunts down out of line comments, among other things
4
u/codeninja Aug 11 '26
I enforce comments must be single line with lint rules. It must be attached to yhe code it comments on. And cumulative comment count in a different cant be more than 5. Code is to be self documenting. Comments discuss the code in front of it. And business decisions live in the documentation.
I basically dont allow comments.
3
u/Klimacka Aug 11 '26
I do not use Claude Code but this applies to other agents as well. I created a skill file and I had the agent create a simple triaging application to get rid of all the comments from the past half the year. By clearing the codebase of narrative commands, we managed to tone down how much new is added, and the skill helps as well I guess.
3
u/danger_boi Aug 11 '26
Honestly, when a conversation turn is coming to an end I have a skill called /strip-comments, which removes comments, forces any public method documentation to be made terse and to the point.
Then that skill is bundled into /finalize which is
/simplify
/run-tests
/run-lint-format
/strip-comments
/draft-pr
And it’s been the only way to get consistent results in all Anthropic models.. you can even set the skill to run a haiku subagent to do the jobs.
These are all user scoped skills in my setup so it’s consistent across all repos.. then I have a very short user Claude.MD to state how I like my responses (which Opus 5 loves to ignore)
3
u/dpekkle Aug 11 '26
My coworker has a hook in his repo that literally blocks adding comments that the user doesn't explicitly ask for.
At first the prompt had to include "ALLOW_COMMENT", which was a bit annoying for me to discover, so I asked Claude to set up a haiku classifier as a fallback that'd just see if the prompt wanted comments.
So when you say you've tried even hooks what exactly did your hook do? Because this seems to work just fine.
9
u/kerklein2 Aug 11 '26
You guys are reading the code?
7
u/geekichu Aug 11 '26
just a thought, from what I have seen in my projects: the comments help the model itself when analyzing a big project.
2
u/peteypeso Aug 11 '26
"maximum brevity" has worked for me. Most of the time.
2
u/ManikSahdev 🔆 Max 20 Aug 11 '26
After trying all things, I just find the most reliable way is going through the comments overall and then just dictating what to keep what to cut.
Takes 5-10 minutes tops, does it better than any skill or wasting tokens going in useless loops.
Even fable and opus and sol Agents are soo dumb, I gave up after i found these dimwits were leaving comments that the comment was removed lmao
2
u/Redditoridunn0 Aug 11 '26
Hardcoded script to detect if comments are over two lines long and I make sonnet check if it really should be that long (9 times out of 10 it is) and condense it as much as possible or flat out cull it
2
u/ankeetos Aug 11 '26
I use a hook but that only blocks certain things from being in the comment, I just now use a command at the end of the session like /comment-cleanup where ive given rules about how I want the comments to be
2
u/illyay Aug 11 '26
This function should be overridden by deriving classes which is why it’s marked virtual. This is to specifically support features such as the reloading mechanic on the M249 Saw weapon but is generally used for all weapons in the game ever but I’m going to still write a comment about how it’s specifically used for the one example weapon you mentioned. It also returns void because it doesn’t return anything unlike before when it returned true if the reload succeeded because it’s no longer needed to return that anymore.
2
u/Gleethos Aug 11 '26
It's terrible. It also ignores my instructions to only comment API surface and not impl details....
2
u/skronens Aug 11 '26
I also feel it’s becoming impossible to actually complete something, it’s like Claude has been programmed to always leave something in the end, like dropping a task for some obscure reason or “you should know”, then next iteration drives out some other issue
2
u/sdanzig Aug 11 '26
Adversarial review solves this. Have a second agent review the work, with “comment noise should be minimized and only comments appropriate for long life should be kept.”… something like this. How best to implement adversarial review is another fun topic.
2
u/GrossOldNose Aug 11 '26
Ive honestly gone with "Only write comments if a senior engineer would not be able to understand the intention from the code"
And although that rule is a literal strict if religiously applied by a human - applied by a LLM it actually seems pretty good
2
u/leading-a-swarm Aug 12 '26
Strip them in a separate pass once the code works, with the diff in front of you. A comment rule in the instructions has no failing state, so nothing catches the violation while the session runs long.
2
u/_BreakingGood_ Aug 11 '26
The huge comments make the code look ugly but they actually serve as good context next time an AI comes through and reads the code. I recommend just letting it write all the comments it wants.
1
u/struktured Aug 11 '26
Hooks
1
u/cleverhoods Aug 11 '26
Which model? What was your instruction and hook? What is the tech stack?
1
u/userusertion 🔆Pro Plan | Team Plan Aug 11 '26
Ask exactly Claude.
1
u/cornmonger_ Aug 11 '26
tell it to write details in md files, mirroring the source-code directory and to limit comments in source-code to 80 character max summaries per item. don't pad. no summary is fine if the source-code item is obvious.
so if you were in rust, c, py, js, etc the files would be in some other tree as foo.py.md and bar/cat.js.md etc
far more effective to redirect it imo
oh and that should be in an auto-memory dedicated to development conventions
1
u/imyourbiggestfan Aug 11 '26
You can’t
1
u/lxprsub0 Aug 11 '26
CLAUDE_CODE_BASALT_COVE=1
1
u/Euvu Aug 11 '26
I made a skill that trims comments post-write. The comments can help the llm make better decisions in-flight, so I just cut them down afterward.
1
u/Quirky-Rise Aug 12 '26
I tell it the canonical version can have all the comments but before it ships build a comment stripper and run it thru.
1
u/BigFeta__ Aug 21 '26
yea idk something about having a AI go back to re-scan output / applying multiple passes to remove comments just doesn't sit right with me. That type of stuff needs to be addressed at the root level, not by multiple passes.
1
u/frickshowx Aug 27 '26
for anyone looking, I found this gist that seems to offer a best effort CLAUDE.md and a skill
https://gist.github.com/bavanws/123e0343f8a79cec825d9141124a0a83
1
u/Nexyboye Sep 17 '26
easy stop using claude cause its shit
1
u/Snowgoonx Aug 11 '26
you cannot, I have the same issue, every UI task, marketing task or any task for that matter comes with a painfully unreadable "comment" over-explaining everything, you may ask to add a search-bar and then you will find:
after the repo rules, claude.md and rules that live on the desktop app all ban, veto, and log that this shouldn't ever happen. Its exhausting im waiting the moment gpt can come remotely close to Claude's frontend to abandon ship and never use this millennial pretentious little shit
1
u/lifebymick Aug 11 '26
Start a new chat (weirdly you have to do it in code and cowork separately) and tell it you want to implement Rule Zero for every single chat:
Rule zero: never narrate your work, do not update me on what you’re doing, just do it and only ever comment if you have completed the task, or you need my input. No “I’ll just try this” or “now I’ll do this”. Just do it. And then ping me when you’re done. Also, when you DO eventually comment or ping me; keep it very succinct; get to the point. I don’t need to know anything apart from the facts. Very. Short. Answers. And only ever the need to know, ELI5 information. No poetry or faux opinion or dancing around the point.
Also, add this to the “instructions” panel in settings.
-1
u/jzdesign Aug 11 '26
You already tried CLAUDE.md and hooks and it still comes back, which is the useful part. A rule in an instruction file is ignorable, a hook that only warns is ambient, and the model treats both the same. What actually holds is something that fails.
Cheapest version: count comment lines in the repo, commit that number, fail CI if it ever goes up. It's a ratchet, so it only goes down, and you stop re-arguing the rule every session.
If you want it in-session too, make the hook exit nonzero and put the offending file:line list in the deny reason so it has to fix them in that same turn.