This file is for AI coding agents working in this repository, and for the people directing them. It records the conventions, constraints, and review feedback that apply to every change, so the same feedback never has to be given twice. Read README.md and ARCHITECTURE.md first for what the engine is and how it fits together.
- The rendering engine for Coder's documentation, published as the
@coder/*packages underpackages/and deployed by the apps underapps/. - The documentation content lives in
coder/coderunderdocs/, not here. Content fixes go to that repository. - The code-server docs come from
coder/code-server'sdocs/at the commitapps/docs/code-server-docs.jsonpins, and only the mainline carries them. Their content fixes go to that repository; bump the pin here in a reviewed PR. apps/docsis the public docs site (served atcoder.com/docs),apps/routerserves the per-version archive,apps/offlinedocsis the offline export, andapps/dist-releasepacks the package tarballs and builder kit that av*tag publishes as this repository's GitHub Release.
- Never publish a package to the public npm registry. The
@coder/*packages stayprivate; public releases are GitHub Release assets on this repository, built byrelease-dist.ymlthroughapps/dist-releaseonly, and consumers such as coder/coder'sofflinedocs/pin those asset URLs. - The public site's Content Security Policy is
script-src 'self' 'unsafe-inline'. Adding any third-party origin (script, frame, or connect) needs sign-off from Security (Lisa or JD). Write such a change behind a flag and mark it "needs security sign-off" in the PR. - No layout shift. Any change to the page chrome must keep cumulative layout shift at 0 through load, hydration, hover, and toggling.
- The site is served under a base path in production (
/docs, and/docs/vX.Y,/docs/@vX.Y.Zor/docs/@mainfor the other versions) but from the root on previews. Never hard-code a root-absolute asset URL (/brand/...,/images/...) in CSS or components; derive it from the base path. A root-absolute URL works on previews and breaks in production. - Never import a client component into
apps/docs/lib/sources.ts, and keep the generated-collection imports after the package imports there. Doing otherwise once doubled a 60 MB server chunk.apps/docs/scripts/source-import-order.test.mjspins the order, so keep Oxfmt'ssortImportsoff and add no import-sorting lint rule. - Public docs follow coder.com's design system (
packages/ui/styles/tokens.cssandramps.cssin coder/coder.com-new). In-product docs may use Coder Kit tokens instead. - Never authorize a Vercel deployment of a fork's pull request. Vercel's Git fork protection holds those deployments until someone authorizes them, and a fork's build would run with the project's environment variables. Fork previews go only through the reviewed
docs-previewenvironment in Actions.
- Never commit on
main. Use one git worktree per branch, under.worktrees/<branch-name>, with branches namedvigilante/<topic>. - Set up with
pnpm install --frozen-lockfile, thenpnpm turbo run build --filter='./packages/*'. Apps consume the packages' builtdist/, so rebuild a package after changing it before testing it in an app. - Run
pnpm run hooksonce per clone, after installing. It pointscore.hooksPathat.githooks, whichpnpm installdoes only where lifecycle scripts are allowed, and every worktree of the clone then uses it. The pre-commit hook checks the staged files with Oxfmt and Oxlint, Stylelint forpackages/docs-themeCSS, and actionlint for workflows when it is installed. It only reports and never rewrites a file, and it reads the files on disk, so a partly staged file is checked as saved. Fix what it reports before committing rather than using--no-verify, since CI runs the same checks. - Format changed files with
./node_modules/.bin/oxfmt <files>and lint them with./node_modules/.bin/oxlint <files>;pnpm lintruns both over the whole repository. - Stylelint checks the CSS in
packages/docs-themeas part of that package'slintscript, withstylelint-config-recommendedonly; formatting stays with Oxfmt, so add no Stylelint style rules. - For local dev against the real corpus, run
pnpm devinapps/docswithDOCS_REPOpointing at acoder/codercheckout. Without it, a small fixture corpus is used. - Stop a dev server by its port (
kill $(lsof -ti tcp:<port>)). Never usepkill -f 'next dev', because other sessions run dev servers on the same machine. - Previews are behind Vercel SSO. Vercel builds
apps/routerfrom Git onmainonly, for production;git.deploymentEnabledinapps/router/vercel.jsonturns its Git builds off for every other branch, so a pull request gets no Vercel bot preview. A docs-site change is previewed byengine-pr-preview.yml, which runs on every push to a pull request from this repository that touchesapps/docs,apps/offlinedocsorpackages/, builds it against coder/codermain, and, once adocs-previewreviewer approves the deploy, comments the URL on the PR and links it from adocs previewstatus. The deploy job runs the PR's own copy ofdocs-pr-preview.ymlbesideVERCEL_TOKEN, so approving a preview means reviewing any.github/workflows/change in that PR first. - A pull request that changes
apps/router,docs-configordocs-manifestalso gets a router preview fromrouter-pr-preview.yml: it builds withvercel build --standaloneand no Vercel credentials, and deploys once adocs-previewreviewer approves, then links the URL in a comment and arouter previewstatus. It replaces the Vercel Git previews, which are off for every branch butmain. The build writes coder-docs's project settings itself, so keep them in step with the Vercel project.
- Comments: at most one short line, and only where the reason is not obvious from the code. No explanatory comment blocks.
- No Linear IDs (
DOCS-123), review-round labels, or other ticket references in code, comments, or commit messages. Linear links belong in the PR body. - Write tests first where there is logic.
- Test rendered output, not implementation details. Render into the jsdom DOM (see
copyright.test.tsxfor the pattern) and assert with DOM queries such asquerySelector,classList,textContent, andstyle.getPropertyValue. Never parse HTML with regular expressions. - Client components import
@coder/docs-config/client, never the package root, which bundles zod into every page;first-load:checkin the docs site fails if zod comes back. - Prefer Fumadocs' own extension points (layout slots,
componentsoverrides, CSS tokens) over forking its components. When a fork is unavoidable, keep it minimal and note the source file and version in one line.
- Aim for WCAG 2.2 AAA and never ship below AA. Text contrast is 7:1 where the design allows, 4.5:1 at minimum; non-text contrast (icons, borders that carry meaning) is 3:1.
- Where coder.com's tokens fall short of AAA, the standard palette keeps the site's value as long as it meets AA, and the More contrast palette carries the AAA value.
- Every interactive element has a visible
:focus-visiblestate, a target of at least 24 by 24 CSS pixels (44 by 44 underpointer: coarse), and an accessible name. - Honour
prefers-contrast: moreandprefers-reduced-motion. - Colour never carries meaning alone; pair it with an icon or a label.
- New UI must pass the axe pass (
pnpm --filter @coder/docs-site a11y:axe), which CI runs on the fixture corpus. When a new component or content type ships, add a fixture page that exercises it and add the page to the pass.
- Consider every change as a possible upstream contribution to Fumadocs, and say yes or no, with the reason, in the PR's
## Upstreamsection. - Good candidates are generic bugs, accessibility fixes, and missing options in fumadocs-ui or fumadocs-core. Coder branding, routing, content, and our own CSS are not.
- File upstream issues or PRs only after Nick approves them. When the Fumadocs maintainer declines an idea, ship it in our own code rather than waiting.
- Conventional Commits:
type(scope): imperative subject, lowercase, no trailing period, with a body that explains why. - The last line of every commit message is
Assisted-by: AI. Never add aCo-Authored-Byline for an AI, and never name an AI model, vendor, or product.
- Open PRs as drafts unless told otherwise, with no reviewers. Nick decides per PR who reviews.
.github/CODEOWNERSnames the@coder/docsteam, so GitHub requests its review when a PR leaves draft. Don't name individuals there; change the team's membership instead.- Request Jess only for TypeScript changes, and Ben only when Nick asks.
- Agents never merge, never approve, never dismiss reviews, and never run
gh workflow run. When told not to comment on a PR, post nothing there. - Body sections, in order:
## Merge order, Summary, Design or Fix,## QA,## Pages to compare, Testing,## Upstream, the Linear link, and then a---rule followed by🤖 Built with AI assistance.as the last line. - Write PR bodies, issues, review comments and commit messages as normal paragraphs, not one sentence per line. One sentence per line applies only to Markdown files (
.md,.mdx).
Nick merges after checking each PR in his own browser, so QA must work there:
- Browser-only steps, with no terminal. Each step names the page, the exact action, and the expected result in plain words; DevTools values are optional extras.
- Steps work in both Firefox and Chrome. Where DevTools differ, give both. Mark any Firefox step that could not be verified.
- A
## Pages to comparetable with the columns What to check, Production, and Preview. Both are full clickable URLs: production athttps://coder.com/docs/<path>/and the preview on the branch alias. Note that the preview alias always serves the PR's latest deploy and needs a Vercel login. - At most one before-and-after screenshot, for visible changes. Host it on an orphan branch
pr-assets/<pr-number>-<topic>that is never merged, and embed it withhttps://github.com/coder/docs-engine/blob/<branch>/<file>?raw=true. - For CI, publish, or test-only changes, say there is nothing to see on the site and point to the GitHub or Vercel pages that show the change working.
- Never put a Vercel share link or protection-bypass token in a PR body.
- When editing a PR body, fetch it with
gh pr view <n> --json bodyimmediately before writing and apply only your change, so you never overwrite someone else's newer edit from a stale copy. Only one agent edits a given PR's body at a time.
Rules that came out of PR reviews, so reviewers don't have to repeat them. The number after each rule is the PR where it was raised.
- Keep code comments minimal; the PR body carries the reasoning. Don't justify a change in a comment block, especially in CSS. (#114, #115, #116)
- Put trade-offs, abandoned approaches, and non-obvious invariants in the PR body or ARCHITECTURE.md, with at most one short line in code, so no one re-attempts something already ruled out. (#28, #48, #52 to #55)
- Don't name a local the same as a global, such as a helper called
document, even where it's harmless. (#124) - When a function's purpose changes, rename it; when an implementation is superseded, move every caller and delete the old one. (#49)
- Export shared constants and helpers from one place and import them everywhere, instead of keeping private copies. (#28, #44, #52)
- Keep async behaviour consistent: a function never resolves synchronously for some inputs and asynchronously for others. (#131)
- Avoid
as unknown asand other casts that throw away type information, in code and tests. (#131, #161) - Build or recognise a version URL segment only through
versionSegment,versionUrlPrefixandisVersionShapedSegmentfrom@coder/docs-manifest/version-segment;version-segment-scan.test.tsfails on a hand-built one. (#201)
- Never parse rendered HTML with regular expressions. Render into jsdom, or parse with
DOMParser, and assert with DOM queries. (#131) - Assert on a component's rendered output and behaviour, never on its props or internal state, and don't cast an element to a fake type to inspect it. (#131, #161)
- When the same jsdom setup repeats across test files, extract a shared helper. (#131)
- Check that a new test fails against the old code before landing it. (#50)
- For a security invariant, demonstrate the failure mode itself, such as the leaked content, not just that a code path exists. (#28, #49, #52 to #54)
- Base corpus-shaped tests on real markup from the docs, not simplified examples. (#13, #28)
- Back every documented invariant with a test that pins it. (#48, #53, #54)
- Run any change that widens strict validation against the real corpus in strict mode before merging. (#50)
- Name a test file after the module it covers (
archive.test.ts), never after the PR or the batch it came from. (#232) - Every jsdom test preload calls
guardDomAssertions()from@coder/docs-ui/test/assert-dom. A failing assertion on a React-rendered node can use all of the machine's memory, because Node diffs the node's whole fiber tree. - Assert with
node:assert/strict, on one element'stextContentorgetAttributeat a time. Never assert directly on elements, NodeLists, HTMLCollections or objects holding elements. Never uset.assertor a barenode:assertimport, which the guard doesn't cover; oxlint rejects the import but nott.assert.
- Fail closed: reject ambiguous or unsafe input, and throw when a size or shape can't be determined, instead of assuming it's safe. A checker that meets a shape it can't parse reports it rather than passing. (#28, #51, #347)
- Refuse up front the input an upstream is known to reject, and treat its error statuses as failures (503) rather than misses (404): a crawler reads a 404 as gone and a 503 as try again. Never let a response produced from an error be cached. (#232)
- When a reader tolerates one bad item, it keeps that item's last good value instead of dropping it, and refuses the refresh when nothing good is left for an item the site depends on. (#232)
- CSS alone never gates or hides content. If gating is incomplete, say so. (#28, #49)
- Surface authoring defects at sync or build time rather than swallowing errors at runtime. (#28, #44)
- When scanning HTML, treat raw-text elements (
script,style,textarea,title) as text, and keep that list the same in every scanner. (#52, #53) - Never let one caller's temporary state live in another caller's directory or address space. (#51)
- Keep every Actions secret in an environment with a branch rule, a tag rule or a required reviewer, never at repository level: a workflow pushed to any branch can read a repository secret or an unprotected environment's, with no pull request and no review.
docs-distdeploys only fromv*tags, which only admins can create, and its release job holds no secret, only its ownGITHUB_TOKENwithcontents: write. (#342, #343) - A job that reads a secret declares its
environment:. The only exceptions are a guard step listed by job and step name inGUARDSinapps/docs/scripts/workflow-secrets.test.mjs, which fails if a write secret is visible, and asecrets: inheritcall to a workflow in this repository. That test enforces this, and fails on any secret reference it can't place in a job. (#342, #343, #347, #325) - Treat
vercel.jsonand.github/workflows/as a deploy boundary: review any change togit.deploymentEnabled, an environment name, a trigger or a secret reference line by line, because a reformatted file can hide a one-line change. (#343)
- Mark the current item (a nav or TOC entry) with
aria-current, not only with a visual style. (#121) - When a status such as "404" is only visual, add visually hidden text so screen readers get it too. (#126)
- Use an icon that implies behaviour, such as the external-link icon, only when the element behaves that way. (#123)
- The branch ruleset requires one check,
build & check, which is the aggregator job at the end ofci.yml. Add new CI work as its own job in that job'sneeds:list, and never give another job that name. build & checkpasses when every job it needs succeeded or was skipped, and fails when any failed or was cancelled, as coder/coder'srequiredjob does.- The
a11yjob runs the axe pass over the fixture build and fails on any WCAG violation not in.github/a11y-allowlist.json. Allowlist a failure only under the open PR that fixes it (pr-<n>) or, when the fix has no PR yet, atracked-<topic>owner; never under a Linear ID. - Adding a fixture page can need updates elsewhere:
fixtures/url-parity-approved.jsonfor a classic anchor the page drops on purpose, and the axe page list inscripts/a11y-axe-helpers.mjs. - A new package with a
testscript goes in thetestmatrix inci.yml; thetest matrix covers every packagejob fails until it does. - The workspace, CI and Vercel run Node 24, but the released packages and the offline kit support Node 22.12 and later, tested on 22.23.4, which coder/coder's toolchain pins.
The release rewrite in
apps/dist-release/src/manifest.mjsstampsengines.node: ">=22.12", and thepackages on node 22job builds, tests and exports on 22, so use no Node-24-only API inpackages/orapps/offlinedocs. - Oxfmt formats the YAML too: the workflows,
.github/actions/setup/action.ymlandpnpm-workspace.yaml, but notpnpm-lock.yaml, which pnpm writes. - The
actionlintjob lints every workflow, with ShellCheck over therun:scripts. Run it locally withpnpm lint:actions, which needsactionlintandshellcheckon your PATH (brew install actionlint shellcheck). - Fix what actionlint reports; for a ShellCheck false positive, put
# shellcheck disable=SCnnnn # <reason>on the line before the command. - Pin
LC_ALL=Cfor anysortwhose output must match byte for byte across jobs. (#125) - Normalise a shared config value, such as the base path, with the same function in every script that reads it. (#107)
- Give every fetch in a polling or health-check script a per-request timeout (
AbortSignal.timeout). (#107) - Don't write
input || defaultin GitHub Actions expressions where0or another falsy value is valid. (#105) - When partitioning entries with fixed filters, add a catch-all bucket or assert that the parts add up to the whole. (#105)
- Plan large or speculative work as a series of small, focused PRs. (#101)
- Before rebasing a stale branch, check whether newer work has superseded it, and keep only what's still new. (#44)
- When two PRs touch the same code, land the fix first and rebase the other onto it, so conflict resolution can't silently undo the fix. (#50, #53)
- When review feedback is applied, say so in the PR so the thread isn't left ambiguous. (#28)
- When Nick gives a new standing instruction, or a reviewer leaves feedback that generalises beyond one PR, add it here in the same PR or a follow-up, under the right section, with the source PR number for review feedback.
- Before starting work, read the review comments on any PR you are about to change, and check this file for the rule before asking.
- Keep entries short and imperative. Remove entries that stop being true, and resolve conflicting entries rather than keeping both.