Goldilocks of Comments
Clean Code dogma taught us that a comment is often a confession of failure. The idea is seductive: if the code is expressive enough, any additional annotation is noise, a crutch for limping logic, or a legacy of laziness. This discipline forced us to name variables better and extract functions until the flow was as readable as prose. However, in that quest for aesthetic purity, we sometimes forget that even the cleanest code in the world remains silent regarding the project's scars. Code says what it does; the comment explains why it couldn't be done any other way.
Reality is pragmatic and time is finite. A well-placed comment is not a symptom of sloth, but an act of respect toward whoever comes next. It’s the note on the dinner plate in the fridge: it doesn’t question the other person's ability to cook; it simply saves them ten minutes of uncertainty.
Today, the emergence of AI and development agents elevates this "courtesy" to the category of critical infrastructure. Those comments we once feared maintaining due to the risk of them becoming obsolete have now found their best ally in AI. Agents are not only capable of drafting concise explanations in milliseconds, but they can also audit the coherence between text and logic, eliminating the maintenance cost that historically justified their eradication.
Beyond maintenance, comments have become the guardrails of automation. For an AI agent, a context comment is an embedded system prompt. It prevents an automated refactor from destroying a critical workaround due to an external library vulnerability or altering an execution order imposed by a database migration. In a workflow where AI generates code proposals at superhuman speeds, the comment is the clue that allows the human reviewer to validate intent without getting lost in the noise of the changes. It is the bridge of trust that accelerates the audit: if the agent explains why it took a shortcut, the human can decide whether to accept it in seconds.
The Goldilocks Guide to Modern Comments
For a comment to be useful in this new era of human-agent collaboration, it must avoid extremes. Neither absolute silence nor unnecessary verbosity.
-
Too Cold (The Obvious Comment)
// Increments i by one i++;Why it fails: It’s pure noise. It adds no semantics and doesn't help the AI; it only consumes space and attention.
-
Too Hot (The War Diary)
// I spent three hours trying to get this to work // with WebSockets but client X’s firewall, // which by the way uses an old version of Fortinet, // wouldn’t let the packets through. // In the end, I used polling because it was Friday // and we had to ship.Why it fails: Too much irrelevant narrative. It obscures technical data with anecdotes that don't help in the long run.
-
Just Right (The Golden Context)
// Using polling due to firewall restrictions at Client X (v2.3). // Check if they migrate to v2.4. // IMPORTANT: save() before dispatch() ensures ID integrity in the event.Why it hits the mark: It expresses a technical or business constraint that the code cannot communicate on its own. It provides a clear guardrail for the AI and immediate justification for the human.
exit(0);