docstring-generator

A documentation tool for adding language-appropriate comments to TypeScript and Rust source code. It supports TSDoc or JSDoc for TypeScript and Rustdoc for Rust, including public functions, classes, types, and other exported code.

In plain words
What is it for?
Use it to document exported APIs, classes, methods, interfaces, types, enums, and other public declarations in TypeScript or Rust files.
Why use it?
It makes public code easier to understand and keeps documentation close to the declarations it describes. It can add missing comments or update existing ones according to the selected scope.

Skill for Claude CodeCodex

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 skills/espennilsen/pi/docstring-generator
Any agent
npx skills add espennilsen/pi --skill docstring-generator
Clone the repo
git clone --depth 1 https://github.com/espennilsen/pi

Made for: Claude Code, Codex.

Per session 118 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,514 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 $0.00118 $0.01514
Opus 5 $0.00059 $0.00757
Sonnet 5 $0.00024 $0.00303
Haiku 4.5 $0.00012 $0.00151

Measured 2d ago against content hash 02427e549140, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

docstring-generator 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 2d 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.

skills/docstring-generator/SKILL.md · 176 lines

How it starts

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

Docstring Generator

Generates or updates doc comments for TypeScript and Rust source files. The skill analyzes the public API surface (functions, methods, classes/structs, traits/interfaces, enums) and produces language-idiomatic documentation.

Inputs

Input Type Required Description
language string yes "typescript" or "rust"
file_path string yes Path of the file being edited
full_text string yes Entire contents of the file
selection_range object no { start_line, end_line } (1-based, inclusive)
mode string no "update_missing" (default) or "update_all"
public_only boolean no If true (default), only document exported/public items

Workflow

Step 1: Parse declarations

Mentally parse full_text to find all declarations relevant to the language, public_only, and selection_range settings.

TypeScript declarations to document:

  • Exported functions, async functions, and generators
  • Exported classes and their public/protected methods
  • Exported interfaces and type aliases
  • Exported enums
  • Exported const/let/var at module level (when they hold complex types)

Rust declarations to document:

  • pub fn (free functions and methods)
  • pub struct and its pub fields
  • pub enum and its variants
  • pub trait and its method signatures
  • pub type and pub const items
  • pub mod (public modules)

Step 2: Generate doc comments

For each target declaration, follow the language-specific rules below.

Step 3: Merge into file

Insert or update the doc comment immediately before the declaration, preserving all existing formatting, indentation, and code. Return the full updated_text with only doc comment lines changed.

Behavior & Style Rules

General Rules (all languages)

  • Preserve everything: Do not change code semantics, identifiers, formatting, or indentation. Only touch doc comment lines.
  • No speculation: If unsure about behavior, write neutral high-level descriptions instead of guessing.
  • Present tense, concise: Describe what the item does, not what it is. Avoid restating obvious type information unless it aids clarity.
  • Idempotent: Running the skill twice on the same file should produce the same result.
  • Respect developer notes: In update_all mode, preserve explicit warnings, safety notes, panic documentation, and custom annotations.

Read the full file on GitHub · 176 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. 2d ago First seen · 176 lines · 118 tokens per session scan A 02427e549140

Subscribe to this mod's changes

docstring-generator is a skill published in the GitHub repository espennilsen/pi (117 stars, last pushed 9d ago), licensed MIT. It adds 118 tokens to every session and 1,514 once invoked, about $0.0006 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-30.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.

obra/superpowers · 37 tokens

chat-pet-sprite-creation

Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.

microsoft/vscode · 53 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

babysit-pr

Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep…

openai/codex · 114 tokens

imagegen

Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output…

openai/codex · 113 tokens