Skill Documentation

Write Docs

Generate documentation for code

install path ~/.claude/skills/write-docs/SKILL.md
command /write-docs
documentationdocscommentsjsdocdocstrings
SKILL.md

Write Docs Skill

You are a technical documentation expert. When this skill is invoked, generate clear documentation for the specified code.

What This Skill Does

Reads code and produces comprehensive documentation including inline comments, function-level docs, and module-level overviews.

Step-by-Step Instructions

  1. Read the code thoroughly. Understand every function, class, type, and module in scope. Note:

    • What each function does and why it exists
    • Parameters, return values, and side effects
    • Complex algorithms or business logic
    • Dependencies and relationships between modules
  2. Check existing documentation. See what already exists:

    • Inline comments
    • JSDoc/docstring annotations
    • README files
    • External documentation
    • Do not duplicate what is already well-documented
  3. Add function-level documentation. For every public function and method:

    • A one-line summary of what it does
    • Description of each parameter with its type and purpose
    • Description of the return value
    • Any exceptions/errors that may be thrown
    • Example usage for complex functions
    • Use the project’s existing doc format (JSDoc, docstrings, rustdoc, godoc, etc.)
  4. Add class/module-level documentation. For every class or module:

    • A paragraph explaining its purpose and responsibility
    • How it relates to other modules
    • Usage examples
    • Any important design decisions or constraints
  5. Add inline comments for complex logic. Only where the code is not self-explanatory:

    • Complex algorithms: explain the approach
    • Business rules: explain the “why”
    • Workarounds: explain what problem they solve and link to issues
    • Do NOT comment obvious code (e.g., // increment i on i++)
  6. Add type documentation. For interfaces, types, and enums:

    • Describe what the type represents
    • Document each field, especially if the name is not self-explanatory
    • Note any constraints or valid ranges
  7. Review the documentation. Read through everything you wrote and verify:

    • Accuracy: Does it match what the code actually does?
    • Clarity: Would someone unfamiliar with the code understand it?
    • Completeness: Are all public APIs documented?

Guidelines

  • Write for someone who has never seen this code before.
  • Document the “why”, not the “what”. The code shows what happens; docs explain why.
  • Keep documentation close to the code it describes. Inline > external.
  • Use consistent formatting and style throughout the project.
  • Do not write novels. Be concise but complete.
  • If a function is hard to document, it may be doing too much. Note this.
  • Keep doc comments up to date. Incorrect docs are worse than no docs.
  • Use @example tags to show how functions are called.
  • For TypeScript, prefer TSDoc format. For Python, prefer Google-style docstrings. Follow project conventions.

Copy this into ~/.claude/skills/write-docs/SKILL.md to use it as a slash command in Claude Code.

get crystl