Skip to content
Back to skills

Comment Guidelines

ASecurity

Code comment guidelines. Remove redundant comments, add strategic ones explaining WHY not WHAT. Applied automatically when modifying code.

  • 666 stars
  • 0 votes
  • 3 copies
  • 16 views
  • Added February 8, 2026
developmenttypescriptgoexpressapi

Works with

  • api

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill comment-guidelines --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Comment Guidelines?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Comment Guidelines
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-comment-guidelines/badge)](https://www.skillsdirectory.com/skills/majiayu000-comment-guidelines)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: comment-guidelines
description: "Code comment guidelines. Remove redundant comments, add strategic ones explaining WHY not WHAT. Applied automatically when modifying code."
user-invocable: false
---

# Comment Guidelines

These guidelines should be automatically applied whenever writing or modifying code.

## Core Principles

1. **Self-documenting code first** - Use clear naming and structure; comments are last resort
2. **WHY over WHAT** - Comments explain intent and reasoning, not mechanics
3. **Reduce cognitive load** - Make non-obvious knowledge explicit
4. **Zero redundancy** - Never duplicate what code already expresses

## When to Add Comments

**DO comment:**
- Design decisions and trade-offs
- Non-obvious behavior or edge cases
- Interface contracts (public APIs, function signatures)
- Important context that isn't evident from code
- Gotchas and subtle behaviors
- Cross-module dependencies

**DON'T comment:**
- What the code literally does (self-evident)
- Well-named variables/functions
- Standard patterns and idioms
- Implementation details visible in code

## Application Rules

When modifying code:

1. **Remove** any comments that restate what code does
2. **Keep** comments that explain WHY something is done
3. **Add** comments only for non-obvious behavior or design decisions
4. **Update** existing comments if code changes make them stale
5. **Never** add comments just to fill space or appear thorough

## Examples

```typescript
// BAD: Restates the obvious
// Set user name to the input value
user.name = input.value;

// GOOD: Explains non-obvious behavior
// Normalize to lowercase for case-insensitive matching in search
user.searchKey = user.name.toLowerCase();

// BAD: Documents what is self-evident
// Loop through all items
for (const item of items) { ... }

// GOOD: Explains WHY this approach
// Process in reverse to allow safe removal during iteration
for (let i = items.length - 1; i >= 0; i--) { ... }
```

## Automatic Application

This skill does NOT need to be explicitly invoked. Claude should:
- Apply these principles whenever editing code
- Proactively clean up redundant comments encountered
- Add strategic comments only where they reduce cognitive load

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.