| name | clean-code-comments |
| description | Use when deciding whether, how, or where to write code comments — applies Clean Code comment principles |
Clean Code: Comments
Based on Robert C. Martin's Clean Code, Chapter 4: Comments.
When to Use This Skill
Trigger on:
- Code review flagging missing or excessive comments
- "Should I add a comment here?" questions
- Debates about documentation style
- Reviewing comment quality in a PR
Core Principle
Comments are always failures. We must have them because we cannot always figure out how to express ourselves without them, but their use is not a cause for celebration.
Good Comments (When to Keep/Write)
1. Legal Comments
Copyright and license notices are necessary.
2. Informative Comments
A short clarification that genuinely cannot be expressed in code:
timestamp = parse_timestamp(raw)
3. Explanation of Intent
Why a decision was made, not what the code does:
for attempt in range(3):
result = call_service()
4. Clarification
Translating a confusing API or library into something readable.
5. Warning of Consequences
6. TODO Comments
Temporary reminders for future work. Include issue/ticket reference.
7. Amplification
Emphasizing the importance of something that might look like a mistake.
Bad Comments (Remove These)
1. Mumbling
Comments that say nothing useful: // Process data
2. Redundant Comments
user.name = new_name
3. Mandated Comments
Cruft like // Constructor above every constructor. The method name says it.
4. Journal Comments
// Updated 2024-01-15 by Alice -- git blame does this better.
5. Noise Comments
name = "Alice"
6. Commented-Out Code
Delete it. Git remembers.
7. Non-local Information
A comment that documents something far away from the code it sits above.
8. Too Much Information
Long historical narratives, RFC excerpts, or protocol specs in comments.
Quick Checklist
Source
Distilled from Clean Code by Robert C. Martin, Chapter 4: Comments.