Agent skill

Docstring Generator

by espennilsen in espennilsen/pi

Generate and update language-idiomatic doc comments for TypeScript (TSDoc/JSDoc) and Rust (Rustdoc).

MITAuto-check passedDevelopment

Install Docstring Generator

skills CLI
$ npx skills add espennilsen/pi --skill docstring-generator -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install espennilsen/pi docstring-generator --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/espennilsen/pi.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/docstring-generator .claude/skills/docstring-generator && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
docstring-generator
GitHub stars
122
Token cost
~1.6k tokens
SKILL.md length
690 words
Files
1
Skills in repo
36
Repo updated
First seen
Licence
MIT

At a glance

Generate and update language-idiomatic doc comments for TypeScript (TSDoc/JSDoc) and Rust (Rustdoc).

  • Works in 3 steps: Parse declarations → Generate doc comments → Merge into file
  • Asked to add docs
  • SKILL.md covers Inputs, Workflow, Behavior & Style Rules and Selection Behavior, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Docstring Generator is an agent skill from espennilsen/pi. Generate and update language-idiomatic doc comments for TypeScript (TSDoc/JSDoc) and Rust (Rustdoc). Use when asked to "add docs", "document this file", "generate docstrings", "add JSDoc", "add Rustdoc", "write TSDoc", or when working with TypeScript or Rust source files that need documentation comments. Supports file-level and selection-level operations. Deterministic and idempotent — safe to run repeatedly on the same code. Does NOT change behavior, rename symbols, or refactor code.

Its SKILL.md is about 1.6k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Technical documentation and Refactoring. It works with Rust and TypeScript. The licence is MIT.

When your agent uses it

  • Asked to add docs
  • Document this file
  • Generate docstrings
  • Working with TypeScript

Example prompts

  • “add docs”
  • “document this file”
  • “generate docstrings”
  • “/docstring-generator”

Workflow steps

3 steps, taken from the step headings in SKILL.md.

  1. Parse declarations
  2. Generate doc comments
  3. Merge into file

What it can do on your machine

Read from SKILL.md and the folder at commit 79d019b. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript and rust).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Docstring Generator loads about 1.6k tokens when it runs. Until then it costs about 127 tokens; SKILL.md has 690 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~127
When it runs · the whole SKILL.md, loaded when a task matches
~1.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from espennilsen/pi at commit 79d019b, republished under its MIT licence (© espennilsen). 690 words, ~1,623 tokens.

