documenting-code-comments

Establish code comment standards for WHY-focused inline documentation.

5|Updated Mar 16, 2019
One-click install
npx skills add https://github.com/third774/dotfiles --skill documenting-code-comments
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: documenting-code-comments
Source: https://github.com/third774/dotfiles/tree/main/opencode/skill/documenting-code-comments
Command: npx skills add https://github.com/third774/dotfiles --skill documenting-code-comments

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides standards for writing self-documenting code and best practices for inline comments, ensuring comments explain WHY rather than WHAT and reducing comment drift.

Core Features & Use Cases

  • Commenting Guidelines: When to write or avoid comments, and the right style.
  • Comment Formatting: JSDoc/TSDoc usage for public APIs; TODO formatting.
  • Audit & Refactor: Helps audits by ensuring code remains self-documenting and maintainable.

Quick Start

Apply guidelines during code reviews or audits to improve inline documentation without overburdening the codebase.

Frequently Asked Questions about documenting-code-comments

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

FAQPage Schema
How do I write code comments that explain WHY instead of WHAT?

Comments explaining WHY focus on the reasoning behind decisions rather than restating code logic. Use comments to document intent, trade-offs, and non-obvious constraints; let self-documenting code and type systems convey WHAT the code does. This reduces comment drift and keeps documentation aligned with actual implementation.

When should I add comments to code, and when should I avoid them?

Add comments for non-obvious decisions, business logic rationale, and complex algorithms. Avoid comments restating readable code or obvious operations. Use self-documenting practices—clear naming, type annotations, and JSDoc/TSDoc for public APIs—to minimize the need for inline comments and keep documentation maintainable.

What's the best way to format TODO comments and API documentation?

Use consistent TODO formats with context and ownership, and apply JSDoc or TSDoc conventions for public APIs to document parameters, return types, and exceptions. Standardized formatting ensures comments remain searchable, maintainable, and consistent across projects during code reviews and audits.

How do I audit code to ensure comments stay aligned with implementation?

Audit code systematically by checking that comments explain WHY decisions were made, not what the code does; verify type annotations and self-documenting names reduce redundant comments; and enforce TODO and JSDoc standards. Regular audits prevent comment drift and keep documentation accurate as code evolves.

Can I use JSDoc and TSDoc standards for both JavaScript and TypeScript projects?

Yes. JSDoc applies to JavaScript; TSDoc extends JSDoc for TypeScript with type-specific annotations. Both follow similar formatting conventions and serve the same purpose: documenting public APIs and reducing inline comment burden. Apply the appropriate standard for your language to maintain consistency.

Why does self-documenting code reduce the need for comments?

Self-documenting code uses clear naming, type systems, and logical structure to make intent explicit without explanation. When variable names, function signatures, and types convey purpose and constraints, comments can focus solely on WHY decisions exist rather than restating obvious logic, making documentation leaner and more maintainable.