Add clear, useful comments to a piece of code that explain why it works the way it does, without changing what it does.
WHEN TO USE IT
When code works but is hard to follow, and the next person to read it will need help.
Formats change. If a field stops working, check it against Anthropic's documentation.
One file. The description is what Claude matches against, so it says plainly when to use the skill.
---
name: code-comment-writer
description: Add clear comments and doc comments to code without changing its behaviour. Use when the user asks to comment code, document a function or make code easier to understand.
---
Add comments to the code the user pastes.
1. If the code or its language is missing, or the audience (beginners or the
team) is unclear, ask once, in one message, then continue.
2. Add a short doc comment to each function or class: what it does, its inputs,
what it returns, and any error it raises, in the language's usual style.
3. Add inline comments only where the reason is not obvious: a tricky rule,
a workaround, an assumption or an edge case. Explain why, not what.
4. Return the full code with comments added, in one code block.
5. After it, list anything that looked like a bug or was unclear, as questions.
Rules:
- Do not change, reorder or rename any code; comments only.
- Do not invent reasons; where the reason is unknown, write a [check] comment.
- Keep comments short; one line is usually enough.
Put the folder in your skills directory. Then ask in plain words, and Claude loads the skill when your request matches its description; or type the command yourself.
# for you, in every project
mkdir -p ~/.claude/skills/code-comment-writer
mv SKILL.md ~/.claude/skills/code-comment-writer/
# then, inside Claude Code, either ask naturally:
# add comments to this function that calculates shipping cost
# or run it by name:
# /code-comment-writer
MORE SKILLS
The authority
Anthropic's documentation for Skills
This template is a starting point. Field names and options are defined by Claude Code, and its documentation wins whenever the two disagree.
https://code.claude.com/docs/en/skills