跪拜 Guibai
← All articles
Coding Standards · Agent · Source Code Reading

Don't Comment Bad Code — Rewrite It

By mCell ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Over-commenting obscures the real problem: unreadable code. Treating explanatory comments as a design smell forces the harder, higher-value work of simplification and renaming, which pays off every time someone — including an AI agent — reads the code later.

Summary

A principle drawn from *The Mythical Man-Month* and hardened by daily practice: comments exist to capture intent and rationale — the "why" — not to narrate what the code is already doing. When a block of logic feels too obscure to stand on its own, the correct fix is to refactor it into self-explanatory form, not to staple a paragraph of prose above it.

The rule has been codified into an AGETNS.md file, treating it as a non-negotiable baseline for AI-assisted and human-authored code alike. If a developer reaches for a comment to clarify mechanics, that reach is itself the bug.

Takeaways
Comments should explain why a decision was made, not what the code does.
A comment describing mechanics is a cue to rewrite the code until it no longer needs the explanation.
The principle is enforced as a rule in AGETNS.md for both human and AI-authored contributions.
Conclusions

Codifying this as an explicit rule for AI agents is a pragmatic hedge against the verbosity LLMs default to when generating code — they will happily produce a correct but unreadable block and then narrate it in comments, which satisfies neither goal.

The stance treats explanatory comments as a design smell rather than a documentation aid, which shifts the developer's job from annotator to simplifier.

Concepts & terms
AGETNS.md
A rules file (analogous to AGENTS.md or similar conventions) that defines behavioral constraints for AI coding agents, ensuring generated code adheres to project-specific standards like self-documenting logic.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