AGENT SKILL

experiment-docs

Generate or update Fumadocs MDX pages for Cloudflare Experiments across Cloudflare products (not Workers-only). Use when adding a new experiment, updating experiment API/docs, writing apps/docs/content/docs/experiments/*.mdx, editing meta.json navigation, or when the user asks to document an experiment on the docs site.

License 许可
MIT
最近更新
2026-10-06
Stars
★ 3
Forks
0

01 前言 Front Matter

name
experiment-docs
description
Generate or update Fumadocs MDX pages for Cloudflare Experiments across Cloudflare products (not Workers-only). Use when adding a new experiment, updating experiment API/docs, writing apps/docs/content/docs/experiments/*.mdx, editing meta.json navigation, or when the user asks to document an experiment on the docs site.

02 资源文件 1

03 SKILL.md 正文

Experiment Docs

Generate and maintain docs at apps/docs/content/docs/experiments/<name>.mdx from the experiment source in apps/experiments/<name>/.

Scope

Docs describe Cloudflare product patterns. Experiments usually deploy as Workers, but the catalog covers most Cloudflare products (AI, storage, networking, security, email, media, …). Lead intros and "Cloudflare Features Used" with the product capability; mention Workers as the runtime/deploy vehicle when relevant - never frame the whole project as Workers-only.

When to use

  • New experiment merged or scaffolded under apps/experiments/
  • Experiment API, bindings, routes, or README changed
  • User asks to "document the experiment", "add docs page", or "update docs site"

Source of truth (read in this order)

  1. apps/experiments/<name>/src/index.ts - app name, description, usage on GET /
  2. apps/experiments/<name>/src/routes/*.ts - endpoints, validation, response shapes, error codes
  3. apps/experiments/<name>/src/types/ - request/response types
  4. apps/experiments/<name>/wrangler.json - bindings (AI, R2, D1, KV, browser, Access, email, …)
  5. apps/experiments/<name>/README.md - examples, setup notes (do not copy blindly; verify against code)
  6. Closest existing doc for tone/structure: all experiment pages share the same H2 section order below; optional sections are omitted when not applicable.

Canonical section order

Every experiment doc uses these H2 headings in this order (skip sections that do not apply):

  1. Features — bullet list of capabilities (recommended for AI and multi-capability workers)
  2. API Reference — endpoints, params, examples, errors (always present)
  3. Optional middle sections — e.g. Implementation Details, Technical Details, Monitored AI Crawlers, Architecture, Setup (complex workers only)
  4. Use Cases — 3–5 bullets
  5. Limitations — constraints and caveats
  6. Use in your project — optional <UseInYourProject> paste recipe (small lib cores only; see below)
  7. Deployment — <Steps> with deploy button, deploy notes, test curl
  8. Local Development — install, dev, local test curl
  9. Configuration — wrangler bindings, secrets, dependencies (when relevant)
  10. Cloudflare Features Used — linked bullets to Cloudflare docs
  11. Next Steps — optional <Cards> linking related docs

Rename legacy headings when editing: API Endpoint(s) → API Reference, Setup & Deployment / Deploy → Deployment, Run locally → Local Development.

Use in your project (optional)

Add this section when the experiment has a small, pasteable core under src/lib/ (e.g. a helper that does not need a full Worker scaffold). Use the <UseInYourProject> MDX component:

## Use in your project

<UseInYourProject
  experiment="crypto-hash"
  dependencies={[]}
  bindings={[]}
  platform={["Web Crypto (`crypto.subtle`)"]}
  files={["src/lib/hash.ts", "src/constants/algorithms.ts", "examples/usage.ts"]}
/>

Props:

Prop Purpose
experiment Folder name under apps/experiments/
dependencies npm packages for the pasteable core (omit / [] if none)
bindings Wrangler bindings / resources to create ([] → shows "None")
platform Runtime APIs (Cache API, request.cf, Workers AI, …)
files Paths relative to the experiment root — loaded from disk into filename tabs
installCommand Optional override for the install line

Never paste source into MDX. Put pasteable files under the experiment (e.g. src/lib/*.ts, examples/usage.ts) and list their paths in files. Docs rebuild picks up edits automatically. Keep examples/ out of the Worker main entry (and usually out of tsconfig include) so it is docs-only.

Reference pilots: Crypto Hash, Where Am I?, Edge Cache.

Workflow: new experiment

1. Scaffold the MDX file

From repo root:

node apps/docs/scripts/scaffold-experiment-doc.mjs <experiment-name>

This writes apps/docs/content/docs/experiments/<name>.mdx with frontmatter, deploy button, and TODO sections. Then replace every TODO using the source files above.

Or copy .cursor/skills/experiment-docs/template.mdx to apps/docs/content/docs/experiments/<name>.mdx and fill placeholders manually.

2. Write the page content

Required sections (in order):

Section Content
Frontmatter title, description, tags, bindings, and status: new for experiments in the latest What's New batch (description ≤ ~160 chars for SEO; tags include category + discoverability aliases like jev for Clef). Lead description with the Cloudflare product shown. Update apps/docs/lib/experiment-docs-meta.ts when tags/bindings change.
Intro 1–2 sentences: what it does + primary Cloudflare product/capability (not "a Worker that…")
Features Optional bullet list of capabilities
API Reference One ### METHOD /path per route; params, examples, errors
Use Cases 3–5 bullet points
Limitations Timeouts, size limits, local vs deployed behavior
Use in your project Optional: <UseInYourProject> + core snippet + wire-up (small lib only)
Deployment <Steps> with deploy button, deploy note, test curl
Local Development cd apps/experiments/<name>, install, dev, test curl
Configuration Optional: wrangler.json bindings, secrets, dependencies
Cloudflare Features Used Bullets linking to Cloudflare docs
Next Steps Optional <Cards> linking related docs

Optional middle sections (between API Reference and Use Cases): Implementation Details, Technical Details, Architecture, Setup, etc.

3. Register navigation

Edit apps/docs/content/docs/meta.json:

  • Add "experiments/<name>" under the correct category separator
  • Categories (use existing separators only):
    • ---AI & Machine Learning---
    • ---Web Scraping & Parsing---
    • ---Browser Rendering---
    • ---Network & Monitoring---
    • ---Edge Platform---
    • ---Compute & Isolation---
    • ---Storage & Data---
    • ---Stateful & Async---
  • Pick category from primary binding/capability (see table in reference/experiment-docs)

4. Update repo indexes

For new experiments only:

  • Add row to root README.md experiments table (name, description, deploy link)
  • Deploy URL pattern: https://deploy.workers.cloudflare.com/?url=https://github.com/shrinathsnayak/cloudflare-experiments/tree/main/apps/experiments/<name>

5. Rotate sidebar / homepage "New" badges

Source of truth: the newest dated section in apps/docs/content/docs/changelog.mdx (What's New).

When shipping new experiments:

  1. Read the latest What's New entry and collect every experiment named there that has a docs page.
  2. Add status: new to each of those MDX frontmatters (apps/docs/content/docs/experiments/<name>.mdx).
  3. Remove status: new from every older experiment that is not in that latest batch (do not leave previous cohorts tagged).
  4. Mirror the same set in apps/docs/lib/home-content.ts:
    • featuredExperiments entries (homepage cards; capped by maxFeaturedNewBadges)
    • matching homeCategories entries

Sidebar badges come from MDX status via statusBadgesPlugin in apps/docs/lib/source.tsx. They are not inferred from dates or git history.

6. Verify

cd apps/docs && npm run build
npm run dev -- --filter=docs   # spot-check /experiments/<name>

Confirm: OG image generates, sidebar link works, code blocks render with Google Sans Code.

Workflow: update existing experiment docs

  1. Diff apps/experiments/<name>/ (routes, types, wrangler, README)
  2. Update matching sections in apps/docs/content/docs/experiments/<name>.mdx only - do not rewrite unrelated sections
  3. If routes renamed/added/removed, update API + curl examples + error codes
  4. If bindings changed, update Deployment, Configuration, Cloudflare Features Used
  5. Run npm run build -- --filter=docs

MDX conventions

  • Deploy button (required in Deployment step):
[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/shrinathsnayak/cloudflare-experiments/tree/main/apps/experiments/<name>)
  • Param docs (Fumadocs style, not Mintlify ParamField):
**`url`** `string` (required)

The target URL (http or https only).
  • Components: Callout, Steps/Step, Cards/Card, Accordions/Accordion, UseInYourProject, File/Files/Folder - see apps/docs/components/mdx.tsx
  • External images: plain markdown ![...](https://...) (deploy button SVG); do not use paths that break next/image
  • Links: prefer /... for internal pages (no /docs prefix); full URLs for Cloudflare developer docs
  • Code citations in prose: use repo paths like src/routes/check.ts without line numbers unless referencing a specific implementation walkthrough

Quality checklist

Before finishing:

  • [ ] Every documented endpoint exists in src/routes/ or src/index.ts
  • [ ] Query/body params match validateUrl / route validation
  • [ ] Error code strings match jsonError(..., "CODE") in source
  • [ ] Response JSON matches TypeScript types in src/types/
  • [ ] Local dev port is 8787 (Wrangler default)
  • [ ] Deploy button URL uses apps/experiments/<name> path
  • [ ] Page listed in meta.json under correct category
  • [ ] New experiment (or notable user-facing change) listed in apps/docs/content/docs/changelog.mdx
  • [ ] status: new only on latest What's New cohort (older MDX + home-content.ts tags removed)
  • [ ] No Mintlify-only syntax (<ParamField>, <Icon>, etc.)
  • [ ] npm run build in apps/docs succeeds

Do not

  • Import from other experiments in docs content
  • Document endpoints that are not implemented
  • Use favicon.svg or stale Mintlify assets
  • Skip meta.json (page won't appear in sidebar)
  • Duplicate full implementation in docs when a short snippet + link to GitHub suffices

Related skills

  • cloudflare-experiments - scaffold worker + README + root table
  • Per-experiment skills under .cursor/skills/<name>/ - route and binding reminders when editing that worker

Full guideline

Public reference for contributors: Experiment documentation guide (apps/docs/content/docs/reference/experiment-docs.mdx).

04 同仓库更多 Skills