Experiment Documentation Guide
How to write and maintain Fumadocs pages for each Cloudflare Experiment worker
Every worker under apps/experiments/<name>/ should have a matching docs page at /experiments/<name>. This guide explains structure, conventions, and the automation available to contributors and agents.
Where docs live
| Artifact | Path |
|---|---|
| MDX page | apps/docs/content/docs/experiments/<name>.mdx |
| Sidebar order | apps/docs/content/docs/meta.json |
| Docs app | apps/docs/ (Fumadocs + Next.js) |
| Worker source | apps/experiments/<name>/ |
| Root index | README.md experiments table (new experiments only) |
Docs are not generated automatically on deploy. When you add or change an experiment, update its MDX page in the same PR (or immediately after).
SEO, tags, and AI discovery
Edit title, description, tags, and bindings in each experiment's MDX frontmatter. Keep apps/docs/lib/experiment-docs-meta.ts in sync when you change tags or bindings. Optional reference catalog: apps/docs/data/experiment-seo.json.
Tag guidelines:
- Primary category first - one of
ai,scraping,browser,network,edge,storage,stateful,containers,email,security(used by docs search chips). - Product / binding tags - e.g.
workers-ai,durable-objects,vectorize,browser-rendering. - Discoverability aliases - names people or agents actually search for when the Cloudflare product is obscure (e.g. Clef →
jev,systemone,decision-model; ML-KEM →kyber,post-quantum).
Descriptions should be ~120–160 characters and mention the searchable alias plus the Cloudflare capability. Intros can expand on that for humans and LLM crawlers (/llms.txt, /llms-full.txt, per-page markdown).
Quick start: new experiment
Scaffold the MDX file
From the repository root:
node apps/docs/scripts/scaffold-experiment-doc.mjs my-experimentThis creates apps/docs/content/docs/experiments/my-experiment.mdx with frontmatter, deploy button, and TODO markers derived from src/index.ts and wrangler.json.
Fill in content from source code
Read these files (source of truth):
src/index.ts- name, description, usagesrc/routes/*.ts- endpoints, validation,jsonErrorcodessrc/types/- response shapeswrangler.json- bindingsREADME.md- examples (verify against code)
Replace every TODO in the MDX file.
Add to sidebar navigation
Edit apps/docs/content/docs/meta.json and add "experiments/my-experiment" under the correct category (see Categories below).
Note it on What's New
Add a short dated bullet to What's New (newest first) when shipping a new experiment or a user-facing API/docs change.
Rotate "New" badges from What's New
Use the latest What's New section as the source of truth:
- Add
status: newto the frontmatter of each new experiment page in that batch - Remove
status: newfrom older experiment pages that are no longer in the latest batch - Keep
apps/docs/lib/home-content.tsin sync (featuredExperimentsand category entries; homepage shows at mostmaxFeaturedNewBadges)
Badges are manual - they are not derived from ship date.
Update root README (new experiments only)
Add a row to the experiments table in the root README.md with name, description, and deploy link.
Verify the docs build
cd apps/docs && npm run buildOpen http://localhost:3000/experiments/my-experiment after npm run dev -- --filter=docs.
Page structure
Required frontmatter
---
title: "Human Readable Name"
description: "One sentence for SEO and page header (≤ ~160 characters)"
# Only for experiments in the latest What's New batch:
# status: new
---Use the same description as GET / returns in src/index.ts when possible. Add status: new only while the experiment is in the current What's New cohort, then remove it when the next batch ships.
Required sections
- Intro - What the worker does and which Cloudflare product it showcases
- API Endpoint(s) - One
### METHOD /pathblock per public route - Parameters - Document each query/body field
- Example request -
curlagainsthttps://your-worker.workers.dev - Response fields - Type + description for each JSON key
- Example response - Valid JSON
- Error responses -
{ error, code }shape with real codes from routes - Use cases - 3–5 bullets
- Deployment -
<Steps>with deploy button + test command - Local development - install,
npm run dev, localcurlon port8787 - Cloudflare features used - Bullets with links to developer docs
Optional sections
Add when they help readers:
| Section | When |
|---|---|
<Callout type="warning"> | Experimental workers, AI cost/limits |
| Features | Multiple capabilities beyond one endpoint |
| Implementation details | AI pipelines, multi-step fetch/parse flows |
| Configuration | Bindings, secrets, D1 schema SQL |
| Limitations | Timeouts, size caps, local vs production differences |
| Use in your project | Small pasteable src/lib/ core (see below) |
| Next steps | <Cards> to related experiments or Cloudflare docs |
Use in your project
For experiments with a small, self-contained core (helpers in src/lib/, few or no bindings), add a paste recipe between Limitations and Deployment using <UseInYourProject>:
## Use in your project
<UseInYourProject
experiment="whereami"
platform={["request.cf"]}
files={["src/lib/cf.ts", "examples/usage.ts"]}
/>The component loads each path in files from apps/experiments/<name>/ at build time and renders filename tabs. Put wire-up snippets in examples/usage.ts (docs-only; keep it out of wrangler main). Do not paste source into MDX - edit the real files so docs stay in sync.
Pilots: Crypto Hash, Where Am I?, Edge Cache.
Skip this section when the useful unit is the whole Worker (many bindings, Durable Objects, multi-route apps). Deploy remains the primary path.
Reference examples
- Simple (single route, no bindings): Is It Down?, Where Am I?
- Paste recipe: Crypto Hash, Edge Cache
- Full (AI, config, implementation walkthrough): AI Website Summary
MDX conventions
Parameter documentation
Use bold name + type + description (Fumadocs prose style):
**`url`** `string` (required)
The target URL to check. Must use `http://` or `https://`.Do not use Mintlify components (ParamField, Icon, etc.).
Deploy button
Always use the monorepo path apps/experiments/<name>:
[](https://deploy.workers.cloudflare.com/?url=https://github.com/shrinathsnayak/cloudflare-experiments/tree/main/apps/experiments/is-it-down)Available MDX components
Registered in apps/docs/components/mdx.tsx:
Callout- notes and warningsSteps/Step- numbered proceduresCards/Card- related linksAccordions/Accordion- collapsible detailUseInYourProject- paste recipe checklist (deps, bindings, files, snippets)File/Files/Folder- folder trees
External images (e.g. deploy button SVG) use plain <img> / markdown image syntax.
Categories
Add new pages under the matching separator in meta.json:
| Separator | Use for |
|---|---|
---AI & Machine Learning--- | Workers AI, LLM summarization, AI proxies, RAG, Agents |
---Web Scraping & Parsing--- | HTML fetch/parse, metadata, llms.txt, feeds, structured data |
---Browser Rendering--- | Browser Rendering / Puppeteer binding |
---Network & Monitoring--- | DNS, uptime, redirects, geolocation, request.cf, probes |
---Edge Platform--- | Cache, crypto, auth helpers, flags, Secrets Store, Tail, Realtime |
---Compute & Isolation--- | Containers, Sandbox SDK, Dynamic Workers (Loader), Workers for Platforms |
---Storage & Data--- | R2, D1, KV, Vectorize, Hyperdrive, Pipelines |
---Stateful & Async--- | Durable Objects, Cron, Queues, Workflows, Email, Analytics Engine |
If an experiment spans categories, pick the primary capability shown in its README and issue proposal.
Updating existing docs
When changing an experiment:
- Diff routes, types,
wrangler.json, and README - Update only the affected MDX sections (API, errors, config, deployment notes)
- Keep curl examples in sync with path and query names
- Run
npm run buildinapps/docs
Do not remove documented error codes that still exist in code, and do not document routes that were deleted.
Accuracy checklist
Before merging:
- Every endpoint in docs exists in
src/routes/orsrc/index.ts - Error
codestrings matchjsonError(c, message, "CODE")in source - Response JSON matches TypeScript types
- Binding setup matches
wrangler.jsonandsrc/types/env.d.ts - Page entry exists in
meta.json - New experiment or notable user-facing change listed on What's New
-
status: newonly on the latest What's New cohort (older badges cleared;home-content.tsmatched) - Deploy URL uses
apps/experiments/<name> -
apps/docsbuild passes
Agent / Cursor skill
The experiment-docs skill (.cursor/skills/experiment-docs/SKILL.md) instructs Cursor agents to:
- Run the scaffold script
- Follow the template at
.cursor/skills/experiment-docs/template.mdx - Update
meta.json, README, and What's New - Rotate
status: newbadges from the latest What's New batch - Verify the docs build
Invoke it when adding or updating experiment documentation.
Related guides
- Adding New Experiments - full worker scaffold process
- Code Standards - API and folder conventions docs should reflect
- Contributing - PR expectations