Coding agents explain every line they write. Those comments cost tokens on every read, go stale and make bad patterns look intended.
This article gives you one rule for AGENTS.md, shows which comments survive it, and how to clean up the ones already in your codebase.
Who it’s for
For developers whose code needs subtitles. And the AI writing them.
The problem
Agents add a paragraph to explain a simple check:
/* * Validate the email address before submitting the form. * If the address is invalid, show a validation error to the user * and return early to prevent the form from being submitted. */function handle(e: string) { if (!isValidEmail(e)) { setError('Enter a valid email address.'); return; } submit(e);}Why it hurts
- Tokens. The comment is longer than the function, and the agent reads it again each time it loads the file.
- Hidden bad names. The comment explains what
handle(e)does, so nobody renames it. The name stays vague everywhere it is called. - False intent. A comment that explains a bad pattern makes it look intended, and the agent copies it.
- Staleness. Code changes, comments don't. The next agent trusts the comment over the code.
- Noise. The one comment that matters gets buried.
The fix
Add one rule to AGENTS.md:
- No comments unless necessary. Make the code clearer instead.Comments that stay explain a reason the code can't express, like a workaround or a platform quirk:
// The backend returns 200 with an empty body on expired sessions instead of 401.if (response.ok && !(await response.text())) { return redirectToLogin();}Then ask the agent to apply the rule to the codebase. It removes every comment that doesn't carry a reason, and makes the code clearer where a comment was explaining it.
Before & after
A stagger delay from this blog's home page.
/* * Returns the animation delay for a topic. * The first topic waits 50 ms, then each topic * starts 50 ms after the previous one. */function calc(i: number) { return 0.05 + 0.05 * i;}| Before | After |
|---|---|
A comment explains what the code does | The names explain it |
A vague function name like calc(i) | A name that says what it returns |
Two magic 0.05s with different meanings | A named constant for each |
Sum up
By making the code clearer and declaring intent through names, you remove the need for most comments. The agent reads fewer tokens, copies clearer patterns and has nothing stale to trust. The comments that remain explain a reason the code can't, so they get read.




