The source of the public documentation site at docs.marfa.so and the status page at status.marfa.so: Fumadocs on TanStack Start, deployed as two Cloudflare Workers. The docs follow the contract and the API description in withmarfa/marfa, which are the source of truth (STYLE.md, "Truth").
- Before adding, moving or wiring a page under
content/docs/, readcontent/AGENTS.md. Before writing one, readSTYLE.md, the one place the writing rules live. - Before changing
src/, readsrc/AGENTS.md: the agent surfaces, analytics and the status page. - Each
AGENTS.mdhas aCLAUDE.mdsymlink beside it. Edit theAGENTS.md, never the link. - Put no
.mdfile undercontent/docs/. The docs collection reads every.mdand.mdxfile there as a page, so an instruction file there fails the build for want of frontmatter, or is published.
- American English in code, comments and commits. Pages follow
STYLE.md. - Conventional Commits with a scope, such as
docs(build):orfix(mcp):. Work reachesmainonly through a pull request, one logical change each. - Make worktrees in
.claude/worktrees/(git worktree add .claude/worktrees/<name> -b <branch> origin/main). Once the work is merged, remove the worktree and its local branch (git worktree remove, thengit branch -D, because git sees a squash-merged branch as unmerged) and rungit pull --ff-onlyonmain. If git refuses a removal, report it rather than forcing it. - TypeScript and ESM. pnpm with the committed lockfile, on Node 22.22.2 or later (24.15 or later on Node 24), which jsdom, the component tests' DOM, requires; TanStack Start, Vite and Vitest need only 22.12. CI uses Node 22.
- This repository is public. Commit no internal hostname, private IP address, personal path, key or token, in a page or anywhere else.
- A comment says only what the code cannot: the reason, the constraint or the trade-off. It never names a tracker, ticket number or project phase.
- The telemetry page (
/run/telemetry) starts with what Marfa shows its owner itself (marfa attention, the server's log, a webhook onattention.raised) and comes to destinations last. PostHog is one optional route for a power user (a free PostHog Cloud project and two settings), never part of Marfa: Marfa sends nothing about itself until its owner sets where. - A code change in another repository opens a docs issue here, not a docs pull request. Pages are rewritten whole from those issues after each Marfa release ("Docs pass at each release").
- Each page has a kind and a
jobline.pnpm testfails a page over its kind's word ceiling or caps, and a page with nojobline.STYLE.md, "Page types", says what each kind holds, andsrc/lib/page-limits.jsonsets the numbers. It also lists each page with a bigger budget and its reason.
content/docs/: the pages, one folder per tab, ordered bymeta.jsonfiles.src/routes/,src/lib/andsrc/components/: the docs site, built on@withmarfa/docs-kit(the shared look and plumbing;src/AGENTS.mdsays which parts are the kit's), including the Worker entrysrc/server.ts, the Markdown copies,llms.txt, the docs MCP server at/mcpand the JSON addresses under/api/docs/.src/status/: the status page, a second Vite target built byvite.status.config.tsintodist-status/and deployed fromwrangler.status.jsonc.src/generated/andopenapi.json: written only by the sync scripts. Never edit them by hand.scripts/: the sync from marfa, the sync of WithMarfa's plugins from withmarfa/plugins, the changelog sync and the staleness report. The changelog sync and the report use only Node built-ins, because CI runs the report without installing anything. Their tests are insrc/lib/, the only place Vitest looks..github/scripts/: the CI change classifier and the publish checks, each with a.test.shbeside it, and the two sync scripts' tests.public/: static files for both targets.
pnpm install # also generates .source/
pnpm dev # the docs site, http://localhost:3000
pnpm exec vite dev -c vite.status.config.ts # the status page, port 3001
pnpm build # the docs site, with a full prerender
pnpm build:status # the status page
pnpm types:check # fumadocs-mdx, then tsc for each target
pnpm test # vitest, including the content lint and MCP conformance
bash .github/scripts/<name>.test.sh # the tests for one shell script- Run
pnpm buildandpnpm build:statusbeforepnpm types:check. Each build generates a route tree, and both trees register paths in one global interface, so without both builds the other target's route types becomeundefined. pnpm deployis a pnpm built-in that does not run the script. The fallback whenPublishcannot deploy ispnpm run deployorpnpm run deploy:statusfrom an authenticated shell.
MARFA_ROOT=/path/to/marfa scripts/sync-from-marfa.sh # defaults to ../marfa- Use a marfa checkout on an up-to-date
mainwith its tags fetched. The script copies committed files and runs nothing, and it checks every input before it writes anything. Its header lists what it writes. - After an API, glossary, CLI, contract table or release change lands in marfa, run the sync and open a sync pull request. A code change opens a docs issue, not a docs pull request (
STYLE.md, "Keeping pages current"). - Fix a gap in
openapi.jsonor a generated table in marfa's generator, never here. - The script takes only what marfa generates and commits: a file of its own, Markdown between markers, or a committed data file such as
builtin_catalog.jsonand the schemas inopenapi.json, which it renders into tables and lists under labels with no sentence of its own. What a value means is written on the page that includes the file. A list marfa does not generate gets a source there first. - The script also writes the command tree,
src/generated/cli-commands.json, from the sameCOMMANDS.md: every command with its options.src/lib/command-check.test.tschecks the pages' commands and options against it (STYLE.md, "Examples"), so a CLI change that renames or removes a command fails the next sync pull request on every page that still names it. src/lib/glossary.test.tsholds the Glossary page tosrc/generated/GLOSSARY.md.src/lib/glossary-sources.jsonnames, for each word on the page, the row that settles it and a fingerprint of the two definitions, so a sync that changes a row fails until the page's definition is read against it again and the fingerprint renewed.- After changing the script, run
.github/scripts/sync-from-marfa.test.sh. It pins what the script writes and every input it refuses.
MARFA_PLUGINS_ROOT=/path/to/plugins scripts/sync-from-plugins.sh # defaults to ../plugins
MARFA_PLUGINS_TAG=v0.0.9 scripts/sync-from-plugins.sh # a tagged release instead of main
scripts/sync-from-plugins.sh --relink # indexes and headers only, from the copy held- withmarfa/plugins holds WithMarfa's plugins: the connectors under
connectors/, and common type families undertypes/, one folder each (Tickets is the first). The sync reads both, as that repository's own list does (scripts/release/plugins.ts): eachconnectors/<name>/plugin/plugin.json, and eachtypes/<name>/that holds aplugin.json. A folder oftypes/with noplugin.json, a file there other thanREADME.md, and two folders that name one plugin stop the sync, as that list refuses them. The manifests are committed at HEAD of a plugins checkout, which that repository's own check keeps current. The script fetchesoriginand stops unless the checkout is atorigin/main, or, withMARFA_PLUGINS_TAG, at that tag's commit. Run it afterscripts/sync-from-marfa.sh(the headers link the types the shipped catalog has). - The script writes
src/generated/connectors/:connectors.json, the list the docs hold, derived from the manifests (a connector's name, title, description, source, mark, types and the types it carries back: a kind with the directionoutorboth),source.json(the plugins commit, and the tag if one names it), the connector index and one header for each connector. It also writessrc/generated/plugins/:families.json(each family's types, status words, guidance and display hints, as the plugin declares them), one header per family andindex.md, every plugin the repository publishes. A row is a connector, a type family or both, and the list gives no count. A family's header shows its version, the release tag on the commit without the leadingv, and no version line when no tag names the commit. Each connector page includes its header; a family page includes its header. The Plugins page (content/docs/catalog/connectors/index.mdx) includessrc/generated/plugins/index.md. The connector index stays generated, and that page does not include it, because the plugin list already names each connector. It also writes a page for a connector or a family that has none, holding only its header, with adescriptionand ajobline written from the title (and, for a connector, the source name) so they fit the page limits. A header says what a connector can carry back, which is its widest direction; no manifest says which setting turns that off, so the header does not. A page that exists is never overwritten. Neither folder'smeta.jsonis touched. The connectors folder lists nopages, so the sidebar orders those pages by file name. scripts/sync-from-marfa.shruns--relinkat its end whenever the docs hold a copy of the list, because a type links to its Catalog page only if the shipped catalog has one: a catalog change then moves the links with no second command.- A page under
content/docs/catalog/connectors/must have a connector of the samename:remarkIconsfails the build for one that has none, andsrc/lib/connectors.test.tschecks both ways. - After changing the script, run
.github/scripts/sync-from-plugins.test.sh.
node --experimental-strip-types scripts/sync-changelog.ts # GITHUB_TOKEN is used when set- The Changelog page is built from the GitHub release notes of withmarfa/marfa, never written by hand. The script reads the published releases and writes
src/generated/changelog.json, newest first, fromFIRST_VERSIONin the script (earlier releases were written in an older shape and stay on GitHub). It skips drafts and pre-releases. - Run it after each Marfa release's notes are written, and open a pull request with the file. The release notes have a fixed shape, which
src/lib/changelog.tsreads: a summary, an optional**Breaking:**paragraph, a###section for each part (Server, CLI, Core, TypeScript SDK, Swift SDK) and a**Full changelog:**link. Fix a wrong note on the release in GitHub and run the script again. source.config.tswrites the same releases into the page's Markdown copy and, throughremarkChangelogIndex, into its search index.
After each Marfa release, one docs agent works the open docs issues and rewrites each page they name whole, to STYLE.md. Nobody else edits a page for a code change. The staleness report is the backstop: it finds the pages that cite something a release changed and that no issue named. It names pages to read again, never asks for a change, and "no change needed" is a normal answer.
-
If no docs commit has synced the new release tag, run the sync and merge its pull request first. Run the changelog sync once the release's notes are written. Run the connectors sync once withmarfa/plugins has followed the release (
source.jsonsays which commit the docs hold), and merge its pull request: the marfa sync only relinks the headers it already has. -
Work the open docs issues. Close each when its page is right.
-
Find the commits that synced the previous release and the new one, and run the staleness report between them:
git log --format='%h %ad %s' --date=short -- src/generated/marfa-release.json git show <commit>:src/generated/marfa-release.json # which release a commit synced node --experimental-strip-types scripts/staleness-report.ts <previous-release-commit> <new-release-commit>
-
Read each page it lists that no issue covered against the contract and the API description. Rewrite a page whole if it is out of date, and leave it alone if it is right. Do the pages under "chapter changed" last.
On a pull request, the Docs reports job writes the same report to the job summary when openapi.json or src/generated/contract-index.json changed. It cannot fail the job.
CIruns on every pull request and every push tomain.Full CI(namedDraft CIwhile the pull request is a draft) is a roll-up ofBuild and type-check, and withPull request descriptionit is a required check, so never addpathsfilters toci.yml: a filtered-out run leaves the check pending..github/scripts/ci-changes.shskips the build only for rootAGENTS.md,CLAUDE.md,README.mdandLICENSE, the agent directories,.githooks/and the GitHub templates, and runs the sync scripts' tests only whenscripts/sync-from-marfa.sh,scripts/sync-from-plugins.sh, either one's test orci.ymlchanged.- A pull request description follows the organization's template:
Pull request descriptionfails it otherwise (scripts/check-pr-description.ts). - A newer push cancels a pull request's earlier run; a push to
mainis never cancelled. - Every workflow runs on GitHub-hosted
ubuntu-latest. TheCodeQLworkflow owns code scanning, so GitHub's default CodeQL setup stays off. - Merging to
mainpublishes.Publishruns whenCIsucceeds onmain. Each Worker has its own job, which deploys only when something that target builds from changed since the commit the site serves, then fails unless the site's/version.jsonreports the deployed commit. - Never build both targets and then deploy in one tree. The Cloudflare plugin writes one deploy pointer per project root and every build rewrites it, so a bare
wrangler deploydeploys whichever target built last.deploy:statuspasses the config its own build emitted. Publishhas no schedule. Run it by hand withmodeset tocheckto compare each live commit withmainand check that the status store is still written, or topublishto deploy.targetlimits it todocsorstatus. Nothing reports outside GitHub: a red run is the signal.- Deploying uses the
CLOUDFLARE_API_TOKENsecret and theCLOUDFLARE_ACCOUNT_IDvariable. The analytics key is thePOSTHOG_PROJECT_KEY_SITESvariable, passed to the build asDOCS_POSTHOG_KEY. Never commit any of them.
Report only a problem you can show: name the page, input or step, and what goes wrong. Leave formatting, and what the content lint and CI catch, to them. content/AGENTS.md and src/AGENTS.md add rules for their areas.
- Untrue against marfa. Flag a Marfa name, field, error code, rule or example that marfa's contract,
openapi.jsonor code contradicts. Safe path: check it there and link the rule's heading. - Generated file edited. Flag a hand edit under
src/generated/or toopenapi.json. Safe path: fix the source in marfa and run the sync. - Publishing weakened. Flag a
pathsfilter onci.yml, a deploy that can run where both targets were built, a self-hosted runner, or a publish job that no longer checks/version.json. - Worker route frozen. Flag a change to the prerender filter in
vite.config.tsthat freezes/version.json,/mcpor anything under/api/as a static file. - Private detail committed. Flag a token, key, account ID, internal hostname or personal path in a tracked file.
- Stale instructions. Flag a change that leaves an
AGENTS.md,STYLE.md, the README or a comment untrue, and fix it in the same pull request.