doc-gen

doc-gen is a command for Claude Code from halflength-ampleness75/claude-code-recipes. It costs 16 tokens per session (903 once invoked), scanned A, original, MIT.

A command for generating software documentation from a file, directory, symbol, or keyword such as README or API. It can create inline comments, project guides, or API reference material.

In plain words
What is it for?
Use it to add JSDoc or docstrings, document a directory, update a README, generate API documentation, or document a named function or class.
Why use it?
It removes the need to decide manually what kind of documentation a target needs. It can document exported code elements and explain non-obvious behavior, parameters, returns, and implementation details.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: model in frontmatter.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/halflength-ampleness75/claude-code-recipes/doc-gen
Clone the repo
git clone --depth 1 https://github.com/halflength-ampleness75/claude-code-recipes

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for doc-gen

README.md
[![agentmods](https://agentmods.dev/badge/commands/halflength-ampleness75/claude-code-recipes/doc-gen.svg)](https://agentmods.dev/commands/halflength-ampleness75/claude-code-recipes/doc-gen)
Your own site
<a href="https://agentmods.dev/commands/halflength-ampleness75/claude-code-recipes/doc-gen"><img src="https://agentmods.dev/badge/commands/halflength-ampleness75/claude-code-recipes/doc-gen.svg" alt="Measured on agentmods" height="20"></a>
Per session 16 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 903 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00016 $0.00903
Opus 5 $0.00008 $0.00451
Sonnet 5 $0.00003 $0.00181
Haiku 4.5 $0.00002 $0.00090

Measured 5d ago against content hash 8f96312c7a7d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

doc-gen scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/doc-gen.md · 115 lines

How it starts

The opening of the file, as written. The whole thing — 115 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Generate documentation for the code specified in $ARGUMENTS. The argument may be a file path, a directory, a function name, or a keyword like "readme" or "api".

Step 1 — Determine Documentation Type

Parse $ARGUMENTS to figure out what kind of documentation is needed:

Argument contains Action
A file path (e.g., src/auth.ts) Add inline JSDoc/docstrings to that file
A directory (e.g., src/utils/) Document all exported members in that directory
readme or README Generate or update the project README
api Generate API reference documentation
A function/class name Find and document that specific symbol
Nothing Ask the user what they want documented

Step 2a — Inline Documentation (JSDoc / Docstrings)

For each exported function, class, method, type, and constant in the target file(s):

JavaScript/TypeScript — JSDoc:

/**
 * Brief one-line description of what this function does.
 *
 * Longer explanation if the behavior is non-obvious, including
 * algorithm notes, performance characteristics, or caveats.
 *
 * @param name - Description of the parameter
 * @returns Description of the return value
 * @throws {ErrorType} When and why this error is thrown
 * @example
 * const result = myFunction("input");
 * // result === "expected output"
 */

Python — Docstrings (Google style):

def my_function(name: str) -> str:
    """Brief one-line description.

    Longer explanation if needed.

    Args:
        name: Description of the parameter.

    Returns:
        Description of the return value.

    Raises:
        ValueError: When and why this error is raised.

    Example:
        >>> my_function("input")
        'expected output'
    """

Rules:

  • Do not state the obvious. @param id - The id is useless. Write @param id - Unique identifier used to look up the user record.
  • Document why, not just what, when the purpose is non-obvious.
  • Include at least one @example for public API functions.
  • Document thrown errors and edge-case behavior.
  • Preserve existing documentation — only add or improve, never remove unless it is incorrect.

Read the full file on GitHub · 115 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 115 lines · 16 tokens per session scan A 8f96312c7a7d

Subscribe to this mod's changes

doc-gen is a command published in the GitHub repository halflength-ampleness75/claude-code-recipes (2 stars, last pushed today), licensed MIT. It adds 16 tokens to every session and 903 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.