write-api-docs
SKILL.md
Write API Docs
Overview
Use this skill when documenting public APIs in Remix packages.
The goal is to document the API users can actually import, not every helper in src/lib.
Work from the package exports outward, add concise JSDoc to the public declarations, and make sure the result passes the repo's ESLint JSDoc rules.
Workflow
- Identify the package's public exports.
- Find the
srcentry files that back those exports. - Trace those entry files to the declarations they re-export from
src/lib. - Add or tighten JSDoc on the public declarations only.
- Run package typecheck if appropriate and always run
pnpm run lint.
How To Identify Public API
The source of truth is the package's package.json.
- Start with
package.jsonexports. - Each public export should map to a file directly under
src/. - Those
src/*.tsentry files define the public surface by re-exporting symbols fromsrc/lib. - A declaration in
src/libis public only if it is re-exported by one of those publicsrc/*.tsentry files.
Rules:
- Do not assume everything in
src/libis public. - Do not document private helpers just because they are exported within
src/lib. - If a declaration is not reachable from a package export, it is internal unless the user explicitly asks otherwise.
What To Document
For public API, add JSDoc to:
- exported functions
- exported classes
- exported interfaces
- exported type aliases
- exported public constants when they are part of the API shape
For public interfaces:
- add a JSDoc block on the interface itself
- add a property-level JSDoc block for every property on the interface, even when the name seems obvious
For public object-shaped type aliases:
- prefer an
interfacewhen you are introducing a new public object shape - if an existing public type alias cannot reasonably become an interface, document the object shape as thoroughly as the syntax allows
For overloads:
- document the public overload signatures or the exported declaration in a way that makes the callable surface clear to users
JSDoc Style For This Repo
Keep comments short, factual, and user-facing.
- Describe what the API does, not how the implementation works internally.
- Prefer one concise summary sentence, then short
@param/@returnsdocs as needed. - Do not put TypeScript types in JSDoc tags. ESLint forbids JSDoc type syntax here because the source of truth is the TypeScript signature.
- Keep parameter names in JSDoc exactly aligned with the function signature.
- Use
@returnsfor non-void functions and include a real description. - For
@param, include descriptions and do not add a hyphen before the description. - Specify
@paramdefault values in parenthesis at the end of the comment, do not use@defaulttags - Include an
@examplecode block when it helps to show a use-case or pattern. Skip@examplefor simple getters, trivial constructors, or APIs whose usage is self-evident. - Use
{@link API}to link to related Remix APIs when it adds value. Don't link every related API — use discretion to avoid noise. - Use backticks for all other unlinked code references — identifiers, HTTP methods, special values.
Good:
/**
* Creates an {@link AuthProvider} for direct credentials-based authentication.
*
* @param options Parsing and verification hooks for submitted credentials.
* @returns A provider that can be passed to `login()`.
*/
export function createCredentialsAuthProvider(...) {}
Avoid:
/**
* @param {CredentialsOptions} options - options
* @returns {CredentialsProvider}
*/
ESLint Expectations
The relevant rules live in eslint.config.js.
For packages/**/*.{ts,tsx} (excluding tests), ESLint enforces JSDoc on callable declarations such as:
- function declarations
- function expressions
- arrow functions
- class declarations
- public methods
Important enforced details:
jsdoc/require-paramjsdoc/require-param-namejsdoc/require-param-descriptionjsdoc/require-returnsjsdoc/require-returns-descriptionjsdoc/no-typesjsdoc/check-param-namesjsdoc/check-typesjsdoc/check-alignment
Practical implication:
- if a public function takes parameters, document all of them
- if a public function returns a value, document the return value
- do not use JSDoc type annotations
- keep the block formatted cleanly enough to satisfy alignment checks
Review Checklist
- Did you start from
package.jsonexports instead of guessing fromsrc/lib? - Are all documented declarations actually reachable from a public
src/*.tsentry file? - Do all public functions and methods have JSDoc with
@paramand@returnswhere required? - Do public interfaces and type aliases have a concise doc block explaining what they represent?
- Does every property on every public interface have its own property-level JSDoc block?
- Did you avoid documenting internal helpers that are not exported publicly?
- Did
pnpm run lintpass?
Weekly Installs
2
Repository
remix-run/remixGitHub Stars
32.5K
First Seen
1 day ago
Security Audits
Installed on
amp2
cline2
opencode2
cursor2
kimi-cli2
codex2