Back to list
rileyhilliard

documenting-code-comments

by rileyhilliard

62🍴 13📅 Jan 21, 2026

SKILL.md


name: documenting-code-comments description: Standards for self-documenting code and minimal comments. Use when auditing inline documentation or deciding when comments add value vs clutter.

Code Comments

Core principle: The best comment is the one you didn't need to write.

Hierarchy

  1. Make code self-documenting (naming, structure)
  2. Use type systems for contracts
  3. Add comments only for WHY, never WHAT

When NOT to Comment

AvoidWhy
// Get the user's nameRestates code
@param {string} emailTypes already document
Stale commentsMisleading > missing

When TO Comment

WHY, Not WHAT

// Use exponential backoff - service rate-limits after 3 rapid failures
const backoffMs = Math.pow(2, attempts) * 1000;

Gotchas and Edge Cases

// IMPORTANT: Assumes UTC - local timezone causes date drift
const dayStart = new Date(date.setHours(0, 0, 0, 0));

External Context

// Workaround for Safari flexbox bug (JIRA-1234)
// Per RFC 7231 §6.5.4, return 404 for missing resources

Performance Decisions

// Map for O(1) lookup - benchmarked 3x faster than array.find() at n>100
const userMap = new Map(users.map(u => [u.id, u]));

Refactor Before Commenting

Instead of commentRefactor to
// Get active usersconst activeUsers = users.filter(u => u.isActive)
// 86400000 ms = 1 dayconst ONE_DAY_MS = 24 * 60 * 60 * 1000
// Handle error caseExtract to handleAuthError(err)

TODO Format

// ✅ TODO(JIRA-567): Replace with batch API when available Q1 2025
// ❌ TODO: fix this later

Audit Checklist

  1. Necessity - Can code be refactored to eliminate comment?
  2. Accuracy - Does comment match current behavior?
  3. Value - Does it explain WHY, not WHAT?
  4. Actionability - TODOs have ticket references?

Score

Total Score

65/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

+5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon