Commenting Intent

Write comments explaining why code exists and non-obvious decisions.

Updated Nov 27, 2025
One-click install
npx skills add https://github.com/barrydobson/dotfiles_extra --skill commenting-intent
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Commenting Intent
Source: https://github.com/barrydobson/dotfiles_extra/tree/main/packages/claude/dot-claude/skills/coding/commenting-intent
Command: npx skills add https://github.com/barrydobson/dotfiles_extra --skill commenting-intent

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill addresses the problem of redundant, unhelpful comments that merely restate obvious code, or the lack of comments explaining critical decisions. It ensures comments add real value by focusing on the "why" behind the code, non-obvious decisions, and complex logic, rather than its mechanical "what."

Core Features & Use Cases

  • Focus on Rationale: Guides you to explain the reasoning behind design choices, algorithm selection, or specific values (e.g., magic numbers).
  • Avoid Obvious Comments: Encourages deleting comments that simply restate self-evident code, promoting self-documenting code.
  • Document Workarounds & Gotchas: Provides a clear place to explain unusual code necessitated by bugs or external constraints.
  • Use Case: Instead of commenting total = a + b # Add a and b to get total, use this skill to explain MAX_RETRIES = 3 # Based on testing showing 3 retries handles 99.9% of transient failures.

Quick Start

Review the attached Python function. Identify any comments that merely restate obvious code. For any complex or non-obvious parts, add comments explaining the WHY behind the decision or logic.

Frequently Asked Questions about Commenting Intent

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why should code comments explain the reasoning behind decisions rather than just restating what the code does?

Comments explaining WHY capture the intent, trade-offs, and constraints behind code that self-documenting syntax cannot convey. A comment like 'MAX_RETRIES = 3 # Based on testing showing 3 retries handles 99.9% of transient failures' guides future maintainers on decision rationale, preventing unnecessary changes and speeding code reviews.

How do I identify comments that are redundant and should be removed?

Redundant comments merely restate obvious code mechanics. Remove comments like '# Add a and b to get total' above total = a + b. Keep only comments explaining non-obvious logic, workarounds, magic numbers, algorithm choices, or constraints—information the code itself cannot express.

What should I document when explaining complex algorithms and code logic?

Document the WHY behind algorithm selection, non-obvious decision points, and trade-offs accepted. Include justifications for magic numbers, explanations of workarounds necessitated by bugs or external constraints, and references to decision origins—information that helps maintainers understand intent without reverse-engineering reasoning.

How do I write comments that prevent over-commenting obvious code while covering critical decisions?

Strike balance by commenting only where code intent is unclear: complex branching logic, performance optimizations, unusual workarounds, and justified defaults. Self-evident operations like variable assignments and simple loops need no comments; focus effort on explaining non-obvious decisions and trade-offs.

Can I use this approach to improve code reviews and developer onboarding?

Yes. Comments explaining rationale and decision origins accelerate code review by eliminating back-and-forth questions about intent. New maintainers onboard faster when comments document gotchas, constraints, and design choices upfront rather than forcing them to deduce reasoning from code structure.