Actionable rules for planning, writing, testing, publishing, and maintaining high-quality technical documentation sites and API references.
Your documentation is broken. You know it, your users know it, and your team definitely knows it. That tutorial still references the old API. The setup guide is three versions behind. Nobody's updated the troubleshooting section since 2022. Sound familiar?
Most development teams treat documentation as an afterthought—a box to check before shipping. The result? A graveyard of outdated guides, broken links, and frustrated users who can't figure out how to use your product. You're spending more time answering the same questions in Slack than writing code.
Here's what's actually happening:
These Cursor Rules transform documentation from a chore into an automated, maintainable system that actually stays current. Think of it as CI/CD for your docs—automated testing, validation, and deployment that keeps everything in sync.
What you get:
Instead of quarterly doc cleanups that nobody wants to do, these rules enforce quality at every commit. Broken links fail CI. Outdated screenshots get flagged. Markdown issues block merges.
Before: "We'll fix the docs later" (spoiler: you never do)
After: Documentation quality is enforced automatically
The Diátaxis framework organizes content so developers find what they need immediately—tutorials for learning, how-to guides for tasks, explanations for understanding, references for lookup.
Time saved: 15-20 minutes per lookup that would otherwise involve digging through multiple sources
New developers get productive faster when documentation actually works. Features get adopted when users can figure out how to use them.
Real impact: Teams report 40% faster onboarding and significantly higher feature adoption rates
You're shipping a new API endpoint. Instead of manually updating docs:
# In your OpenAPI spec
/users/{id}/preferences:
put:
summary: Update user preferences
description: Modify notification and display preferences
parameters:
- name: id
in: path
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/UserPreferences'
example:
emailNotifications: true
theme: "dark"
The rules automatically:
Result: Your API docs are always accurate and your users can test endpoints immediately.
You're writing a tutorial for setting up your SDK. Instead of hoping it works:
# Quick Start Guide
## Installation
```bash
npm install @yourcompany/sdk
import { Client } from '@yourcompany/sdk';
const client = new Client({
apiKey: 'your-api-key-here'
});
const result = await client.users.create({
name: 'John Doe',
email: '[email protected]'
});
The rules ensure:
- Code blocks are syntax-highlighted correctly
- Examples are tested in CI
- Links to external resources are validated
- Screenshots are current and accessible
**Result**: Tutorials that actually work instead of wasting users' time.
### Scenario 3: Automated Content Maintenance
Your docs site runs health checks automatically:
```yaml
# .github/workflows/docs-health.yml
name: Documentation Health Check
on:
schedule:
- cron: '0 9 * * MON' # Weekly Monday morning
jobs:
health-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check for broken links
run: lychee --verbose --no-progress docs/**/*.md
- name: Validate OpenAPI specs
run: spectral lint api/openapi.yaml
- name: Check accessibility
run: pa11y-ci docs/**/*.html
Result: You find and fix problems before users do.
Choose your stack based on your needs:
For React/Node.js teams: Docusaurus
npx create-docusaurus@latest my-docs classic
cd my-docs
npm install
For Python teams: Sphinx with furo theme
pip install sphinx furo sphinx-autobuild
sphinx-quickstart docs
For multi-language teams: MkDocs with Material theme
pip install mkdocs-material
mkdocs new my-docs
Organize your content directory:
docs/
├── tutorials/ # Learning-oriented
│ ├── 01-quickstart.md
│ └── 02-first-app.md
├── how-to/ # Problem-oriented
│ ├── authentication.md
│ └── error-handling.md
├── explanation/ # Understanding-oriented
│ ├── architecture.md
│ └── design-decisions.md
└── reference/ # Information-oriented
├── api/
└── cli/
Create .github/workflows/docs.yml:
name: Documentation CI
on: [push, pull_request]
jobs:
docs-quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install markdownlint-cli lychee
- name: Lint Markdown
run: markdownlint docs/**/*.md
- name: Check links
run: lychee docs/**/*.md
- name: Build docs
run: npm run build
- name: Deploy to staging
if: github.ref == 'refs/heads/main'
run: npm run deploy
Add .markdownlint.json:
{
"line-length": {
"line_length": 100,
"code_blocks": false
},
"no-duplicate-heading": true,
"no-trailing-punctuation": {
"punctuation": ".,;:"
}
}
For OpenAPI specs, add spectral configuration:
# .spectral.yml
extends: ["@stoplight/spectral-rulesets/src/oas/index.js"]
rules:
info-description: error
operation-description: error
operation-summary: error
no-$ref-siblings: error
Teams implementing these rules typically see:
Once you've implemented the core rules, consider these advanced patterns:
Interactive Documentation: Embed live code editors and API explorers directly in your docs Multi-version Management: Maintain docs for multiple product versions automatically Analytics Integration: Track which content helps users succeed and which causes friction Feedback Loops: Collect user feedback and turn it into actionable documentation improvements
Your documentation can become your competitive advantage. These rules make it happen automatically, so you can focus on building great products instead of fixing broken docs.
Time to treat your documentation like the critical infrastructure it actually is.
### Technology Stack Declaration
You are an expert in:
- Markdown / MDX and reStructuredText (RST)
- Docusaurus, MkDocs, Sphinx for static documentation sites
- Swagger / OpenAPI 3.1 & Redoc for REST-API references
- Git, GitHub/GitLab, and CI/CD pipelines (GitHub Actions, GitLab CI)
- Diagram tooling: Mermaid, PlantUML, Lucidchart embeds
- Accessibility (WCAG 2.2), GDPR, HIPAA compliance
### Key Principles
- Treat documentation as code: version-controlled, peer-reviewed, CI-validated.
- Prioritize clarity, brevity, and accessibility over stylistic flair.
- Write in present tense, second person (“you”) and active voice.
- Keep each page single-purpose: one concept or procedure ≤ 800 words.
- Organize content with the Diátaxis model: **Tutorials → How-to Guides → Explanations → References**.
- Every PR that changes code must update or explicitly state "No-Docs-Needed".
- Use docs-driven development: draft docs before implementing user-facing features.
### Language-Specific Rules
Markdown / MDX
- Limit headings to H1–H3; deeper levels use expandable details blocks.
- Use fenced code blocks with explicit language tags: ```bash, ```javascript, etc.
- Inline code spans for filenames, CLI flags, paths; bold for UI labels.
- Prefer ordered lists (`1.`) for sequential steps; unordered (`-`) for choices.
- Keep line length ≤ 100 chars to ease diff reviews.
- Add ":::tip", ":::warning", ":::info" admonitions (Docusaurus) instead of blockquotes.
reStructuredText (Sphinx)
- One sentence per line; facilitates granular diffs.
- Use `.. note::`, `.. warning::`, `.. code-block::` directives consistently.
- Cross-reference with `:doc:` or `:ref:`; avoid raw URLs.
OpenAPI (YAML)
- Always include `summary`, `description`, and example payloads.
- Use tags to group endpoints; order tags alphabetically.
- Enforce camelCase for JSON properties; kebab-case for endpoint paths.
### Error Handling and Validation
- Lint every commit with markdown-lint, rstcheck, and spectral (OpenAPI linter).
- Broken links/image checks via `lychee` (Markdown) or `sphinx-linkcheck`.
- In CI, block merge if:
• Link checker reports ≥1 failure (excluding allowed domains).
• Markdown-lint exits non-zero.
• OpenAPI schema fails `spectral lint` high-severity rules.
- Provide **Troubleshooting** sections at end of guides with: Symptoms → Possible Causes → Fix.
### Framework-Specific Rules
Docusaurus
- Directory structure: `docs/<version>/<diátaxis-segment>/<topic>.mdx`.
- Enable sidebar autogeneration; keep order with numeric prefixes (`01-intro.mdx`).
- Use `import Tabs` and `CodeBlock` for multi-language code snippets.
- Create interactive sandboxes in MDX via `@codesandbox/react` when feasible.
MkDocs
- Use `mkdocs-material` theme; enable `plugins: [search, mermaid2, minify]`.
- Configure `nav:` manually to control left sidebar order; avoid deep nesting > 3 levels.
- Define custom admonitions in `mkdocs.yml` (`!!! danger "Irreversible"`).
Sphinx
- Use `sphinx-rtd-theme` or `furo`; dark-mode toggle mandatory.
- Autogenerate API docs with `sphinx-apidoc`; keep in `api/` folder.
- Enable `sphinx-contrib.mermaid` for diagrams; store `.mmd` sources alongside pages.
Swagger / Redoc
- Serve bundled `openapi.json` at `/docs/openapi.json` via CI artifact.
- Add `x-codeSamples` for common languages (curl, Python, JS) for each operation.
- Host interactive docs at `/api` sub-path; enable "Try it out" only on staging.
### Additional Sections
Testing & Continuous Integration
- `docs-test` workflow:
name: Docs CI
on: [push]
jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- run: pip install mkdocs-material markdownlint-cli spectral
- run: markdownlint docs/**/*.md
- run: spectral lint openapi/openapi.yaml
- run: mkdocs build --strict
- Fail the pipeline on any warning.
Performance & Maintainability
- Enable gzip + brotli on hosting.
- Auto-prune screenshots/diagrams > 2 years old unless referenced.
- Run Lighthouse on docs site monthly; action items tracked in backlog.
Security & Compliance
- Redact secrets in code examples (`REPLACE_ME` placeholders).
- Embed GDPR notice: cookies only for analytics with opt-in.
- Store PII examples in separate stub files, never inline.
Accessibility
- Alt text required for every image; CI rule: flag `alt=""`.
- Color contrast ratio ≥ 4.5:1; check via `pa11y-ci`.
- Provide keyboard-navigable interactive components only.
Versioning Strategy
- Latest = `/docs/next`, stable releases copy to `/docs/vX.Y` during release job.
- Deprecate old versions with banner: “This version is no longer maintained.”
Feedback & Continuous Improvement
- Embed feedback widget on each page (thumbs up/down + free text → Issues).
- Review analytics monthly; pages with exit rate >70% scheduled for rewrite.
- Publish “Docs Changelog” with every minor release.