Skip to content
Back to skills

Code Comments Docstrings

ASecurity

Writes docstrings and comments that explain why the code is the way it is, and removes stale or noisy ones, without changing behavior.

  • 3 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 15, 2026
ai-agentsjavascriptpythonrustgojavagitapiperformance

Works with

  • api

Security analysis

A100/100

Scanned November 15, 2026

npx -y skills add workspace-templates/ai-agent-templates --skill code-comments-docstrings --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Code Comments Docstrings?

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

Security grade badge for Code Comments Docstrings
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/workspace-templates-code-comments-docstrings/badge)](https://www.skillsdirectory.com/skills/workspace-templates-code-comments-docstrings)

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: code-comments-docstrings
description: Writes docstrings and comments that explain why the code is the way it is, and removes stale or noisy ones, without changing behavior.
---

# Code comments and docstrings

Comments explain why. The code already shows what.

## Steps

1. Pick the scope (a file, a folder or the diff) and detect the project's docstring style from existing code: Google or NumPy for Python, JSDoc or TSDoc for JavaScript, rustdoc, Javadoc. Follow it; do not mix styles.
2. Read each function fully before writing about it. For public APIs, write a docstring with: a one-line summary in the imperative, parameters, return value, raised errors, and one short example when behavior is not obvious.
3. Add a comment only where the reason is not visible: a workaround and the bug it avoids, a performance choice, a unit or invariant, a surprising order of operations, a link to a spec.
4. Check every existing comment against the code. Fix it if it is wrong, delete it if it only repeats the code, keep it if it carries a reason.
5. Convert TODOs without owner or issue into either a concrete issue reference or a deletion proposal.

## Rules

- Never change executable code, formatting or imports in the same pass.
- Do not write a docstring you cannot support after reading the body. If behavior is unclear, say "unclear" in the report and skip it.
- No commented-out code; remove it, git remembers.
- Keep comments under 3 lines; longer thoughts go to docs.

## Report

Counts of docstrings added, comments rewritten and removed, plus the places where the code itself needs renaming instead of a comment.

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.

View all in ai-agents →

Comments

Loading comments…

Newsletter

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