| name | documentation-guidelines |
| description | Documentation best practices for code comments, JSDoc, READMEs, and API docs. Explains when to comment and when not to. Auto-loaded when writing documentation. |
| category | guideline |
| user-invocable | false |
Documentation Guidelines
Core Principles
- Code is primary — Self-documenting code first, comments second
- Explain why, not what — Comments explain intent, not mechanics
- Keep in sync — Outdated docs are worse than no docs
- Minimal but sufficient — Document what's needed, no more
When to Comment
const clampedGain = Math.max(-60, Math.min(20, totalGain));
setTimeout(() => measureHeight(), 0);
const delay = baseDelay * Math.pow(2, attempt);
When NOT to Comment
counter++;
if (user.role === 'admin') { ... }
TODO Format
JSDoc
Interface Documentation
export interface User {
id: string;
name: string;
email: string;
lastLoginAt: string | null;
}
Anti-Patterns
- Redundant docs: Don't document
getUser(id) as "Gets the user"
- Outdated docs: Wrong docs are worse than no docs
- Over-documentation: Don't explain
add(a, b) in 10 lines
- Magic numbers: Use named constants instead of inline comments