Skip to content
Docs
Changelog

Conventions

Use the existing owners and enforce boundaries in code and tooling.

Markdown

Hooks and components

Hooks coordinate asynchronous state, mutations, subscriptions, error presentation and navigation. Components render that state and compose primitives. A small static component does not need an artificial hook; a screen should not own a second session authority.

Feedback never waits for a refetch

Rule. A mutation's onSuccess, on the web and in the native app, shows its toast or navigates first and starts the refetch with void. It never awaits an invalidation and never returns one.

Why. TanStack Query keeps a mutation pending until the promise its onSuccess returns has settled. await queryClient.invalidateQueries(…), or an arrow that returns it, therefore holds the button's spinner, and any toast written after it, for one more round trip. Thirteen handlers did that, the import start and the trash restore among them.

Example.

onSuccess: () => {
  toast.success(t("FEEDBACK_INBOX_UPDATED_TOAST"));
  void refresh();
},

Anti-pattern. onSuccess: async () => { await refresh(); toast.success(…); }; onSuccess: () => queryClient.invalidateQueries({ queryKey }); onSuccess: changed, where changed awaits the invalidation.

A deliberate wait is an entry with a reason in the test's allowlist: reading the session again before the app opens on it, an organization switch that stays busy until the loaders have run for the new Active Organization, and the consent switch, which is not optimistic and stays disabled until the server's row is on screen.

Enforcement. [test] scripts/no-awaited-invalidation.test.mjs (in pnpm test) reads every onSuccess under apps/web/src and apps/mobile/src. A helper declared in the same file is judged by what it does (const invalidate = () => { void … } is fine); any other call is judged by its name (invalidat, refresh, refetch, fetchQuery). A stale allowlist entry fails.

Module boundaries

Backend rules (feature shape, errors, Effect, tenancy, configuration, logging) are on Backend conventions, and the rules for apps/web/src (routes, features and platform, the .server suffix, hooks versus components) are on Web conventions, each with its reason and enforcement. Before opening a pull request, use the review checklist.

  • No new barrels on server-capable modules. Use safe leaves for values needed by clients.
  • No dynamic import() in new implementation. Use static imports and framework-supported build splitting.
  • Enumerate cross-package exports deliberately.
  • Do not use window.confirm; use the shared accessible confirmation dialog.
  • Validate external payloads once at their boundary with Zod. Keep internal state typed.
  • Preserve Organization scope, current authorization and transactional audit requirements.

Shared client policy lives in a leaf

