Guidelines for writing minimal, high-quality JSDoc comments in TypeScript.
This skill provides focused guidelines for writing JSDoc comments consistently across the codebase.
@example format conventions (label + inline backtick or fenced block)@example Format@example line, code as inline backtick on the next line/**
* @example Required parameter
* `name: Type`
*
* @example Optional parameter
* `name?: Type`
*/
@example/**
* @example
* ```ts
* const result = buildParams(node, {
* paramsType: 'inline',
* })
* ```
*/
@example blocks/**
* @example Object mode
* `{ id, data, params }: { id: string; data: Data; params?: QueryParams }`
*
* @example Inline mode
* `id: string, data: Data, params?: QueryParams`
*/
| Rule | ✅ Correct | ❌ Incorrect |
|---|---|---|
| Label + inline code | @example Required\n\name: Type`` |
@example \name: Type`` (code on tag line) |
| Multi-line code | Fenced ```ts ``` block |
Bare code lines without a fence |
| Short examples | Inline backtick | Triple-backtick fence (too heavy) |
| One concern per example | Separate @example blocks |
One example covering all cases |
| Tag | Purpose | Notes |
|---|---|---|
@default |
Default value | Only when default is non-obvious; omit for undefined |
@example |
Usage example | Prefer for complex or multi-variant APIs |
@note |
Important caveat | Version info, breaking changes |
@deprecated |
Mark as deprecated | Include migration path |
| Tag | Purpose |
|---|---|
@see |
Reference external docs |
@internal |
Internal API |
@beta |
Experimental |
@param — use TypeScript parameter types@returns — use TypeScript return type@type — use TypeScript type annotation@typedef — use type or interface@default undefined — optional (?) already implies this/**
* Output directory for generated files.
*/
outDir?: string
❌ Never use single-line
/** description */— always expand to multi-line.
/**
* Maximum number of concurrent callbacks during traversal.
* Higher values overlap I/O-bound work; lower values reduce memory pressure.
*
* @default 30
*/
concurrency?: number
Do not add
@default falseor@default undefinedwhen the TypeScript type already makes the default obvious.
/**
* How path parameters are emitted in the function signature.
* - `'object'` groups them as a single destructured parameter
* - `'inline'` spreads them as individual parameters
* - `'inlineSpread'` emits a single rest parameter
*/
pathParamsType: 'object' | 'inline' | 'inlineSpread'
/**
* Applies a uniform transformation to every resolved type string.
* Use this for framework-level type wrappers.
*
* @example Wrap every type in a reactive container
* `typeWrapper: (t) => \`Reactive<${t}>\``
*/
typeWrapper?: (type: string) => string
names?: {
/**
* Name for the request body parameter.
* @default 'data'
*/
data?: string
/**
* Name for the query parameters group parameter.
* @default 'params'
*/
params?: string
/**
* Name for the header parameters group parameter.
* @default 'headers'
*/
headers?: string
}
Only add JSDoc when it adds value beyond the signature:
// ✅ No JSDoc needed — signature is self-explanatory
function camelCase(str: string): string { ... }
// ✅ JSDoc adds value — explains behaviour and non-obvious edge cases
/**
* Returns `true` when the schema resolves to a plain string output.
*
* - `string`, `uuid`, `email`, `url`, `datetime` are always plain strings.
* - `date` and `time` are plain strings when their `representation` is `'string'`.
*
* @example UUID resolves to a plain string
* `isStringType(uuidSchema) // true`
*
* @example Date with date representation is not a plain string
* `isStringType(dateSchema) // false`
*/
function isStringType(node: SchemaNode): boolean { ... }
✅ DO:
/** ... */@default only when the default is non-obvious (not undefined, not false)@example blocks to show different variants or modes@example labels short and descriptive❌ DON'T:
/** description */ — always use multi-line@default undefined — optional ? already implies this@example line: @example \foo: string`` → move code to next line@param or @returns tagsFor consistency, use this order within a JSDoc block:
@default (if non-obvious)@example (one or more)@note (if needed)@deprecated (if applicable)@see (if providing references)| Skill | Use For |
|---|---|
| ../documentation/SKILL.md | Writing markdown documentation files |
| ../coding-style/SKILL.md | General coding conventions |