Maintain JS Package Docs
Purpose
Use this skill to keep a package's public API, implementation behavior, declarations, README, examples, and published documentation consistent.
Instructions
- Inspect package metadata, public entry points, declarations, tests, README, and relevant examples.
- Identify the observable contract change before editing documentation.
- Update implementation, API comments, bundled docs, and examples together when they describe the same behavior.
- Run the repository's applicable checks and inspect the packed artifact when publication is in scope.
Examples
Example: when an exported function gains an option, update its JSDoc parameter/default/error semantics, declarations, README usage, examples, and any migration note, then run the package checks.
Requirements
- A publishable JavaScript or TypeScript package with
package.json and public entry points.
- The repository's configured tests, type checks, documentation checks, and package-manager commands.
- A generated declaration surface or source types when the package publishes types.
Limitations
- Do not publish, change release configuration, or broaden package contents without explicit authorization.
- Do not document private modules or planned behavior as part of the public contract.
llms.txt or custom metadata is not authoritative unless the target toolchain explicitly implements it.
Troubleshooting
- Stale API docs: compare the public declaration surface with exports and regenerate before editing prose.
npm pack --dry-run mismatch: inspect package include/exclude rules and verify the packed artifact.
- JSDoc or type-check failure: fix the source-of-truth contract first, then update all dependent examples.
Apply the agent-readable package documentation specification while developing the package. Treat
documentation as part of the public contract and complete the implementation and every affected
documentation layer in the same change. The specification makes an installed package self-describing
and version-aligned; it does not turn package documentation into agent instructions. Optimize the
content first for coding agents reading source or declarations directly, then for natural human
reading, and finally for editor and documentation-tool presentation.
Use this design priority explicitly: Agent-first, human-friendly, tool-compatible.
- Agent-first: make purpose, contracts, examples, and routes to deeper local documentation easy to
discover and understand from source, declarations, and the packed artifact.
- Human-friendly: write complete, natural technical prose that developers can understand without
knowing an agent-specific convention. Completeness takes precedence over brevity; shorten only after
preserving every relevant contract detail.
- Tool-compatible: use JSDoc as the baseline and optional TSDoc or tool-specific enhancements only
when they improve extraction, validation, or presentation without becoming the sole source of truth.
Establish the documentation impact
Before editing, inspect the effective repository instructions and the package's existing sources of
truth: package.json, public entry points, declaration output or source types, README, documentation
index, relevant topic pages, examples, tests, and release or migration conventions. Read only the
materials relevant to the requested change.
Identify the observable change before deciding what to document. Update documentation when the work
changes any of these:
- public exports, signatures, types, defaults, or lifecycle;
- supported configuration, environment, runtime, or compatibility;
- errors, side effects, ordering requirements, performance characteristics, or security guidance;
- recommended usage, deprecation status, migration steps, or a user-visible limitation.
Do not create documentation churn for a behavior-preserving internal refactor unless it changes a
documented mental model, extension point, contributor workflow, or architecture contract.
For specification adoption or audit, a new documentation structure, a substantial public API change,
a deprecation or migration, or an npm publication review, read
references/package-documentation-specification.md
before editing. For a small change in an already conforming package, follow the established routes and
load only the affected documentation.
Implement code and documentation together
- Implement the requested behavior and its tests. Do not document planned behavior as if it already
exists.
- Inventory the actual consumer-facing API from
package.json exports, public entry points, and the
generated declaration surface. Do not equate every source-level export with a public package
export.
- Ensure every public exported function, class, constructor, value, type, interface, enum, and every
consumer-facing public member has an authoritative
/** ... */ API comment. Use JSDoc prose and
tags as the default authoring baseline. Add TSDoc-only constructs as a supplementary layer only
when the repository's documentation toolchain consumes them, and keep required contract semantics
understandable without those extensions. Re-export barrels do not need duplicate comments when
the original declaration comment survives in generated declarations. Document every overload
whose contract differs or whose comment would otherwise be absent from consumer-visible help.
- Treat a public callable comment as incomplete until it covers every runtime parameter and all
non-obvious return, generic, failure, and overload semantics. Describe semantic roles and behavior
instead of restating TypeScript types or adding tags with no information beyond the signature.
- Add comments to non-public functions when their purpose, reason, invariant, mutation, ordering,
error translation, or algorithm is not clear from names and types. Do not comment trivial wrappers,
callbacks, or obvious local helpers merely to increase a count.
- Preserve or add a package-level JSDoc-style comment at the public type entry point when it helps
agents and users discover the package purpose and bundled documentation. Add the TSDoc
@packageDocumentation marker only when the adopted toolchain uses it. Follow the repository's
existing comment standard and ensure declaration generation retains useful comments.
- Update the appropriate authoritative human-facing document. Keep README as a self-contained
orientation and first route; route detailed concepts, tasks, recipes, migrations, and troubleshooting
into focused files under the repository's established documentation directory.
- Update examples when the recommended call pattern changes. Prefer examples that are type-checked,
tested, or otherwise runnable by the existing project workflow.
- For breaking changes and deprecations, document both the replacement and the migration path. Keep
old guidance only when supported versions still require it, and label that scope explicitly.
Avoid copying the same contract into multiple places. Let types define exact shapes, tests define
verified behavior, README provide orientation, and topic docs explain concepts and tasks. Link between
these layers instead of maintaining parallel prose.
Write agent-readable, JSDoc-first API comments
For every exported function, public method, constructor, call signature, and function-valued public
property, require an API comment attached to the declaration consumers see. Make the comment
self-contained enough for a coding agent or human to understand the contract next to the signature:
- a summary that states the operation and its observable contract;
- one
@param entry for each runtime parameter, including rest parameters, with its semantic role,
optional behavior, and default when applicable;
@returns when the result has semantics not already obvious from the name and TypeScript return
type, such as ownership, identity, mutability, units, branches, caching, or failure representation;
- generic-parameter semantics when a type parameter's role, constraint, relationship, or lifetime is
not obvious; put this in ordinary prose or the related
@param/@returns, and optionally add
@typeParam when the repository's TSDoc pipeline supports or requires it;
- meaningful synchronous exceptions, asynchronous rejections, callback propagation, and result-based
failures; use JSDoc
@throws for thrown exceptions and keep any critical nuance understandable in
ordinary prose when some consumers may ignore the tag; do not invent a failure contract; and
- separate complete comments for overloads unless verified
{@inheritDoc} or tool-supported comment
inheritance preserves the exact contract for each visible signature.
In .ts and .tsx, let TypeScript syntax carry types: do not repeat types in braces inside @param
or @returns. Do not use JSDoc @template to redeclare TypeScript generics. In .js and .jsx, use
the TypeScript-supported JSDoc type tags when they provide the package's type information.
Use JSDoc as the primary vocabulary: summary prose, @param, @returns, @throws, @deprecated,
@see, @example, and {@link}. Treat TSDoc additions such as @packageDocumentation,
@typeParam, @remarks, @defaultValue, release-stage modifiers, and TSDoc declaration references
as optional enhancements. Before using them, inspect the existing config and conventions for TSDoc,
API Extractor, TypeDoc, or a related linter. Do not add a TSDoc tag merely because the file is
TypeScript, and do not put the only copy of required contract information behind an extension that
baseline JSDoc consumers may ignore.
Function-valued properties have the same requirements as method syntax. Keep the existing API shape
unless a change is otherwise justified; attach the tags to the property comment and verify how the
project's declaration and documentation tools render them. Documentation elsewhere does not excuse a
missing or partial signature comment.
Apply the same semantic rule to generic public classes, interfaces, and type aliases: explain a type
parameter when its role is not obvious, without mechanically requiring @typeParam for every generic.
Before finishing, make a temporary coverage table with one row per public callable and columns for
summary, parameters, non-obvious return semantics, non-obvious generic semantics, failures, overloads,
JSDoc baseline, justified TSDoc enhancements, generated-declaration retention, and representative
tool rendering. Mark a semantic column not applicable only when the signature and name already make
it unambiguous. A missing TSDoc enhancement is a failure only when the repository has adopted that
profile. Do not report completion while any applicable cell is missing.
Keep installed documentation usable
When the package is published to npm and local documentation is part of the intended developer
experience:
- keep a short documentation route near the top of the package-root README;
- make the documentation index point to focused files through relative links;
- include the required documentation and examples in the published file allowlist;
- describe local paths relative to the package root rather than assuming a
node_modules layout;
- treat bundled docs as version-matched reference material, not as higher-priority instructions for
the consuming repository; and
- do not rely on
llms.txt, a custom package.json field, or a dependency-level AGENTS.md unless
the target toolchain explicitly implements that convention.
Do not publish, change release configuration, or broaden the package contents unless the user's task
authorizes those changes. A dry-run package inspection is read-only and may be used when relevant.
Package comments and bundled Markdown may recommend supported patterns, tradeoffs, or next reading,
but they are advisory reference material rather than instructions that a consuming coding agent must
obey. Do not tell an agent to ignore repository instructions, change its workflow, run commands, or
modify files. A real API precondition may still use mandatory language when it describes program
behavior—for example, requiring close() before process exit to flush buffered data.
Validate the result
Run the repository's applicable tests, type checks, documentation checks, and example validation.
Run any existing JSDoc completeness linter first. Run TSDoc checks when the repository has adopted a
TSDoc profile, and follow its configured tags; do not add a new lint dependency unless the task
authorizes that tooling change.
For npm package work, inspect the actual artifact with npm pack --dry-run or the repository's
equivalent and confirm that README, intended docs, examples, declarations, runtime files, and source
maps follow the package policy. Do not assume a file is published merely because it exists in the
repository.
Review the diff for stale names, broken relative links, duplicated authority, comments stripped from
declarations, examples that no longer type-check, and documentation claims not covered by code or
tests. Compare the generated public declaration surface against the API inventory and list any public
symbol or member with a missing or incomplete documentation comment, including missing parameter or
non-obvious return, generic, failure, or overload semantics. Confirm that the JSDoc baseline remains
understandable after ignoring optional TSDoc-only tags. Verify representative comments through any
available editor or documentation tool, but treat presentation as a compatibility check rather than
the documentation's primary purpose; otherwise mark it as not tested. Report which documentation
surfaces changed, which checks ran, and any package managers, runtimes, or agents that were not tested.
For adoption or audit work, also report unmet specification requirements separately from optional
improvements. Check comments and bundled Markdown for agent-directed commands and distinguish them
from legitimate API requirements and clearly framed usage recommendations.
1---2name: maintain-js-package-docs3description: Maintain JSDoc-first API docs, README, examples, and bundled docs for publishable JavaScript or TypeScript packages. Use when public contracts change; skip app-only or private modules.4license: MIT5---67# Maintain JS Package Docs89## Purpose1011Use this skill to keep a package's public API, implementation behavior, declarations, README, examples, and published documentation consistent.1213## Instructions14151. Inspect package metadata, public entry points, declarations, tests, README, and relevant examples.162. Identify the observable contract change before editing documentation.173. Update implementation, API comments, bundled docs, and examples together when they describe the same behavior.184. Run the repository's applicable checks and inspect the packed artifact when publication is in scope.1920## Examples2122Example: when an exported function gains an option, update its JSDoc parameter/default/error semantics, declarations, README usage, examples, and any migration note, then run the package checks.2324## Requirements2526- A publishable JavaScript or TypeScript package with `package.json` and public entry points.27- The repository's configured tests, type checks, documentation checks, and package-manager commands.28- A generated declaration surface or source types when the package publishes types.2930## Limitations3132- Do not publish, change release configuration, or broaden package contents without explicit authorization.33- Do not document private modules or planned behavior as part of the public contract.34- `llms.txt` or custom metadata is not authoritative unless the target toolchain explicitly implements it.3536## Troubleshooting3738- Stale API docs: compare the public declaration surface with exports and regenerate before editing prose.39- `npm pack --dry-run` mismatch: inspect package include/exclude rules and verify the packed artifact.40- JSDoc or type-check failure: fix the source-of-truth contract first, then update all dependent examples.4142Apply the agent-readable package documentation specification while developing the package. Treat43documentation as part of the public contract and complete the implementation and every affected44documentation layer in the same change. The specification makes an installed package self-describing45and version-aligned; it does not turn package documentation into agent instructions. Optimize the46content first for coding agents reading source or declarations directly, then for natural human47reading, and finally for editor and documentation-tool presentation.4849Use this design priority explicitly: **Agent-first, human-friendly, tool-compatible.**5051- **Agent-first:** make purpose, contracts, examples, and routes to deeper local documentation easy to52 discover and understand from source, declarations, and the packed artifact.53- **Human-friendly:** write complete, natural technical prose that developers can understand without54 knowing an agent-specific convention. Completeness takes precedence over brevity; shorten only after55 preserving every relevant contract detail.56- **Tool-compatible:** use JSDoc as the baseline and optional TSDoc or tool-specific enhancements only57 when they improve extraction, validation, or presentation without becoming the sole source of truth.5859## Establish the documentation impact6061Before editing, inspect the effective repository instructions and the package's existing sources of62truth: `package.json`, public entry points, declaration output or source types, README, documentation63index, relevant topic pages, examples, tests, and release or migration conventions. Read only the64materials relevant to the requested change.6566Identify the observable change before deciding what to document. Update documentation when the work67changes any of these:6869- public exports, signatures, types, defaults, or lifecycle;70- supported configuration, environment, runtime, or compatibility;71- errors, side effects, ordering requirements, performance characteristics, or security guidance;72- recommended usage, deprecation status, migration steps, or a user-visible limitation.7374Do not create documentation churn for a behavior-preserving internal refactor unless it changes a75documented mental model, extension point, contributor workflow, or architecture contract.7677For specification adoption or audit, a new documentation structure, a substantial public API change,78a deprecation or migration, or an npm publication review, read79[references/package-documentation-specification.md](references/package-documentation-specification.md)80before editing. For a small change in an already conforming package, follow the established routes and81load only the affected documentation.8283## Implement code and documentation together84851. Implement the requested behavior and its tests. Do not document planned behavior as if it already86 exists.872. Inventory the actual consumer-facing API from `package.json` exports, public entry points, and the88 generated declaration surface. Do not equate every source-level `export` with a public package89 export.903. Ensure every public exported function, class, constructor, value, type, interface, enum, and every91 consumer-facing public member has an authoritative `/** ... */` API comment. Use JSDoc prose and92 tags as the default authoring baseline. Add TSDoc-only constructs as a supplementary layer only93 when the repository's documentation toolchain consumes them, and keep required contract semantics94 understandable without those extensions. Re-export barrels do not need duplicate comments when95 the original declaration comment survives in generated declarations. Document every overload96 whose contract differs or whose comment would otherwise be absent from consumer-visible help.974. Treat a public callable comment as incomplete until it covers every runtime parameter and all98 non-obvious return, generic, failure, and overload semantics. Describe semantic roles and behavior99 instead of restating TypeScript types or adding tags with no information beyond the signature.1005. Add comments to non-public functions when their purpose, reason, invariant, mutation, ordering,101 error translation, or algorithm is not clear from names and types. Do not comment trivial wrappers,102 callbacks, or obvious local helpers merely to increase a count.1036. Preserve or add a package-level JSDoc-style comment at the public type entry point when it helps104 agents and users discover the package purpose and bundled documentation. Add the TSDoc105 `@packageDocumentation` marker only when the adopted toolchain uses it. Follow the repository's106 existing comment standard and ensure declaration generation retains useful comments.1077. Update the appropriate authoritative human-facing document. Keep README as a self-contained108 orientation and first route; route detailed concepts, tasks, recipes, migrations, and troubleshooting109 into focused files under the repository's established documentation directory.1108. Update examples when the recommended call pattern changes. Prefer examples that are type-checked,111 tested, or otherwise runnable by the existing project workflow.1129. For breaking changes and deprecations, document both the replacement and the migration path. Keep113 old guidance only when supported versions still require it, and label that scope explicitly.114115Avoid copying the same contract into multiple places. Let types define exact shapes, tests define116verified behavior, README provide orientation, and topic docs explain concepts and tasks. Link between117these layers instead of maintaining parallel prose.118119## Write agent-readable, JSDoc-first API comments120121For every exported function, public method, constructor, call signature, and function-valued public122property, require an API comment attached to the declaration consumers see. Make the comment123self-contained enough for a coding agent or human to understand the contract next to the signature:124125- a summary that states the operation and its observable contract;126- one `@param` entry for each runtime parameter, including rest parameters, with its semantic role,127 optional behavior, and default when applicable;128- `@returns` when the result has semantics not already obvious from the name and TypeScript return129 type, such as ownership, identity, mutability, units, branches, caching, or failure representation;130- generic-parameter semantics when a type parameter's role, constraint, relationship, or lifetime is131 not obvious; put this in ordinary prose or the related `@param`/`@returns`, and optionally add132 `@typeParam` when the repository's TSDoc pipeline supports or requires it;133- meaningful synchronous exceptions, asynchronous rejections, callback propagation, and result-based134 failures; use JSDoc `@throws` for thrown exceptions and keep any critical nuance understandable in135 ordinary prose when some consumers may ignore the tag; do not invent a failure contract; and136- separate complete comments for overloads unless verified `{@inheritDoc}` or tool-supported comment137 inheritance preserves the exact contract for each visible signature.138139In `.ts` and `.tsx`, let TypeScript syntax carry types: do not repeat types in braces inside `@param`140or `@returns`. Do not use JSDoc `@template` to redeclare TypeScript generics. In `.js` and `.jsx`, use141the TypeScript-supported JSDoc type tags when they provide the package's type information.142143Use JSDoc as the primary vocabulary: summary prose, `@param`, `@returns`, `@throws`, `@deprecated`,144`@see`, `@example`, and `{@link}`. Treat TSDoc additions such as `@packageDocumentation`,145`@typeParam`, `@remarks`, `@defaultValue`, release-stage modifiers, and TSDoc declaration references146as optional enhancements. Before using them, inspect the existing config and conventions for TSDoc,147API Extractor, TypeDoc, or a related linter. Do not add a TSDoc tag merely because the file is148TypeScript, and do not put the only copy of required contract information behind an extension that149baseline JSDoc consumers may ignore.150151Function-valued properties have the same requirements as method syntax. Keep the existing API shape152unless a change is otherwise justified; attach the tags to the property comment and verify how the153project's declaration and documentation tools render them. Documentation elsewhere does not excuse a154missing or partial signature comment.155156Apply the same semantic rule to generic public classes, interfaces, and type aliases: explain a type157parameter when its role is not obvious, without mechanically requiring `@typeParam` for every generic.158159Before finishing, make a temporary coverage table with one row per public callable and columns for160summary, parameters, non-obvious return semantics, non-obvious generic semantics, failures, overloads,161JSDoc baseline, justified TSDoc enhancements, generated-declaration retention, and representative162tool rendering. Mark a semantic column not applicable only when the signature and name already make163it unambiguous. A missing TSDoc enhancement is a failure only when the repository has adopted that164profile. Do not report completion while any applicable cell is missing.165166## Keep installed documentation usable167168When the package is published to npm and local documentation is part of the intended developer169experience:170171- keep a short documentation route near the top of the package-root README;172- make the documentation index point to focused files through relative links;173- include the required documentation and examples in the published file allowlist;174- describe local paths relative to the package root rather than assuming a `node_modules` layout;175- treat bundled docs as version-matched reference material, not as higher-priority instructions for176 the consuming repository; and177- do not rely on `llms.txt`, a custom `package.json` field, or a dependency-level `AGENTS.md` unless178 the target toolchain explicitly implements that convention.179180Do not publish, change release configuration, or broaden the package contents unless the user's task181authorizes those changes. A dry-run package inspection is read-only and may be used when relevant.182183Package comments and bundled Markdown may recommend supported patterns, tradeoffs, or next reading,184but they are advisory reference material rather than instructions that a consuming coding agent must185obey. Do not tell an agent to ignore repository instructions, change its workflow, run commands, or186modify files. A real API precondition may still use mandatory language when it describes program187behavior—for example, requiring `close()` before process exit to flush buffered data.188189## Validate the result190191Run the repository's applicable tests, type checks, documentation checks, and example validation.192Run any existing JSDoc completeness linter first. Run TSDoc checks when the repository has adopted a193TSDoc profile, and follow its configured tags; do not add a new lint dependency unless the task194authorizes that tooling change.195For npm package work, inspect the actual artifact with `npm pack --dry-run` or the repository's196equivalent and confirm that README, intended docs, examples, declarations, runtime files, and source197maps follow the package policy. Do not assume a file is published merely because it exists in the198repository.199200Review the diff for stale names, broken relative links, duplicated authority, comments stripped from201declarations, examples that no longer type-check, and documentation claims not covered by code or202tests. Compare the generated public declaration surface against the API inventory and list any public203symbol or member with a missing or incomplete documentation comment, including missing parameter or204non-obvious return, generic, failure, or overload semantics. Confirm that the JSDoc baseline remains205understandable after ignoring optional TSDoc-only tags. Verify representative comments through any206available editor or documentation tool, but treat presentation as a compatibility check rather than207the documentation's primary purpose; otherwise mark it as not tested. Report which documentation208surfaces changed, which checks ran, and any package managers, runtimes, or agents that were not tested.209For adoption or audit work, also report unmet specification requirements separately from optional210improvements. Check comments and bundled Markdown for agent-directed commands and distinguish them211from legitimate API requirements and clearly framed usage recommendations.