TSDoc and JSDoc Authoring
Create high-quality documentation comments for functions, classes, interfaces, types, modules, and exported APIs.
When to Apply
Use this skill when the user asks to:
- add or improve code comments/docs
- write TSDoc or JSDoc
- document params, return values, thrown errors, or examples
- standardize documentation style across files
Routing (Read This First)
Choose one focused index before loading rule files:
- TypeScript APIs and typed exports:
- JavaScript authoring and shape docs:
indexes/jsdoc-authoring-index.md
- Strict consistency/lint-safe output standards:
indexes/jsdoc-consistency-index.md
Rule 1: Choose the Correct Standard
- Use TSDoc for TypeScript code and typed public APIs.
- Use JSDoc for JavaScript code or projects using JSDoc tooling.
- Do not mix tag syntaxes from both standards in one comment block.
Workflow
- Read the target file and identify the symbol's purpose and side effects.
- Prefer documenting exported/public APIs first.
- Write a one-line summary in plain language.
- Add only meaningful tags (no empty or redundant tags).
- Validate tag names and formatting against the relevant standard.
- Ensure comments match actual behavior (inputs, outputs, errors, async behavior).
Authoring Rules (Both Standards)
- Describe intent and behavior, not obvious implementation details.
- Keep summaries concise and action-oriented ("Returns...", "Creates...", "Parses...").
- Document every parameter and explain what each parameter does.
- If a parameter is an object, document each object property and what it does.
- Use imperative, consistent phrasing for descriptions.
- Document thrown errors with when behavior depends on error handling.
- Add only when it clarifies non-obvious usage.
- Do not restate TypeScript types in prose unless it adds semantic meaning.
TSDoc Rules
Use these tags by default when relevant:
- for each function argument
- for generic parameters
- for return semantics
- for longer contextual details
- for exceptional behavior
- for practical usage
- for migration guidance
TSDoc formatting reminders:
- Use
@param name - Description
with a hyphen separator.
- Prefer inline links with .
- Keep release tags (, , , ) aligned with project policy.
- For object parameters in TypeScript, prefer a named or and add comments on each property so VS Code hovers/autocomplete show per-property docs.
JSDoc Rules
Use these tags by default when relevant:
- (with optional/default forms when needed)
- (or )
- when known
- and for reusable object shapes
- for usage snippets
- and for async/generator behavior when needed
JSDoc formatting reminders:
- Optional params:
- Optional with default:
@param {string} [name=John Doe]
- Nested object props: and
@param {string} options.mode
JSDoc Consistency Standard
Apply these rules by default in all JavaScript documentation, regardless of lint setup.
- Keep usage consistent per block ( or one shorthand access tag).
- Use only on classes/constructors.
- Prefer rule-specific guidance from the files when there is a conflict.
Output Expectations
When updating comments:
- keep existing project conventions unless user requests a migration
- preserve behavior accuracy over verbosity
- avoid adding comments to private/internal symbols unless requested
Additional Reference
For templates and tag cheat sheets, see reference.md.
Rule Files
Use focused indexes to avoid loading unrelated rules:
- TSDoc index:
- JSDoc authoring index:
indexes/jsdoc-authoring-index.md
- JSDoc consistency index:
indexes/jsdoc-consistency-index.md
Full Compiled Document
For the full rule index and category guide: