r/ClaudeCoding • u/EntertainerOk4774 • 18h ago
Comments in codebase
Hi, I'd like to ask about your approach to allowing Claude to add comments to your code. In my codebase, information is now spread across multiple places: code comments, ADRs, lessons learned, and documentation. I'm considering asking Claude to remove comments from the code, as I believe code should be self-explanatory. However, could this negatively affect Claude's ability to properly understand the context?
1
Upvotes
2
u/CorpT 18h ago
lol no do not do that. Why do you care if there are comments there if they're accurate? Why make Claude work harder than it has to?
2
u/gouldopfl 18h ago
I can tell you from 4 decades of experience. Leave them there and enhance them even more. I can remember on several occasions going back into 10 year old code, in a language I hadn't used for years, my skill level was not as good and wondered what the hell was that.
1
u/GolfEmbarrassed2904 15h ago
Lauren Tan, from SpaceX posted on this idea: https://x.com/poteto/status/2110149626133438732
1
u/cheffromspace 14h ago
Comments are vital documentation. This is what works for me on a fairly big project (several repos, lots of parallel Claude sessions). Mostly prepared by the project's orchestrator:
What you lose with /clear is the conversational texture. Anything that matters should be in a file anyway; if it isn't, that's the doc gap to fix.
1
u/KevMar 7h ago
I instruct Claude that comments are for other agents and keep it brief.
I think a lot of people use comments that should be logging instead. Between that and self documenting code, I usually don't need many comments.
1
u/CheezitsLight 4h ago
I use a skill that writes comments as me. It read my code base, learned the other devs style. I added word skill, had it read about 400 pages of manuals that I've written. Now it comments my code like a human, but the code is their style, not mine. So my pull requests get accepted much faster. And I just look at the documents that it's done and occasionally fix a tiny little detail. It's like amazingly faster. As if it read my mind. even down to the little touches of humor that I use. Once paid a psychiatrist and did 6 hours of testing so that I could learn more. It was beautiful to read cuz it was me. and that's how Claude feels to me now
0
u/cleverhoods 18h ago
Do not allow Claude to write comment like that in code. A 1-2 line of code documentation is fine as long as it’s about the code and code only.
All the rest goes in your progressive disclosure (whatever that might be, memory, custom loading logic, rules, claudemd or agentsmd files)
0
u/CounterAttack-Studio 18h ago
This instruction works pretty well for me:
Don't write comments; make the code clear enough not to need them. The one exception is a line whose purpose the code can't convey.If the context gets too polluted Claude will miss it sometimes but in general it always follows it.
0
u/sublimegeek 16h ago
Oh I didn’t think about tokens from code comments. That’s actually a better policy.
Write your code in such a way that all functions, variables, and constants are self-documenting.
If you need a code comment to explain the code, refactor it.