Use this skill to write well-formed JSDoc for Effect public APIs.
Workflow
When updating public API JSDoc:
- Inspect the declaration, implementation, nearby tests, and nearby JSDoc before editing.
- Decide whether the task is a single API fix or a module refinement pass.
- Rewrite comments into the required documentation shape while preserving correct facts and examples.
- Run the
@seeaudit. - Run the
**Gotchas**audit. - Run the narrowest relevant validation.
Required documentation shape
Use a normal multiline JSDoc comment in TypeScript source:
/**
* Short description as one paragraph.
*
* **When to use**
*
* Optional practical usage guidance.
*
* **Details**
*
* Optional details for complex APIs, options, overloads, or behavior.
*
* **Gotchas**
*
* Optional edge cases, footguns, or surprising behavior.
*
* **Example** (Short title)
*
* Optional prose explaining the example.
*
* ```ts
* const result = example()
* ```
*
* @category constructors
* @since 1.0.0
*/
Writing rules
- Use sober, practical prose.
- Write all public JSDoc prose in English.
- Do not use jargon when a plain word works.
- Do not be clever.
- Do not add filler sections.
- The short description is required and must be exactly one paragraph.
- Optional sections must appear in this order:
**When to use****Details****Gotchas**
- Include an optional section only when it has useful, non-empty content.
**When to use**is important when the API has close alternatives, trade-offs, or@seetags. If@seetags are present, inspect the referenced APIs and add**When to use**when it helps readers choose between them.- Add
@seeonly for APIs that are similar to the documented API but intended for different situations or usage patterns. Do not add@seefor loosely related helpers, dependencies, implementation details, or general background links. - If an API has close alternatives and no
@seetags, inspect the alternatives before deciding whether@seewould help readers choose the right API. - Before deciding whether to include
**Gotchas**, inspect the implementation and nearby tests for edge cases, footguns, preconditions, surprising behavior, or important failure modes. Add**Gotchas**only when you find a real gotcha worth documenting. - If a
Detailssection explains behavior that changes how the API must be used safely or correctly, treat it as a**Gotchas**candidate and make an explicit keep-or-move decision. - Use exactly one blank line between the short description, sections, examples, and tags.
- Do not use Markdown headings such as
# Headingor ad hoc bold headings such as**Notes**; only the standard headings are allowed. - Examples must use
**Example** (Title), optional prose, and exactly one non-emptytscode fence. - Example titles must be unique after trimming and lowercasing.
- Prefer examples with stable, deterministic output. Avoid assertions or
console.logcomments that depend on stack traces, object inspection,Errorformatting, concurrency order, timing, randomness, or environment-specific formatting. Examples may assume Node.js console formatting. DirectSet/Mapoutput is acceptable when insertion order is deterministic and the expected output uses Node's format; otherwise demonstrate a stable property instead. - Do not use
@example. - Do not put TypeScript code fences outside
**Example** (Title)sections. - Inline
{@link Symbol}targets must resolve to TypeScript symbols; do not link to URLs with{@link}. - Avoid overlinking in prose. Use
{@link Symbol}only when navigation to that symbol helps the reader choose or understand the API. For the API being documented, the module's central type, nearby obvious names, or repeated mentions, prefer plain code formatting such asCause,Effect, orContext. - Do not document module-level comments; module JSDoc is ignored by this rule.
@internalmeans the item is ignored; do not rewrite it as public docs.- Default exports are ignored by this rule and do not need JSDoc.
- Do not add unsupported constructs such as enums or empty exports in checked files.
Tag rules
When multiple tags are present, keep them in this order:
@deprecated@default@see@category@since
Root declarations:
- Require
@category. - Require
@sincewith stable semver like1.2.3. - May use
@deprecatedwith a non-empty message. - May use repeated non-empty
@seetags, but only for similar APIs with different usage patterns. - Must not use
@default.
Namespaces and declarations inside namespaces:
- Require
@sincewith stable semver like1.2.3. - May use optional
@category. - May use
@deprecatedwith a non-empty message. - May use repeated non-empty
@seetags, but only for similar APIs with different usage patterns. - Must not use
@default.
Members:
- JSDoc is optional.
- When member JSDoc is present, it must follow the same short description, section, example, spacing, and tag-order rules.
- May use optional
@sincewith stable semver like1.2.3. - May use
@defaultwith a non-empty value. - May use
@deprecatedwith a non-empty message. - May use repeated non-empty
@seetags, but only for similar APIs with different usage patterns. - Must not use
@category.
Updating existing JSDoc
When fixing or updating existing docs:
- Preserve correct facts and examples.
- Rewrite the layout into the standard template.
- Move usage guidance into
**When to use**; when@seetags are present, inspect the referenced APIs and explain selection guidance if useful. - Move option, overload, and behavior details into
**Details**. - Move caveats into
**Gotchas**; if no caveat is already documented, inspect the implementation and nearby tests before deciding whether a**Gotchas**section is warranted. - Convert
@exampletags and loosetsfences into**Example** (Title)sections. - Preserve valid
@see,@deprecated,@default,@category, and@sincetags. - Remove
@seetags that do not point to similar APIs with meaningfully different usage patterns. - Replace redundant inline
{@link ...}tags with plain code formatting when the link target is already obvious from the current declaration or module. - Remove sections that would be empty.
Module refinement
When asked to refine an existing module:
- First scan the module for local documentation patterns, repeated API families, and category conventions.
- Keep the change focused on documentation quality unless the user also asked for rule or source changes.
- Prefer improving existing comments over rewriting every comment into a new voice.
- Preserve examples unless they are wrong, stale, nondeterministic, or fail the required documentation shape.
- Apply the
@seeand**Gotchas**audits across the module before finishing.
See audit
When refining an existing public API module, always do a dedicated @see pass:
- Inspect existing
@seetags and referenced APIs before keeping, changing, or removing them. - Look for close alternatives in the same module or API family when the documented API is one of several ways to do similar work.
- Keep or add
@seeonly when the linked API is a real alternative a reader may choose instead of the documented API. - Do not use
@seefor implementation dependencies, broad concepts, result types, helper APIs used only inside examples, or APIs that are merely compatible. - When
@seetags are kept or added, include**When to use**guidance if the difference between the APIs is not obvious from the short description.
Gotchas audit
When refining an existing public API module, always do a dedicated **Gotchas** pass:
- Scan existing prose for caveat language: warnings, exceptions, limitations, preconditions, special cases, or behavior that is easy to misuse.
- Inspect the implementation and nearby tests for behavior that is not obvious from the type signature or short description.
- Move real caveats from
**Details**into**Gotchas**when they describe edge cases, footguns, preconditions, surprising behavior, or important failure modes. - Add
**Gotchas**only when the caveat is concrete and useful to a reader choosing or using the API. - If no gotchas are added during a refinement pass, state that a gotchas audit was performed and why no caveats were worth documenting.
Validation
Run the narrowest validation that matches the change:
- For JSDoc or example changes in a package with generated docs, run
pnpm docgenfrom that package directory. - Run
pnpm lintbecause the linter includes the custom rule that checks public API JSDoc. - Do not run broad validation for prose-only skill edits.