Skip to main content

Documentation Guide

This document describes the types of documentation we maintain, the automation (pnpm scripts, Cursor skills, and rules), and a runbook for common tasks.


1. Types of Documentation

TypeLocationPurposeSource / How updated
API docsdocs/api/REST endpoint reference: routes, request/response schemas, authGenerated from src/endpoints/**/*.endpoint.ts and src/data/**/*.endpoint.ts; update via generate-api-docs skill
Command docsdocs/commands/Discord bot slash commands, parameters, permissionsGenerated from src/data/**/*.command.ts; update via generate-command-docs skill
Reference docsdocs/reference/Service, repository, and validator contracts (method signatures, types)Generated from src/data/**/*.service.ts, *.repository.ts, *.validators.ts; update via generate-reference-docs skill
Customer docsdocs/customer/User-facing guides by persona (admin, guild member, developer)Authored; update via author-customer-docs skill
Developer docsdocs/developer/Architecture, onboarding, conventions, layer READMEsAuthored; update via author-developer-docs skill
Release notesdocs/releases/Changelog and semantic-release historyConventional commits on main drive semantic-release versioning and changelog updates in docs/releases/CHANGELOG.md; GitHub Releases are published automatically
Runbooksdocs/runbooks/Operational procedures: deployment, incidents, maintenanceAuthored markdown; add as needed
Implementation plansdocs/plans/Linear-issue implementation plans (from workon)Created by Linear workflow; reference only
AI Ecosystemdocs/ai-ecosystem/Cursor setup, skills, rules, MCP, external services, local toolingAuthored narrative + generated Reference via pnpm docs:ai-ecosystem:generate
Top-leveldocs/*.mdARCHITECTURE, CONTRIBUTING, AGENTS, SOW, config, authAuthored; edit directly

The docs site is built with Docusaurus 3 from docs-site/ and sources content from the docs/ tree. The live site is deployed to Render when docs/, docs-site/, or src/**/*.documentation.md changes on main.

Pre-commit doc update: Before every commit, scripts/docs/pre-commit-doc-update.mjs runs. It loads the source-of-truth rules from scripts/docs/documentation-types.rules.json, looks at the staged diff, and determines which doc types are affected (API, commands, reference, customer, developer, AI Ecosystem). It runs generators we have (e.g. docs:ai-ecosystem:generate when .cursor/ changed) and stages their output. For types that require the AI (API, command, reference, customer, developer), it either runs your DOC_UPDATE_CMD (if set) or writes a prompt to scripts/docs/.pre-commit-doc-prompt.md and blocks the commit until you run that prompt in Cursor, update the docs, stage them, and commit again. So every commit that touches endpoints, commands, services, or persona-relevant code either includes the doc updates in the same commit or fails with clear instructions.

To enable full automatic AI doc updates from pre-commit, set:

export DOC_UPDATE_CMD="bash scripts/docs/doc-update-cmd.sh"

The wrapper scripts/docs/doc-update-cmd.sh is production-ready and uses cursor-agent to run doc updates in parallel by doc type (API, commands, reference, customer personas, developer guide). See AI Ecosystem docs for the full behavior and optional env vars (MAX_PARALLEL_DOC_AGENTS, DOC_UPDATE_CURSOR_MODEL, etc.).


2. pnpm Scripts (Documentation)

ScriptCommandDescription
docs:devpnpm docs:devStart the Docusaurus dev server (hot reload). Use when writing or reviewing docs locally.
docs:buildpnpm docs:buildInstall docs-site deps and build the static site. Runs in CI; must pass for merge.
releasepnpm releaseRun semantic-release on main: compute next semver from conventional commits, update changelog, tag, and publish GitHub Release.
release:drypnpm release:dryDry-run semantic-release locally/CI to validate next version and generated notes without publishing.
docs:ai-ecosystem:generatepnpm docs:ai-ecosystem:generateRegenerate docs/ai-ecosystem/reference.md from .cursor/skills, .cursor/rules, .cursor/commands, and .cursor/mcp.json. Run after adding or changing any skill, rule, command, or MCP server.
docs:pre-commit-updatepnpm docs:pre-commit-updateRun the same logic as the pre-commit hook: from staged files, determine affected doc types, run generators, and exit 1 with a prompt path if AI doc updates are required. Used by Husky pre-commit.

API, command, and reference docs are regenerated using the Cursor skills below (or by editing generated files only when necessary, respecting the generated-docs-readonly rule).


3. Cursor Skills (Documentation)

Use these from Cursor when you need to create or refresh documentation.

SkillWhen to useWhat it does
generate-api-docsEndpoint files (*.endpoint.ts) added or changedGenerates/updates docs/api/<feature>.md per endpoint group; documents method, path, body, response, auth; reminds to run pnpm docs:build.
generate-command-docsCommand files (*.command.ts) added or changedGenerates/updates docs/commands/<feature>.md and catalog; documents command name, params, permissions; reminds to run pnpm docs:build.
generate-reference-docsServices, repositories, or validators added or changedGenerates/updates docs/reference/<feature>.md with method signatures, repository contract, validator schemas; reminds to run pnpm docs:build.
author-customer-docsUser-facing features added or changedCreates/updates persona docs in docs/customer/admin/, guild-member/, or developer/ with clear steps and examples.
author-developer-docsArchitecture, onboarding, or conventions changedUpdates docs/developer/ and layer READMEs; keeps alignment with docs/ARCHITECTURE.md.

