Package Scribe
Experimental caveat
This skill is experimental and not yet stable. Behavior, structure, and outputs may change between versions.
When to use
Use when you need to systematically add or improve documentation across TypeScript packages — whether a full monorepo sweep or a single package.
Typical triggers:
- "document all packages"
- "improve docs for
packages/utils/observable"
- "add TSDoc to all public exports in this package"
- "rewrite the README for this package"
- "run a documentation pass on the monorepo"
- "review the TSDoc quality in this package"
Implicit triggers:
- A package has public exports with missing or stub TSDoc
- A package README is outdated, inconsistent, or missing standard sections
- A documentation sweep is planned across multiple packages
When not to use
- Modifying runtime code (only doc comments and README files)
- Generating API reference sites or TypeDoc output
- Non-TypeScript languages (initial scope is TS/TSX only)
- Auto-merging PRs or bypassing review workflows
- Security vulnerability scanning or performance profiling
- Replacing existing CI-based doc generation pipelines
Required inputs
If required inputs are missing or ambiguous, ask before proceeding.
- Scope: monorepo root path or specific package path(s)
- Mode:
single (one package) or sweep (multiple packages)
Conditional inputs
- Package filter: glob or list when processing a subset of packages
- README template path: repo-specific template if not using the built-in default (for example under
.github/instructions/)
- Tracking issue: issue number for lifecycle updates (assign, status, close)
- Commit style: repo-specific conventional commit format (defaults to
docs(<package>): )
- Batch size: number of packages per batch for sweep mode (defaults to 5)
Defaults
- Mode:
single (if only one package path provided)
- Commit prefix:
docs(<package-name>):
- Batch size: 5 packages per sweep batch
- README structure: built-in template from
references/readme-template.md
- Review council: enabled (runs after every package)
Precedence and standards discovery
This skill discovers and follows the target repository's own standards:
- Repository instructions — applicable files under
.github/instructions/, CONTRIBUTING.md, contribute/
- Tooling configuration —
tsconfig.json, biome.json, .editorconfig
- Companion skill —
fusion-code-conventions for TSDoc rules, naming conventions, and intent quality (when installed)
- Built-in defaults —
references/tsdoc-checklist.md and references/readme-template.md
Repository-level standards always win. When no repo standards exist, the built-in defaults apply.
Agent modes
| Agent |
Role |
Activated for |
agents/orchestrator.agent.md |
Batch coordinator |
Sweep mode — plans batches, manages token budgets, tracks progress |
agents/documenter.agent.md |
Per-package writer |
Every package — scans API surface, generates TSDoc, rewrites README |
agents/reviewer.agent.md |
Review council |
After each package — verifies intent, comprehension, retrieval fitness |
In single-agent runtimes, all three roles run inline sequentially.
Instructions
Step 1 — Discover repository standards
Before generating any documentation:
- Search for repo-level documentation instructions:
- applicable files under
.github/instructions/
CONTRIBUTING.md, contribute/
- Read
tsconfig.json to understand module structure, path aliases, and strict mode settings
- Read
biome.json or equivalent linter config for style expectations
- Check if
fusion-code-conventions is available — if so, defer to its TSDoc rules from references/typescript.conventions.md
- If no repo-level standards exist, use
references/tsdoc-checklist.md as the quality baseline
Step 2 — Discover packages
- For single mode: validate the provided package path exists and has TypeScript source files
- For sweep mode:
- Read the root
package.json or workspace config (pnpm-workspace.yaml, lerna.json, turbo.json) to find all packages
- Filter by any provided glob/list
- Sort packages by estimated size (file count) for batch planning
- Write the discovery summary to
.tmp/scribe-discovery-<context>.md
Step 3 — Plan execution (sweep mode only)
Activate agents/orchestrator.agent.md (or run inline):
- Group packages into batches of the configured batch size
- Order batches: smaller packages (fewer source files) first to maximize early throughput
- Estimate token budget per package: ~100 tokens per source file for reading, ~200 tokens per export for TSDoc generation
- If a single package exceeds 60% of the estimated context window, flag it for special handling (barrel exports first, defer internal modules)
- Write the execution plan to
.tmp/scribe-plan-<context>.md
Step 4 — Process each package
Activate agents/documenter.agent.md (or run inline) for each package:
4a — Scan public API surface
- Find the barrel export file (
index.ts, index.tsx, or main field in package.json)
- Trace all re-exports to identify the full public API surface
- Categorize exports: functions, classes, types/interfaces, constants, hooks, enums
- Prioritize: barrel exports first, then direct public exports, then internally-consumed-but-exported items
4b — Generate or improve TSDoc
For each public export:
- Read the existing implementation to understand intent, parameters, return values, error paths, and side effects
- Check for existing TSDoc — improve rather than replace when present
- Apply the TSDoc checklist (repo standards or
references/tsdoc-checklist.md):
- Summary line: explain why and what problem it solves, not just what it does
@param for every parameter with meaningful descriptions
@returns for every non-void function
@template for every generic type parameter
@throws for meaningful error paths
@example for user-facing and non-trivial public APIs
@deprecated with replacement guidance when applicable
- Flag and rewrite "name-echo" patterns (for example
/** Gets the value. */ getValue())
- Do not modify runtime code — only doc comments
4c — Rewrite or improve README
- Read the existing README (if any) to preserve valuable content
- Apply the README structure from repo instructions or
references/readme-template.md:
- Package name and description
- Features / key exports
- Installation
- Usage with code examples
- API reference (summary of key exports with links or inline docs)
- Configuration (if applicable)
- Ensure the README is useful to a developer discovering the package for the first time
- Optimize for retrieval: use clear headings, keyword-rich descriptions, and concrete examples
Step 5 — Review council
Activate agents/reviewer.agent.md (or run inline) after each package:
- Intent extraction — Does the TSDoc accurately describe what the code does and why? Flag any comment that merely restates the function/type name.
- Code comprehension — Are complex algorithms, state machines, or side effects explained? Would a new developer understand the code from the docs alone?
- User-facing quality — Is the README useful to someone discovering the package for the first time? Does it have working examples?
- Retrieval fitness — Will the documentation produce good hits in RAG / semantic search? Are key terms present in headings and summaries?
The reviewer produces a pass/fail per criterion. Failures loop back to Step 4 for the specific package.
Step 6 — Commit
After the review council passes for a package:
- Stage only documentation files (
.ts/.tsx files for TSDoc changes, README.md)
- Commit using the repo's conventional commit format, defaulting to:
docs(<package-name>): improve TSDoc and README documentation
- Do not push — leave that to the user or a PR workflow
Step 7 — Report
After all packages are processed:
- Write a summary to
.tmp/scribe-report-<context>.md:
- Packages processed and status (pass/fail/skipped)
- Total exports documented
- Review council pass rates per criterion
- Any packages flagged for manual review
- Commits created
- If a tracking issue was provided, update it with the summary
Expected output
- TSDoc comments on all public exports in processed packages
- Consistent README for each processed package
- One commit per package with documentation-only changes
- Summary report in
.tmp/
- Tracking issue update (when issue number provided)
Safety & constraints
This skill is mutation-capable. Repository-local workflow instructions take precedence over inline guidance when they conflict.
- Only modify doc comments and README files — never touch runtime code
- Do not push commits; leave push decisions to the user
- Do not auto-merge PRs or bypass review workflows
- Do not invent API behavior — document only what the code actually does
- Do not delete or replace existing valuable documentation without preserving its content
- When a tracking issue is referenced, update it only after explicit confirmation
- Respect
.gitignore and do not commit temporary files from .tmp/
- If the review council fails a package twice, flag it for manual review instead of looping indefinitely
1---2name: fusion-package-scribe3description: Systematically improves TSDoc and README documentation across packages in a TypeScript monorepo. Discovers public API surfaces, generates or improves TSDoc on all exports, rewrites READMEs to a consistent retrieval-friendly structure, and commits each package independently. USE FOR: monorepo-wide documentation passes, single-package doc improvements, TSDoc generation on public exports, README standardization, review council quality checks. DO NOT USE FOR: runtime code changes, security scanning, API reference site generation, non-TypeScript languages.4license: MIT5---67# Package Scribe89## Experimental caveat1011This skill is experimental and not yet stable. Behavior, structure, and outputs may change between versions.1213## When to use1415Use when you need to systematically add or improve documentation across TypeScript packages — whether a full monorepo sweep or a single package.1617Typical triggers:18- "document all packages"19- "improve docs for `packages/utils/observable`"20- "add TSDoc to all public exports in this package"21- "rewrite the README for this package"22- "run a documentation pass on the monorepo"23- "review the TSDoc quality in this package"2425Implicit triggers:26- A package has public exports with missing or stub TSDoc27- A package README is outdated, inconsistent, or missing standard sections28- A documentation sweep is planned across multiple packages2930## When not to use3132- Modifying runtime code (only doc comments and README files)33- Generating API reference sites or TypeDoc output34- Non-TypeScript languages (initial scope is TS/TSX only)35- Auto-merging PRs or bypassing review workflows36- Security vulnerability scanning or performance profiling37- Replacing existing CI-based doc generation pipelines3839## Required inputs4041If required inputs are missing or ambiguous, ask before proceeding.4243- **Scope**: monorepo root path or specific package path(s)44- **Mode**: `single` (one package) or `sweep` (multiple packages)4546### Conditional inputs4748- **Package filter**: glob or list when processing a subset of packages49- **README template path**: repo-specific template if not using the built-in default (for example under `.github/instructions/`)50- **Tracking issue**: issue number for lifecycle updates (assign, status, close)51- **Commit style**: repo-specific conventional commit format (defaults to `docs(<package>): `)52- **Batch size**: number of packages per batch for sweep mode (defaults to 5)5354## Defaults5556- Mode: `single` (if only one package path provided)57- Commit prefix: `docs(<package-name>):`58- Batch size: 5 packages per sweep batch59- README structure: built-in template from `references/readme-template.md`60- Review council: enabled (runs after every package)6162## Precedence and standards discovery6364This skill discovers and follows the target repository's own standards:65661. **Repository instructions** — applicable files under `.github/instructions/`, `CONTRIBUTING.md`, `contribute/`672. **Tooling configuration** — `tsconfig.json`, `biome.json`, `.editorconfig`683. **Companion skill** — `fusion-code-conventions` for TSDoc rules, naming conventions, and intent quality (when installed)694. **Built-in defaults** — `references/tsdoc-checklist.md` and `references/readme-template.md`7071Repository-level standards always win. When no repo standards exist, the built-in defaults apply.7273## Agent modes7475| Agent | Role | Activated for |76|---|---|---|77| `agents/orchestrator.agent.md` | Batch coordinator | Sweep mode — plans batches, manages token budgets, tracks progress |78| `agents/documenter.agent.md` | Per-package writer | Every package — scans API surface, generates TSDoc, rewrites README |79| `agents/reviewer.agent.md` | Review council | After each package — verifies intent, comprehension, retrieval fitness |8081In single-agent runtimes, all three roles run inline sequentially.8283## Instructions8485### Step 1 — Discover repository standards8687Before generating any documentation:88891. Search for repo-level documentation instructions:90 - applicable files under `.github/instructions/`91 - `CONTRIBUTING.md`, `contribute/`922. Read `tsconfig.json` to understand module structure, path aliases, and strict mode settings933. Read `biome.json` or equivalent linter config for style expectations944. Check if `fusion-code-conventions` is available — if so, defer to its TSDoc rules from `references/typescript.conventions.md`955. If no repo-level standards exist, use `references/tsdoc-checklist.md` as the quality baseline9697### Step 2 — Discover packages98991. For **single mode**: validate the provided package path exists and has TypeScript source files1002. For **sweep mode**:101 - Read the root `package.json` or workspace config (`pnpm-workspace.yaml`, `lerna.json`, `turbo.json`) to find all packages102 - Filter by any provided glob/list103 - Sort packages by estimated size (file count) for batch planning104 - Write the discovery summary to `.tmp/scribe-discovery-<context>.md`105106### Step 3 — Plan execution (sweep mode only)107108Activate `agents/orchestrator.agent.md` (or run inline):1091101. Group packages into batches of the configured batch size1112. Order batches: smaller packages (fewer source files) first to maximize early throughput1123. Estimate token budget per package: ~100 tokens per source file for reading, ~200 tokens per export for TSDoc generation1134. If a single package exceeds 60% of the estimated context window, flag it for special handling (barrel exports first, defer internal modules)1145. Write the execution plan to `.tmp/scribe-plan-<context>.md`115116### Step 4 — Process each package117118Activate `agents/documenter.agent.md` (or run inline) for each package:119120#### 4a — Scan public API surface1211221. Find the barrel export file (`index.ts`, `index.tsx`, or `main` field in `package.json`)1232. Trace all re-exports to identify the full public API surface1243. Categorize exports: functions, classes, types/interfaces, constants, hooks, enums1254. Prioritize: barrel exports first, then direct public exports, then internally-consumed-but-exported items126127#### 4b — Generate or improve TSDoc128129For each public export:1301311. Read the existing implementation to understand intent, parameters, return values, error paths, and side effects1322. Check for existing TSDoc — improve rather than replace when present1333. Apply the TSDoc checklist (repo standards or `references/tsdoc-checklist.md`):134 - Summary line: explain *why* and *what problem it solves*, not just *what it does*135 - `@param` for every parameter with meaningful descriptions136 - `@returns` for every non-void function137 - `@template` for every generic type parameter138 - `@throws` for meaningful error paths139 - `@example` for user-facing and non-trivial public APIs140 - `@deprecated` with replacement guidance when applicable1414. Flag and rewrite "name-echo" patterns (for example `/** Gets the value. */ getValue()`)1425. Do not modify runtime code — only doc comments143144#### 4c — Rewrite or improve README1451461. Read the existing README (if any) to preserve valuable content1472. Apply the README structure from repo instructions or `references/readme-template.md`:148 - Package name and description149 - Features / key exports150 - Installation151 - Usage with code examples152 - API reference (summary of key exports with links or inline docs)153 - Configuration (if applicable)1543. Ensure the README is useful to a developer discovering the package for the first time1554. Optimize for retrieval: use clear headings, keyword-rich descriptions, and concrete examples156157### Step 5 — Review council158159Activate `agents/reviewer.agent.md` (or run inline) after each package:1601611. **Intent extraction** — Does the TSDoc accurately describe *what the code does* and *why*? Flag any comment that merely restates the function/type name.1622. **Code comprehension** — Are complex algorithms, state machines, or side effects explained? Would a new developer understand the code from the docs alone?1633. **User-facing quality** — Is the README useful to someone discovering the package for the first time? Does it have working examples?1644. **Retrieval fitness** — Will the documentation produce good hits in RAG / semantic search? Are key terms present in headings and summaries?165166The reviewer produces a pass/fail per criterion. Failures loop back to Step 4 for the specific package.167168### Step 6 — Commit169170After the review council passes for a package:1711721. Stage only documentation files (`.ts`/`.tsx` files for TSDoc changes, `README.md`)1732. Commit using the repo's conventional commit format, defaulting to:174 ```175 docs(<package-name>): improve TSDoc and README documentation176 ```1773. Do not push — leave that to the user or a PR workflow178179### Step 7 — Report180181After all packages are processed:1821831. Write a summary to `.tmp/scribe-report-<context>.md`:184 - Packages processed and status (pass/fail/skipped)185 - Total exports documented186 - Review council pass rates per criterion187 - Any packages flagged for manual review188 - Commits created1892. If a tracking issue was provided, update it with the summary190191## Expected output192193- TSDoc comments on all public exports in processed packages194- Consistent README for each processed package195- One commit per package with documentation-only changes196- Summary report in `.tmp/`197- Tracking issue update (when issue number provided)198199## Safety & constraints200201This skill is mutation-capable. Repository-local workflow instructions take precedence over inline guidance when they conflict.202203- Only modify doc comments and README files — never touch runtime code204- Do not push commits; leave push decisions to the user205- Do not auto-merge PRs or bypass review workflows206- Do not invent API behavior — document only what the code actually does207- Do not delete or replace existing valuable documentation without preserving its content208- When a tracking issue is referenced, update it only after explicit confirmation209- Respect `.gitignore` and do not commit temporary files from `.tmp/`210- If the review council fails a package twice, flag it for manual review instead of looping indefinitely