Download SKILL.mdSave it as .claude/skills/docstring-generator/SKILL.md (or your agent's skills folder).
name
docstring-generator
description
Generate and update language-idiomatic doc comments for TypeScript (TSDoc/JSDoc) and Rust (Rustdoc). Use when asked to "add docs", "document this file", "generate docstrings", "add JSDoc", "add Rustdoc", "write TSDoc", or when working with TypeScript or Rust source files that need documentation comments. Supports file-level and selection-level operations. Deterministic and idempotent — safe to run repeatedly on the same code. Does NOT change behavior, rename symbols, or refactor code.

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

InputTypeRequiredDescription
languagestringyes"typescript" or "rust"
file_pathstringyesPath of the file being edited
full_textstringyesEntire contents of the file
selection_rangeobjectno{ start_line, end_line } (1-based, inclusive)
modestringno"update_missing" (default) or "update_all"
public_onlybooleannoIf 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.
TypeScript Rules

Comment style: Use /** ... */ TSDoc/JSDoc block comments immediately before the declaration.

Functions & methods:

  • First line: one-sentence summary of what the function does.
  • Then @param name - description for each parameter.
  • Then @returns with a short description if the function returns non-void.

Classes, interfaces, type aliases, enums:

  • Summarize the purpose and role of the type.
  • Prefer describing intent over implementation details.

Mode behavior:

  • update_missing: Do not rewrite existing comments unless they are obviously placeholder (e.g., TODO, fix, FIXME, @todo).
  • update_all: Improve unclear comments but preserve any explicit developer notes or warnings.

Example:

typescript
/** Loads a user by id from the primary data store.
 * @param id - Unique identifier of the user.
 * @returns The user if found, otherwise null.
 */
async function getUserById(id: string): Promise<User | null> {
  // ...
}

Overloaded/union-heavy functions: Describe the general behavior rather than each possible overload or union variant.

Show full SKILL.md (281 more words)Show less
Rust Rules

Comment style: Use /// triple-slash line comments for item docs. Keep lines around 80 characters.

Structure:

  • First line: brief summary sentence.
  • Blank /// line, then details or examples as needed.
  • For fallible functions, add a # Errors section if the error conditions are clear from the signature.
  • Refer to types with backticks: `SomeType`.

Scope: Only document public API by default (pub fn, pub struct, pub enum, pub trait, pub methods on pub types).

Mode behavior:

  • update_missing: Only add docs to items without existing /// comments.
  • update_all: Refine awkward wording but preserve explicit notes like # Panics or # Safety.

Example:

rust
/// Calculates the checksum for the given buffer.
///
/// # Errors
///
/// Returns an error if the buffer length exceeds the supported maximum.
pub fn checksum(buf: &[u8]) -> Result<u32, ChecksumError> {
    // ...
}

Selection Behavior

  • If selection_range is provided: Only consider declarations that start within the selected line range. Do not modify docs for items outside the selection.
  • If a declaration spans multiple lines and the selection includes its start line, treat the entire declaration as in-scope.
  • If selection_range is omitted: Apply the chosen mode to the entire file, respecting public_only.

Edge Cases

  • Generic names: If a symbol name is extremely generic (e.g., doStuff, handle), use surrounding code and types to infer a better description, but stay conservative.
  • Insufficient context: If there isn't enough information to write a meaningful description, use a neutral description like "Performs the operation for this type" rather than fabricating details.
  • Rust generics: Do not over-specify type parameters. Describe the concept and constraints at a high level.
  • Selection mid-declaration: If the selection start line falls inside a multi-line declaration, still treat the entire declaration as in scope.

Output

Return these three values:

FieldTypeDescription
updated_textstringFull file text with updated doc comments
summarystring1-3 sentence summary of what was documented
touched_symbolsstring[]Names of functions/types that had docs added or updated

© espennilsen, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/docstring-generator of espennilsen/pi.

Open the folder on GitHubat commit 79d019b

Compare with similar skills

Docstring Generator next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Docstring Generator compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Docstring Generator this skillespennilsen/pi122—~1.6kAutomated safety check: PassMIT
Coding Agentmastra-ai/mastra29k—~2.3kAutomated safety check: PassCustom licence
Enforce Rules For Typescriptmoeru-ai/airi50k—~3.4kAutomated safety check: PassMIT
Rust Architectsergigp/yarrtube133—~6.1kAutomated safety check: PassMIT
New Pattern Authoring WorkflowTotoro-jam/battle-tested-patterns344—~1.5kAutomated safety check: PassMIT
Maintainability Reviewpmndrs/glyph393—~1.7kAutomated safety check: PassMIT

Similar skills

  • Coding Agent

    mastra-ai/mastra

    Authoring playbook for building agents that write, edit, review, or refactor code.

    29k GitHub stars~2.3k tokensUpdated today
    DevelopmentAuto-check passed
  • Enforce AIRI's TypeScript and Vue source rules for imports, naming, comments, JSDoc, fallbacks, stateful and protocol code, and module design.

    50k GitHub stars~3.4k tokensUpdated today
    DevelopmentAuto-check passed
  • Rust Architect

    sergigp/yarrtube

    Architecture, naming, and testing conventions guidelines for architecting Rust codebases.

    133 GitHub stars~6.1k tokensUpdated today
    DevelopmentAuto-check passed
  • New Pattern Authoring Workflow

    Totoro-jam/battle-tested-patterns

    Step-by-step workflow for adding a new pattern to the battle-tested-patterns repo: validate the topic, verify sources, write the doc, code and exercises.

    344 GitHub stars~1.5k tokensUpdated 1 mo ago
    DevelopmentAuto-check passed
  • Audit and improve repository code milestone by milestone for correctness, clarity, local reasoning, DRY design, explicit state modeling, panic resistance, and trustworthy TypeScript boundaries.

    393 GitHub stars~1.7k tokensUpdated today
    DevelopmentAuto-check passed
  • Code Refiner

    Mathews-Tom/armory

    Deep code simplification and refactoring preserving behavior across Python, Go, TypeScript, Rust.

    328 GitHub stars~3.1k tokensUpdated 2 days ago
    DevelopmentAuto-check passed

More from espennilsen/pi

All 36 skills in this repo
  • GitHub

    espennilsen/pi

    Interact with GitHub repos, PRs, issues, CI, and notifications via the pi-github extension commands and gh CLI.

    122 GitHub stars~1k tokensUpdated 16 days ago
    Auto-check passed
  • Skill Creator

    espennilsen/pi

    Create, review, and improve skills for Pi agents. An agent skill from espennilsen/pi.

    122 GitHub stars~2.1k tokensUpdated 16 days ago
    Auto-check passed
  • Dry Code Review

    espennilsen/pi

    Perform a comprehensive DRY (Don't Repeat Yourself) code review on a codebase.

    122 GitHub stars~1.7k tokensUpdated 16 days ago
    Auto-check passed
  • Extract Design System

    espennilsen/pi

    Reverse-engineer a design system from a live website (public URL or localhost).

    122 GitHub stars~2k tokensUpdated 16 days ago
    Auto-check passed
  • Herdr Operations

    espennilsen/pi

    A skill your agent uses when inspecting or operating Herdr sessions, workspaces, tabs, panes, agents, terminal output, agent messaging, or waits.

    122 GitHub starsUsed in 1 repo~525 tokens
    Auto-check passed
  • PDF Reader

    espennilsen/pi

    Read and extract content from PDF files — text, tables, metadata, and images.

    122 GitHub stars~1.6k tokensUpdated 16 days ago
    Auto-check passed

Works with

Categories

Questions about Docstring Generator

What does Docstring Generator do?

Generate and update language-idiomatic doc comments for TypeScript (TSDoc/JSDoc) and Rust (Rustdoc). Docstring Generator is an agent skill from espennilsen/pi. Generate and update language-idiomatic doc comments for TypeScript (TSDoc/JSDoc) and Rust (Rustdoc).

When should I use Docstring Generator?

Docstring Generator fits situations like: asked to add docs; document this file; generate docstrings; working with TypeScript.

How do I install Docstring Generator in Claude Code?

Run `npx skills add espennilsen/pi --skill docstring-generator -a claude-code`. Or copy the skill folder (skills/docstring-generator in espennilsen/pi) into .claude/skills/docstring-generator in your project. Claude Code loads it when a task matches its description.

How do I install Docstring Generator in Codex?

Run `npx skills add espennilsen/pi --skill docstring-generator -a codex`. Or copy the skill folder (skills/docstring-generator in espennilsen/pi) into .agents/skills/docstring-generator in your project. Codex loads it when a task matches its description.

Can I use Docstring Generator in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add espennilsen/pi --skill docstring-generator -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/docstring-generator, .gemini/skills/docstring-generator, .github/skills/docstring-generator and .opencode/skills/docstring-generator in your project.

What does Docstring Generator need to run?

SKILL.md names no scripts, command-line tools or credentials: Docstring Generator is instructions for the agent only.

Does Docstring Generator access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Docstring Generator safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Docstring Generator use?

Docstring Generator is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Docstring Generator use?

About 1.6k tokens (SKILL.md is roughly 6.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Docstring Generator?

Skills that share tags, products or a category with Docstring Generator: Coding Agent (mastra-ai/mastra, 29k stars), Enforce Rules For Typescript (moeru-ai/airi, 50k stars), Rust Architect (sergigp/yarrtube, 133 stars) and New Pattern Authoring Workflow (Totoro-jam/battle-tested-patterns, 344 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Docstring Generator?

espennilsen (a GitHub user) maintains it in espennilsen/pi, which has 122 GitHub stars. The repository holds 36 skills in this directory. The repository was last updated on September 21, 2026.

Source: espennilsen/pi on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.