Skills live under .cursor/skills/. Invoke by name in Cursor when the task matches “when to use” above.


4. Cursor Rules (Documentation)

These rules enforce documentation contracts. They live under .cursor/rules/.

RulePurpose
api-doc-contractWhen changing *.endpoint.ts, update or create docs/api/<feature>.md and run pnpm docs:build. Use generate-api-docs skill.
command-doc-contractWhen changing *.command.ts, update or create docs/commands/<feature>.md and run pnpm docs:build. Use generate-command-docs skill.
service-doc-contractWhen changing *.service.ts, *.repository.ts, or *.validators.ts, update or create docs/reference/<feature>.md and run pnpm docs:build. Use generate-reference-docs skill.
generated-docs-readonlyTreat docs/api/, docs/commands/, and docs/reference/ as generated; don’t edit by hand except to fix urgent issues. Update source and re-run the corresponding skill. READMEs in those dirs may be edited.
documentation-and-commentsCode-level: JSDoc for exported/shared symbols; inline comments for non-obvious logic. Applies to src/**/*.ts. Keeps source the single source of truth for generated API/reference docs.

5. Cursor Commands

There are no documentation-specific Cursor commands. Documentation work is done via the skills above and the pnpm scripts in §2. General commands (e.g. workon, openpr) are unchanged.


6. Runbook: do this when you want that

GoalWhat to do
Preview the docs site locallyRun pnpm docs:dev and open the URL (e.g. http://localhost:3000).
Check that the docs site builds (e.g. before pushing)Run pnpm docs:build. Fix any build or link errors.
Add or change an API endpoint1) Implement in *.endpoint.ts. 2) Use generate-api-docs skill (or update docs/api/<feature>.md and keep it in sync). 3) Run pnpm docs:build.
Add or change a Discord command1) Implement in *.command.ts. 2) Use generate-command-docs skill (or update docs/commands/<feature>.md). 3) Run pnpm docs:build.
Add or change a service, repository, or validator1) Implement in src/data/<feature>/. 2) Use generate-reference-docs skill (or update docs/reference/<feature>.md). 3) Run pnpm docs:build.
Document something for admins, guild members, or API usersUse author-customer-docs skill; add or edit pages under docs/customer/admin/, docs/customer/guild-member/, or docs/customer/developer/. Run pnpm docs:build.
Update architecture, onboarding, or developer conventionsUse author-developer-docs skill; edit docs/developer/ and/or docs/ARCHITECTURE.md, docs/CONTRIBUTING.md, docs/AGENTS.md as needed. Run pnpm docs:build.
Add a user-visible change to release notesUse conventional commits in your PR (feat, fix, perf, and BREAKING CHANGE), merge to main, and let semantic-release update changelog/tags/releases automatically.
Preview next release version/notes before mergeRun pnpm release:dry. This validates semantic-release parsing and shows the computed next version and notes without creating a tag/release.
Document an operational procedure (deploy, incident, maintenance)Add a new markdown file under docs/runbooks/ with clear steps and link it from docs/runbooks/README.md if useful.
Fix a typo or small error in generated API/command/reference docsEdit the file in docs/api/, docs/commands/, or docs/reference/ if necessary, but prefer fixing the source and re-running the corresponding generate-* skill so the fix persists.
See why the docs build failed in CICheck the job that runs pnpm docs:build (e.g. in ci.yml). Fix broken links, invalid frontmatter, or missing files.
Deploy the docs sitePush changes to main that touch docs/, docs-site/, or src/**/*.documentation.md; the docs-deploy workflow runs and Render deploys from the repo. No manual deploy step.
Add or change a Cursor skill, rule, command, or MCP serverPre-commit runs docs:pre-commit-update, which runs docs:ai-ecosystem:generate when .cursor/ changed and stages reference.md. No extra step unless you bypass the hook.
Commit code that touches endpoints, commands, or servicesPre-commit runs first. If API/command/reference/customer/developer docs are affected, the hook writes scripts/docs/.pre-commit-doc-prompt.md and fails. In Cursor, run that prompt to update all affected docs, then git add docs/ and commit again. For full automation, set DOC_UPDATE_CMD and have that wrapper run AI updates (optionally parallel subagents).

Tenant-customizable legal document templates live under docs/legal/. The set includes a privacy policy, terms of service, refund policy, and cookie policy — each pre-wired for the platform's third-party integrations (Stripe, NOWPayments, TaxJar, SendGrid, EasyPost, Discord) and using a consistent placeholder vocabulary. See docs/legal/README.md for customization instructions.


7. Release Conventions

  • Canonical source: Conventional commits merged to main.
  • Versioning: semantic-release computes semver and creates release tags.
  • Release notes: semantic-release generates notes and updates docs/releases/CHANGELOG.md.

8. CI and Deployment

  • CI: pnpm docs:build runs in the main pipeline. The branch cannot merge if the docs site fails to build.
  • Release: On successful CI completion for main, the Release workflow runs pnpm release (semantic-release) to compute semver, update changelog, tag, and publish GitHub release notes.
  • Deploy: The docs-deploy workflow runs on push to main when paths under docs/, docs-site/, or src/**/*.documentation.md change. Render builds and serves the static site per render.yaml.