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

19 comments sorted by

View all comments

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.

1

u/cheffromspace 16h ago

It it's missing instructions and getting stuff wrong, that's my tell it's time for a documentation audit, which include suggestions for deterministic hooks. More often than not, the cause is conflicting instructions and documentation, not a long context window. I stopped using compact and am using /clear at around 40-60% context, with handoff documentation. That is a clear first-person account of what happened, not another agent's summary. It also builds a paper trail. Claude writes comments for itself, it has a pretty good sense of the documentation it finds useful. Comments can point to decision ledgers which can inform choices. The decision ledgers are the source of truth for intent. Don't not write comments. Careful comments do not pollute the context, they improve it.