Snippet
Copy and paste this prompt into a coding agent. Replace the part in angle brackets with your whole codebase or the section you want cleaned:
text
Take a look at every code comment in <my codebase | this section of the code>.
Categorise each comment as:
- Tautology: simply repeats what is already visible from the code
- Excuse: many comments allow the agent to get away with a hacky implementation, which then gets propagated through the code
- Stale: references code or implementation information that is no longer relevant
- Decision Record: documents an important, non-obvious decision about the code
For each comment, take this action:
- Tautology/Stale: delete the comment
- Excuse: delete the comment and file an issue to fix the hacky implementation
- Decision Record: move it into an ADR
Once this is done:
- Create a lint rule banning comments for <my codebase | this section of the code>
- Take a ratchet approach, assuming not all comments will be deleted this PR
- Create a /delete-comment skill in this repository so we can repeat this process later
- Estimate for me how many lines of code we'll shed by deleting all commentsHow to Use
- Copy the prompt in the box above.
- Replace
<my codebase | this section of the code>in both places with your scope, such as "the src/billing directory". - Paste it into a coding agent that can edit files and open issues, such as Claude Code.
- Review the issues it files and the ADRs it writes before you merge.
How It Works
- Four kinds of comment - Each comment repeats the code, excuses a hack, is out of date, or records a decision. Only decisions are worth keeping.
- Hacks become issues - Deleting an excuse comment removes the cover for a hack, and the filed issue keeps the fix on the list.
- Decisions move to ADRs - Architecture Decision Records keep the reasoning in one place, where it does not go stale beside the code.
- Ratchet lint rule - Existing comments are allowed for now, but the count can only go down, so new comments cannot creep back in.
- Repeatable - The /delete-comment skill lets you run the same cleanup again later.
Source: Matt Pocock on X.