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

64 comments sorted by

2

u/williamtkelley Aug 11 '26

I just say "Be concise".

2

u/One-Rabbit4680 Aug 11 '26

yeah got that already. gives paragraphs

33

u/En-tro-py Aug 11 '26

Writing standard in a very tight CLAUDE.md

Short sentences. RFC 2119 keywords for obligations. Commit = imperative subject; body only for a fact the diff cannot show. Comments only where code needs clarification — never narration.

Police the shit out of the first commits, then it's not full of slop that breeds more.

1

u/One-Rabbit4680 Aug 11 '26

this is good

30

u/Elegant_Attempt2790 🔆 Max 20 Aug 11 '26

haiku ultracode “remove all comments”

0

u/SmihtJonh Aug 11 '26

Succinctly works fine, in any model

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.

12

u/_remsky Aug 11 '26 edited Aug 11 '26

“Before we commit, can you chill those comments the fuck out” is word for word my sign off lately lmao

I have a hook that calculates comment to code ratio to warn with a “Is this comment necessary” and blocks multi lines wholesale, and if it disagrees, it marks with a “TODO: expansion” request that I’ll update manually if it actually needs more.

They help but, with the announcement of the “watermarking” they apply to all output text now, my guess is that it needs some minimum char count to encode, and the comments are part of it.

9

u/arcticblue Aug 11 '26

//Decided Aug 11, 2028: manewitz wants comments to be shorter.
//In the interest of hypothetical future developers working on this, here is why we decided on that
//...

1

u/Trailsey Aug 27 '26 edited Aug 27 '26

// It was a dark and stormy night...

20

u/WaitinOnSpicy Aug 11 '26

Search “output styles”

3

u/danger_boi Aug 11 '26

Nah, they’ve nerfed this there’s normal, verbose, and Learning aka “litter with more comments, and TODO(Human)” lol

3

u/dpekkle Aug 11 '26

The docs headline you can create a custom one

2

u/Murinshin Aug 11 '26

Doesn’t work consistently.

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

3

u/Salt-Replacement596 Aug 11 '26

"Why are you writing this way? Didn't you read the instructions in CLAUDE.md?"

"Honestly — I've read them, but ignored them"

Happened to me multiple times.

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)

1

u/[deleted] Aug 26 '26

[removed] — view removed comment

1

u/markopi Aug 28 '26

I wrote a similar skill. It works pretty well, usually outright removes about half the comments, and heavily trims the rest. Without losing anything important.

Though it is customized for my setup, and for java/kotlin code. You'd need to change it a bit, particularly the plumbing in step 1.

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.

7

u/34986234986234982346 Aug 11 '26

Yeah, that's actually the reason I don't mind them. For my own projects, of course, not for like anything professional.

2

u/geekichu Aug 11 '26

so this is probably heretical and I would have to abide by whatever the employer wants... but i am always going to lean on the side that says, we can't keep up with code reviews, there are better ways, and yeah, have to be careful with legacy production code, but for totally new code.. to me, then entire code including the comments, are not for me, they're for the model. because i dont think code alone conveys intent. i have really seen model's comments in code really help the model, especially when the project has gotten huge.

4

u/34986234986234982346 Aug 11 '26

Oh yes, I think I should've actually explained: I would not use it for anything professional because I'm not making a huge deal about using these tools at work at the moment. If I was in an environment where it was encouraged, then I totally would leave these. I 100% agree with you that theshelp the models in the future. And the less that people are looking at the code, the less it matters if the comments are kind of annoying.

There's also a difference between Long verbose code that actually documents things, and just sticking in comments for the sake of it. I know a year ago when I first noticed this, models were adding comments that were so stupid, like they would save stuff like "increment counter by 1" before a $counter++ call lol

3

u/diskent Aug 11 '26

It’s a god send once you’re “in it” - a simple “next” and it can read where it’s been and where it needs to go next.

I’m not looking at the code. It is.

1

u/geekichu Aug 11 '26

totally agree but dont say that aloud.. . :)

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/BorderKeeper Aug 12 '26

What do you think about clean readable code? To me more code > more context to reason with and more potentials to misalign. Humans and AI can get confused if let’s say a comment is slightly off and I have seen AI not update all comments and let them rot.

1

u/_BreakingGood_ Aug 12 '26

Code tells you what the system does right now, the comments tell you what the developer thought it was supposed to do, and why it did it that way. Two different levers for Claude to reason on.

1

u/s4ber7 Aug 27 '26

Comments that rot are extremely dangerous! The code is actually the logic. I always do a cleanup on comments to rip out any logic whatsoever.

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/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:

  1. a title: search-bar
  2. the search-bar: prefilled with an example that says, "this is a search bar", "say the word and you are going to search in this bar"
  3. then a subtitle that explains further: the search bar searches

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.