Rule. Any pure client policy shared by web and mobile (error translation, mutation-toast rules, query retry, user-agent parsing, role checks) lives once in a client-safe LEAF MODULE under packages/*, with an enumerated exports entry and tests at its interface. Do not copy or port a helper between apps/web/src/platform and apps/mobile/src/platform.

Why. Parallel platform copies drift silently: mobile kept retrying 4xx queries while web stopped, parseUserAgent gained native-client support only on mobile, sessionHasAdminRole had looser parsing on the web than on the server, and inline (key, params) => t(key as never, params ?? {}) adapters repeated across 14 call sites. Putting each policy behind one small leaf interface gives both apps locality and leverage without exposing any server capability (ADR-0002).

Example. Import translateError from @fofo/errors, shouldToastMutationError from @fofo/errors/mutation-toast, retryQuery from @fofo/errors/query-retry, parseUserAgent from @fofo/auth/user-agent, and sessionHasAdminRole from @fofo/api/admin/roles.

Anti-pattern. Porting a web platform/ helper into apps/mobile/src/platform/ with a comment saying it mirrors the web copy, or repeating an inline adapter lambda with as never at each call site.

Enforcement. [test] scripts/duplicate-platform-exports.test.mjs (in pnpm test) fails whenever the same exported function name appears in both apps/web/src/platform and apps/mobile/src/platform, outside a small allowlist for platform-specific hooks (useAuthMutation) that fails when stale. [test] scripts/leaf-modules.test.mjs keeps every shared leaf free of server imports.

UI and language

Read apps/web/PRODUCT.md before UI work. shadcn is the visual authority; neutral semantic tokens make rebranding inexpensive. Build controls from the packages/ui wrappers over ui-sdk and the component catalog, with the ui-sdk skill as Design patterns adapts it. Authenticated screens follow the product’s operating interface; marketing has separate design guidance. Design patterns lists which source, kit and agent skill each job uses.

Add chrome strings to the English, German, French and Brazilian Portuguese catalogs together, each in its own language: a key copied into de.ts with its English text passes the parity check and ships English to German readers. [test] scripts/catalog-language.test.mjs (in pnpm test) reads the web, mobile, error and email catalogs and the push texts, and fails on a word or letter that belongs to one of the other three languages, and on a translated string of three or more multi-letter words that repeats the English one. It works from short word lists, so a short one- or two-word label outside those lists passes in any catalog; that part stays [convention]. Preserve keyboard navigation, visible focus, reduced-motion preferences and meaningful labels. Use semantic links for destinations and buttons for actions.

Code is written in English

Rule. Everything that is code or about code is English, whatever language the domain, the team or the conversation uses: identifiers (variables, functions, types, files, folders, routes, database tables and columns, env vars, flag keys), comments, test names (describe/it), developer log and error messages, error codes, commit messages, branch names, pull request titles and bodies, developer docs and ADRs.

User-facing text is the only exception. It goes through the i18n catalogs, never hard-coded: apps/web/src/locales, apps/mobile/src/locales, packages/errors/src/locales and packages/email/src/locales, with the packages/intl runtime (see UI and language and the Locales rules).

A domain word from another language gets one English name, recorded once in CONTEXT.md under the English term. Code uses only that name; an identifier never mixes two languages. A proper noun or a legal term with no translation appears only in user-facing strings or in its glossary entry. Asking an agent in Portuguese or German changes the chat, not the code.

Why. Projects built from this template are read by people and agents who do not share the domain's language. One language keeps names searchable (a search for invoice finds every invoice, not also fatura and rechnung), keeps the glossary the single source of a term, and lets anyone guess the name of the next function. A name in two languages is the worst case: neither reader can predict it. User-facing text is different: it has to be translated, so it lives in catalogs whose locales are checked against each other.

Example. A German-speaking team adds delivery notes. The glossary records the term once:

**Delivery Note**:
The document that travels with a shipped order (German: _Lieferschein_).
_Avoid_: Shipping slip

The code uses only the English term, and the German word reaches users through the catalog:

// A delivery note is created once, when the order ships.
export function createDeliveryNote(order: ShippedOrder): DeliveryNote { … }

describe("createDeliveryNote", () => {
  it("copies the shipped items from the order", () => { … });
});

// apps/web/src/locales/de.ts
DELIVERY_NOTE_TITLE: "Lieferschein",

Anti-pattern. createLieferschein(order) or gerarNotaDeEntrega(pedido); type ResultadoEnvio; describe("envio do pedido") or a comment written in Portuguese because the ticket or the chat was; log.warn("Lieferschein fehlt") for developers; <Button>Speichern</Button> with the label hard-coded instead of in the catalogs.

Enforcement. [test] scripts/code-language.test.mjs (in pnpm test) fails on a short list of Portuguese and German words in identifiers, comments and describe/it/test titles under apps/*/src, packages/*/src, their scripts/ folders, the root scripts/, docs/** and .github/**, and in prose, HTML, YAML comments/labels and filenames across docs/**, every other tracked Markdown, MDX and text file (the docs site under apps/web/content, AGENTS.md, the READMEs), tracked YAML files (excluding pnpm-lock.yaml and vendored skills) and .github/**, with no baseline. It does not read string literals, JSX text, quoted words and URLs, or the locales and fixtures folders, so a word of another language shown as an example goes in backticks or quotes. It is a word list, not a language detector, so other languages, log messages, commits, branches and pull requests remain [convention]. [test] scripts/user-facing-strings.test.mjs covers the other half for the native app: in apps/mobile/src/{app,features,design,platform} it fails on JSX text and on a string literal given to a copy prop or option (title, label, placeholder, accessibilityLabel, any name ending in Title, Label, Text, Hint, …), also through a ? "x" : "y" and a ?? "x". A string that is the same in every language (an example URL, the name of an operating system) is an entry with a reason in that file's allowlist, which fails when it goes stale. The web has no such check yet ([convention]).

Configuration hygiene

A dated exception expires. An exception that is meant to be temporary says so on its own line: remove after <YYYY-MM-DD> or remove after <YYYY-MM-DD HH:MM> UTC, next to its reason. The usual case is a minimumReleaseAgeExclude entry in pnpm-workspace.yaml (library reference). Once the date has passed, remove the exception, or renew it with a new reason. Without the date nothing tells a later reader that the line is safe to delete, and eight such entries outlived their two days.

A key is written once. A JSON or JSONC object names each key once. JSON.parse and Wrangler keep the last copy without a warning, so the first copy and the comment above it describe a value nobody reads. apps/web/wrangler.jsonc declared version_metadata twice this way.

A script knows it is the command with import.meta.main. A script that is both a module (its functions are tested) and a command guards the command part with if (import.meta.main). Comparing process.argv[1] with import.meta.url is false whenever the path on the command line goes through a symlink, because Node resolves the module URL and not the argument (on macOS /tmp is a symlink). The command then does nothing and exits 0: check-production-config.mjs, check-system-call-sites.mjs and verify-rls.mjs passed that way without checking anything.

Enforcement. [test] scripts/tooling-tests.mjs (in pnpm test) reads every tracked YAML, JSON, JSONC, TOML, JavaScript and TypeScript file for an expired remove after date, and every tracked JSON and JSONC file for a repeated key. Vendored skills under .agents/skills are not read. [test] scripts/entry-guard.test.mjs fails on a script that compares process.argv[1] with its own URL, and runs one check through a symlinked path.

Reviewable pull requests and prose

Reviewable pull requests (D2). Keep a pull request body at 400 words or fewer unless it links a specific ADR under docs/adr/. Keep the diff at 1,500 changed lines or fewer outside locales, snapshots, vendored UI (packages/ui/src/components/, apps/web/src/platform/stageshow/), vendored skills (.agents/skills/, .claude/skills/, skills-lock.json) and generated lock or route files (pnpm-lock.yaml, routeTree.gen.ts). The /pr skill note in .agents/skill-notes/pr.md repeats these limits.

Changed prose (D4). Changed .md and .mdx files outside vendored skills and .scratch/ are scanned for mechanical unslop patterns (unslop-7, unslop-8, unslop-9, unslop-13, unslop-18, unslop-19, unslop-20, unslop-23, unslop-31). Frontmatter, fenced code blocks, inline code, HTML comments, URLs, MDX imports and JSX/HTML tags are skipped.

Enforcement. Both checks run in .github/workflows/ci.yml (checks job) and emit ::warning:: annotations without failing CI ([convention]). Fixture and rule behavior are tested in pnpm test ([test] scripts/check-pr-reviewability.test.mjs, scripts/check-prose.test.mjs), and the /pr repo note is checked by [test] scripts/skill-notes.test.mjs.

A swallowed failure says why

Rule. promise.catch(() => {}), .catch(() => null), .catch(() => undefined), .catch(() => { return null; }), .then(onOk, () => {}) and an empty catch {} in apps/*/src and packages/*/src carry the reason as a comment inside or after the handler on the same line (not a tool directive).

await reader.cancel().catch(() => {}); // the stream may already be closed

Why. Discarding an error is sometimes right: a stream cancel that may fail, a haptic on a device without them, an analytics beacon. Without the reason, the next reader cannot tell those from a failure that was hidden to make a test pass. Sixty-four such sites had none.

Anti-pattern. A bare .catch(() => {}); the reason two lines above, where an edit separates it from the call; a reason that restates the code ("ignore errors").

Enforcement. [test] scripts/swallowed-rejections.test.mjs (in pnpm test). A handler that logs, sets state or returns a fallback value is not a swallow. Tests and the vendored ReUI tree are not read.

Comments explain the code, not the project's history

Rule. A comment names what the code does or the documented rule it serves (D3, W15, an ADR). It does not cite a plan or a review by its code: no "lane C", no bare R8, no "review P1-1".

Why. Such a code meant something for the two weeks of that round. A reader a month later finds nothing behind it, while the sentence next to it already says what matters.

Enforcement. [test] scripts/code-language.test.mjs reads the comments of the source trees and of the oxlint configs for those three patterns. Quoted text is an example and is not read.

Changes and evidence

Use logical Conventional Commits. Keep generated migration SQL and relevant tests with their feature. Record measurements for runtime or bundle changes, including exact commands and limitations. Read the relevant ADR before altering an established boundary; historical measurements describe their captured revision, not a guarantee about the current tree.

Key files

Edit on GitHubDocumentation is in English.
Cookie settings
We use essential cookies to make our app work. With your consent, we also use optional cookies to improve your experience.

Read our Cookie Policy and Privacy Policy.