Instructions for AI coding agents working in this repository (Superwall docs site).
For documentation-writing guidelines (tone, content conventions, etc.), see content/README/AGENTS.md.
- Stack: Next.js + Fumadocs (MDX) + TailwindCSS
- Hosting: Cloudflare (via
@opennextjs/cloudflare) - Docs: multi-platform SDK docs (iOS, Android, Flutter, Expo, React Native) + dashboard/integration guides
- Search/AI: built-in search + AI search mode; support center integration
- Theming: custom themes; dark/light mode is disabled by default
- Never deploy without explicit user approval.
- Content vs. engineering changes:
- Content changes: update files in
content/docs/**(andcontent/shared/**if used). - Engineering changes: you may edit other parts of the repo as needed.
- Never edit
public/**(it is generated and will be overwritten).
- Content changes: update files in
- SDK references first: if a task needs SDK APIs/changelogs, run
bun run download:referencesbefore writing. - SDK reference tables: use the Fumadocs-style
TypeTablefor parameters/types; do not use<ParamTable>. - Test: run
bun run build:cfandbun testafter making changes to ensure you didn't break anything
# Dev (http://localhost:8293)
bun run dev
# Build (runs all generators, then MDX + Next build)
bun run build
# Clear caches (when build/dev gets weird)
rm -rf .next
bun run clear:cache
# Content generation / assets
bun run generate:llm
bun run generate:md
bun run copy:docs-images
bun run watch:images
# Cloudflare builds / preview
bun run build:cf
bun run preview
# Deploy (DO NOT RUN WITHOUT USER APPROVAL)
bun run deploy:staging
bun run deploy- Navigation is defined by
meta.jsonfiles alongside content directories.- If a
meta.jsondoes not include"...", every page must be explicitly listed. - Use relative paths without extensions (e.g.
"guides/my-guide", not"guides/my-guide.mdx"). - You can nest objects to group related pages.
- If a
- Adding a new page:
- Create the
.mdxfile under the correctcontent/docs/**folder. - Update the folder’s
meta.jsonto include it in navigation. - Run
bun run buildto verify generation + routing.
- Create the
- Images: assets in docs content are copied into
public/during build (usebun run copy:docs-images; in dev usebun run watch:images).
- The site is served under
/docs(basePath+assetPrefixinnext.config.ts). /docs/sdk/*is a selector route that redirects to the chosen platform page.- Redirects are generated from
redirects-map.ts(folderRedirectsMap,fileRedirectsMap,externalRedirectsMap) insidenext.config.ts.
Changes require a rebuild to take effect.
Custom remark plugins are wired in source.config.ts. The current order is:
remark-image-paths(must run first)remark-follow-export- Fumadocs “existing” plugins
remark-includeremark-directiveremark-tabs-syntaxremark-code-languageremark-codegroup-to-tabsremark-sdk-filter(must run last; removes non-matching SDK blocks)
- Config:
source.config.ts,next.config.ts,open-next.config.ts,tsconfig.json - Redirects:
redirects-map.ts - Layout/routing:
src/app/layout.config.tsx,src/app/(docs)/[[...slug]]/page.tsx - Source plumbing:
src/lib/source.ts,src/mdx-components.tsx - Plugins:
plugins/* - Scripts:
scripts/*(title map, generators, image copy/watch, cache clear, etc.) - New UI/components: put React components in
src/components/and wire site-level layout/nav insrc/app/layout.config.tsx/src/lib/source.ts.
meta.jsonnavigation editsredirects-map.tschanges- remark plugin changes (
plugins/*orsource.config.ts) - new/updated images (make sure copy/watch runs)
- Cloudflare builds use
bun run build:cf(OpenNext adapter). - Cloudflare Workers disallow
eval():next.config.tsaliases the eval-basedfumadocs-uihide-if-emptycomponent tosrc/components/HideIfEmptyStub.tsx.
- Builds use Turbo (
next dev --turbo) and Cloudflare’s CDN for delivery.
Run:
bun run download:referencesThis clones/pulls SDK repos into reference/ (gitignored). Use the source to confirm API signatures and behavior before updating docs.
- Docs location:
content/docs/<sdk>/changelog.mdxforios,android,flutter,expo,react-native - Source of truth:
reference/<sdk>/CHANGELOG.md - Process: run
bun run download:references, then copy upstream changelog verbatim - Allowed edits: keep required frontmatter (
title: "Changelog"+ short per-SDK description). Optionally add one top-level deprecation callout. - Formatting: no MDX components/wrappers in the changelog body; escape angle brackets that would parse as tags (e.g.
< 8). - Navigation: ensure each SDK
meta.jsonlistschangelogright afterindex.
- For any AI SDK or AI SDK Elements work, fetch the latest docs via Context7 MCP before making changes.
SEARCH_MODE:'fumadocs'(default) or'rag'(external AI search)NEXTJS_ENV: development/production- Optional integration keys may exist (Slack, Mesh, Unify, RB2B, Pylon). See project environment documentation if present.
@/*→src/*@/.source→.source/index.ts(generated by Fumadocs)
- Build failures: check MDX syntax; validate
meta.json; ensure listed pages exist; runbun run buildfor full errors. - Dev server issues:
rm -rf .next,bun run clear:cache, verify port 8293 is free, reinstall dependencies if needed.
- Keep
.agents/skills/and.claude/skills/in sync for shared skills.