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
- 其他template.mdx2.3 KB
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)
apps/experiments/<name>/src/index.ts- app name, description, usage onGET /apps/experiments/<name>/src/routes/*.ts- endpoints, validation, response shapes, error codesapps/experiments/<name>/src/types/- request/response typesapps/experiments/<name>/wrangler.json- bindings (AI, R2, D1, KV, browser, Access, email, …)apps/experiments/<name>/README.md- examples, setup notes (do not copy blindly; verify against code)- 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):
- Features — bullet list of capabilities (recommended for AI and multi-capability workers)
- API Reference — endpoints, params, examples, errors (always present)
- Optional middle sections — e.g. Implementation Details, Technical Details, Monitored AI Crawlers, Architecture, Setup (complex workers only)
- Use Cases — 3–5 bullets
- Limitations — constraints and caveats
- Use in your project — optional
<UseInYourProject>paste recipe (small lib cores only; see below) - Deployment —
<Steps>with deploy button, deploy notes, test curl - Local Development — install, dev, local test curl
- Configuration — wrangler bindings, secrets, dependencies (when relevant)
- Cloudflare Features Used — linked bullets to Cloudflare docs
- 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.mdexperiments 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:
- Read the latest What's New entry and collect every experiment named there that has a docs page.
- Add
status: newto each of those MDX frontmatters (apps/docs/content/docs/experiments/<name>.mdx). - Remove
status: newfrom every older experiment that is not in that latest batch (do not leave previous cohorts tagged). - Mirror the same set in
apps/docs/lib/home-content.ts:featuredExperimentsentries (homepage cards; capped bymaxFeaturedNewBadges)- matching
homeCategoriesentries
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
- Diff
apps/experiments/<name>/(routes, types, wrangler, README) - Update matching sections in
apps/docs/content/docs/experiments/<name>.mdxonly - do not rewrite unrelated sections - If routes renamed/added/removed, update API + curl examples + error codes
- If bindings changed, update Deployment, Configuration, Cloudflare Features Used
- Run
npm run build -- --filter=docs
MDX conventions
- Deploy button (required in Deployment step):
[](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- seeapps/docs/components/mdx.tsx - External images: plain markdown
(deploy button SVG); do not use paths that breaknext/image - Links: prefer
/...for internal pages (no/docsprefix); full URLs for Cloudflare developer docs - Code citations in prose: use repo paths like
src/routes/check.tswithout line numbers unless referencing a specific implementation walkthrough
Quality checklist
Before finishing:
- [ ] Every documented endpoint exists in
src/routes/orsrc/index.ts - [ ] Query/body params match
validateUrl/ route validation - [ ] Error
codestrings matchjsonError(..., "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.jsonunder correct category - [ ] New experiment (or notable user-facing change) listed in
apps/docs/content/docs/changelog.mdx - [ ]
status: newonly on latest What's New cohort (older MDX +home-content.tstags removed) - [ ] No Mintlify-only syntax (
<ParamField>,<Icon>, etc.) - [ ]
npm run buildinapps/docssucceeds
Do not
- Import from other experiments in docs content
- Document endpoints that are not implemented
- Use
favicon.svgor 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
whereami
Use when editing whereami. GET /whereami returns request.cf (country, city, colo, etc.); no bindings.
websocket-echo
Use when editing websocket-echo. GET /echo WebSocket upgrade; echoes messages.
website-to-llms-txt
Use when editing website-to-llms-txt. GET /llms.txt?url=; returns plain-text llms.txt format (title, description, links, contact); no bindings.
website-to-api
Use when editing website-to-api. GET /api?url=; returns structured title, headings, links, images.
website-metadata-extractor
Use when editing website-metadata-extractor. GET /metadata?url=; extracts title, description, canonical, og tags.
website-devtools-inspector
Use when editing website-devtools-inspector. GET /devtools?url=; headers, cookies, scripts, assets, metadata.