comment-minimizer
Eliminates noisy, redundant, and obvious comments (//, #, /* */); enforces self-documenting identifiers and clean code.
SKILL.mdskills/comment-minimizer/SKILL.md
GitHubComment Minimizer & Clean Code Protocol
Enforce clean, self-documenting code by eliminating redundant comments and cognitive clutter.
1. Zero Obvious Comments Rule
Delete any comment that simply restates what the code expresses:
- Bad:
// increment counterfollowed byi++; - Bad:
# set user statusfollowed byuser.status = 'active' - Bad:
// check if list is emptyfollowed byif (items.length === 0) - Rule: If a comment can be inferred from reading the identifier name, delete the comment.
2. Refactor Comments into Code
Instead of explaining confusing code with a comment, refactor the code to be self-explanatory:
- Explanatory Variables:
- Bad:
if (u.age >= 18 && u.hasVerifiedEmail && !u.isSuspended) // check if eligible - Good:
const isEligibleToTransact = user.age >= 18 && user.hasVerifiedEmail && !user.isSuspended;
- Bad:
- Extract Function:
- Bad:
// calculate tax with surcharge+ 15 lines of math - Good:
calculateTaxWithSurcharge(orderTotal, regionCode)
- Bad:
3. Permissible Comments Only
Retain or add comments strictly in these 3 exceptional cases:
- Non-Obvious Business Rationale: Explaining why a decision was made when it contradicts standard convention.
- Upstream Bug Workaround: Linking to a specific issue tracker URL or vendor ticket.
- Complex Algorithmic Edge Cases: Explaining non-trivial mathematical formulas or bitwise operations.
- Delete all commented-out dead code; rely on git history instead.