AGENTS.md is the compact repository-wide operational source for coding agents. Keep
non-obvious safety and workflow rules here; load the linked documents only when the task
needs their detail. Dynamic facts belong in package.json, .nvmrc, scripts, or source.
- Execute shell work sequentially: one Bash/tool shell call per turn; never start parallel heavy processes or background Vitest, Biome, tsgo, Vite, Cargo, Storybook, or build jobs.
- Use Node and pnpm declared by
package.json/.nvmrc; pnpm only. Never use npm or yarn for repository dependency operations. - Before every push, run
pnpm run ci:prepush. On a new worktree or after dependency/lock changes, usenode scripts/dependency-state.mjs reconcile(orpnpm run deps:reconcile), never a bare install. Ifnode_modulesis missing or pnpm'sverifyDepsBeforeRunblocks thepnpm runlauncher, use the direct Node reconcile entrypoint; the pnpm command is only the convenience wrapper when pnpm can already launch scripts. Never disableverifyDepsBeforeRun, weakenallowBuilds, or use a bare install as a bypass. - Local default is the quick gate plus a focused test for every non-trivial behavior change;
add or update the narrowest relevant test rather than silently shipping unverified behavior.
Never run
pnpm test, an untargeted Vitest wrapper, full coverage, Playwright E2E, Stryker, Lighthouse, or Storybook test-runner locally; cloud CI is authoritative for those heavy checks. - The authoritative repository typecheck is
pnpm run typecheck; a lighter helper is not an equivalent gate. Do not launch multiple heavyweight checks concurrently.
- Unknown, malformed, incompatible, or unsupported data is preserved and refused: never delete, quarantine, silently normalize, or grant write authority when safety is unproven.
- Treat readable and writable as separate capabilities. Storage, autosave, snapshots, backups, auxiliary project files, and migration paths must honor the current authority boundary and serialization contract.
- Never commit or expose secrets. Never log keys, IVs, decrypted material, or full manuscript
payloads; use
services/logger.tswith sanitized context. - Never store credentials, manuscript content, or other sensitive payloads in plaintext
localStorage; use the approved encrypted/storage boundary instead. - Do not weaken encryption, CSP, storage boundaries, or privacy gates. AI responses are not cached by the service worker; delete only caches proven to be WorldScript-owned under the canonical naming scheme.
- Never execute AI, provider, user, or community content as code (
eval,new Function, or dynamic script injection); preserve the CSPunsafe-evalboundary and read the relevant ADR. - Community content remains schema-validated and guarded by
pnpm run content:guard; new network endpoints require the canonical CSP source and runtime privacy gate.
exactOptionalPropertyTypesis enabled: omit optional properties rather than assigningundefinedunless the type explicitly permits it. Avoidanyand honor strict checks.- When adding a nested settings object, update default merging in both
services/storage/idbProjectStore.ts#normalizePersistedSettingsandfeatures/settings/settingsSlice.ts#setSettingsso persisted and Redux hydration agree. - User-visible copy uses the i18n system. Add keys to canonical
locales/*sources and run the repository i18n generator/check; do not hardcode UI strings or stale locale counts. - Do not use Tailwind
dark:classes. Themes are body-class and semantic CSS-token driven. - First-party TS/TSX must not import
@tauri-apps/*directly. Route desktop capabilities throughdesktopPlatform/@domain/desktop-contracts; the approved boundary and exceptions are defined byscripts/check-tauri-import-boundary.mjs.components/ui/**remains platform-neutral. - New feature flags need the repository’s relevant E2E coverage, but heavy E2E execution is
CI-only on this machine. Do not invent scattered
if (true)feature gates. - For non-trivial TypeScript/TSX/CSS changes, add one short physical-line
QNBS-v3:rationale comment only when the reason is genuinely non-obvious (security, persistence, concurrency, native boundary, or compatibility). A test being new, substantive, regression-critical, security-sensitive, or persistence-sensitive does not by itself require a QNBS-v3 comment. In test/fixture files, add one only when a non-obvious harness, setup, fixture, order, timing, mock, suppression, or compatibility choice needs rationale beyond what the test name, inputs, and assertions already explain. Straightforward regression cases whose names, fixtures, and assertions state the invariant require no QNBS-v3 comment. No QNBS comment is needed for obvious tests, fixtures, generated files, locale JSON, or mechanical renames. Config JSON/YAML has no inline comment.pnpm run qnbs-comments:check(staged/diff-aware; wired into pre-commit andci:prepush) mechanically enforces the one-physical-line part of this rule — seedocs/CI.mdfor the full risk-routed local admission matrix. - Do not mutate
ref.currentduring render; use an effect. Preferuser-eventfor modeled interactions and descriptive names such asanchorfor download elements.
React/PWA remains the first-class web product. Tauri 2 is transitional; the authoritative
native direction is Rust Core plus Qt 6/Qt Quick. GPUI remains separately gated and CEF is not
a future target. Before native work, read docs/native/CORE-MIGRATION-LEDGER.md and the
binding roadmap/ADR; do not copy roadmap prose into agent context.
For persistence, AI, filesystem, or encryption work, inspect the relevant source and the
path-scoped Cursor/nested Claude rule first. Deep references include docs/CI.md,
docs/BEST-PRACTICES.md, docs/IDB-ENCRYPTION.md, and the native ledger.
Vendor-fork edits under packages/collab-transport follow VENDOR-FORKS.md and
pnpm run verify:vendor; do not recreate the removed upstream patch or a parallel fork.
When a task enters commit/push/PR/CI/review/merge work, read and follow
docs/PR-CI-MERGE-WORKFLOW.md; do not load that procedure for an unrelated tiny edit.
- Use a feature branch and conventional commits. Never commit directly to
main. - Open every pull request as ready for review; do not use draft PRs. If a PR number is needed for its changelog entry, open it once implementation is ready and add the reference promptly so review and CI start immediately.
- PR budget is cumulative base→prospective head/index: absolute normal ceiling is ≤30 changed files / ≤3000 meaningful lines / ≤15 commits; at 30 files do not add a file, at 15 commits do not create another commit, and never push merely to discover the budget.
- Resolve the real PR base and run
pnpm run pr:budget -- --base <ref>before the first commit and before every corrective commit/push; use--prospectivefor staged changes. If no live PR base exists yet, provide the reviewed base asPR_BUDGET_BASE=<ref>for both admission and push. Treat remaining headroom as a design constraint, never delete meaningful safety proof to reclaim a slot, and use a bounded split/successor when a valid fix cannot fit. - Do not add Claude/Anthropic attribution, generated-by footers, or session URLs to commit
messages, tags, PR titles/bodies, or maintainer-authored review comments. Repository history
records the code change, not the agent session. Never add
Co-Authored-Byfor Claude or aClaude-Sessiontrailer, including theGitHub Copilot (Claude ...)co-author form.scripts/check-commit-attribution.mjsmechanically enforces this for commit messages, tags, and PR titles/bodies (commit-msg hook, pre-push, and CI); review comments and replies have no automated check and stay a manual policy — never append these footers there. - Before new history, run
pnpm run signing:doctorand install hooks withpnpm run hooks:install. Commits and tags must be normally signed and Git-verified; never use--no-gpg-sign,--no-verify, unsigned temporary history, or force-push ordinary PR history. Use--force-with-leaseonly where the canonical PR recovery procedure explicitly requires it after a controlled rebase. - Inspect all three review channels: paginated inline threads, top-level issue comments, and full review bodies. Validate each finding against current code; fix real correctness, security, persistence, or data-integrity issues, or reply with evidence. Resolve inline threads and leave no actionable finding. Never add a suppression to silence review.
- Keep PRs comfortably below the repository’s absolute governance tier. Do not self-authorize exceptions, weaken the checker, bypass protection, or use an admin merge.
- GREEN PR CI IS NECESSARY BUT NOT SUFFICIENT for context-sensitive gates. When a required gate changes behavior across feature, pull-request, merge-ref, detached-HEAD, or main context, prove the current-base + PR resulting merge/main semantics before merge and make that proof part of a required status check; do not infer resulting-main safety from PR-head green alone. The trusted base-ref workflow-policy checker must retain that proof and the evaluator must run from trusted base code after the introducing bootstrap; a PR must not certify its own admission logic.
- After a merge, wait for exact resulting-main CI and CodeQL success, then follow
docs/VERCEL-PREVIEW-RETENTION-POLICY.md. Ordinary mode runs the full dry-run reconciliation before dependent mutation. An explicitly declared bounded dependency/toolchain maintenance train may defer only Preview housekeeping under that policy. The introducing transition may make the pull request that first admits the exception the train's first merge when its record is complete before merge. A later pull request cannot reuse that transition. A failed resulting-main gate aborts the train into ordinary reconciliation. Production correctness gates stay mandatory after every train merge, and one full reconciliation is required before non-train mutation resumes. Use a dry-run manifest, protect Production/main, rollback history, active-PR previews, and uncertain metadata; redact provider secrets and creator emails. Do not use project-wide Vercel removal. A separately declared release-batched Preview retention mode in that policy may defer the same Preview housekeeping until the next sanctionedv*release reconciliation. Its destructive writer is Codex CLI in the local VS Code/Ubuntu environment. Cursor Cloud does not delete Vercel deployments, publish a release, or receive release secrets. Per-merge exact-mainCI Success, CodeQL, Production READY, canonical HTTP, and alias/promotion/rollback checks stay mandatory. Whole push-triggeredCI / CDsuccess remains required in normal mode. The signed, reviewed GH #1176 incident mode is the sole bounded exception for its listed dependency successors; it must report a cancelled Pages job and the truthful overall workflow result, and it defers all Vercel retention. Gate 7 and the production storage-authority switch stay maintainer-gated. The introducing transition is one-time; a later pull request cannot reuse that transition. Reaching 14 days or 24 non-protected Preview deployments, or provider resource pressure, requires one exceptional Codex CLI pass and stops dependent repository mutation until that pass is recorded. That pass does not restore per-merge destructive cleanup. Until that mode is onmain, ordinary mode still requires the full reconciliation. As of 2026-10-13 that release-batched mode is superseded and ordinary per-merge reconciliation is active. As of 2026-11-06, its operator eligibility, recorded in GH #627, permits one maintainer-designated local Claude Code CLI or Codex CLI at a time. Cursor Cloud may write source and PRs under ordinary repository rules, but destructive retention remainsNOT_ADMITTEDuntil the separate maintainer-approved capability gate in GH #1174 is complete. That gate requires Cursor-managed least-privilege Vercel access and a clean, source-equal Node 22 runner; local Vercel tokens or state must never be copied into Cursor. Until admission, hand off per-merge retention to a qualified local operator and record the exclusive lease transfer. This updates operator eligibility only: full reconciliation, SAFE-only deletion, Production/rollback protection, all gates, and release restrictions remain in force. See the policy's dated operator-eligibility section. During GH #1176 incident mode, no Vercel deployment or alias deletion is permitted; expiry, any additional failed job, or a changed Pages failure signature stops the dependency lane until normal full reconciliation is available.
Cloud Agents run on Linux VMs with Cursor-managed signing and GitHub integration. gh API auth
may fail while Git push/PR operations still work — diagnose both separately. Open every PR as
Ready for Review; do not use Draft PRs, including when the PR number is needed for the
changelog or governance. Complete that reference in the ready PR so CodeRabbit and CI can run
immediately (see config/reviewer-registry.json). After merge, prove resulting-main CI/CodeQL/Vercel Production
on the squash commit SHA, not the PR head. Operational detail: docs/CURSOR-CLOUD-AGENT.md;
session snapshot: pnpm run cursor:cloud-doctor.
- Product and setup overview:
README.mdandCONTRIBUTING.md. - CI and workflow mechanics:
docs/CI.mdanddocs/PR-CI-MERGE-WORKFLOW.md. - Cursor Cloud Agent execution:
docs/CURSOR-CLOUD-AGENT.md. - Native architecture:
docs/native/CORE-MIGRATION-LEDGER.mdanddocs/adr/0021-qt-gpui-native-desktop-strategy.md. - i18n:
scripts/build-i18n.mjs,scripts/check-i18n-keys.mjs, and.cursor/rules/150-i18n-and-content.mdc. - Architecture/dependency investigation:
docs/graphify.mdanddocs/codegraph.md; use tools on demand. - Specialist path knowledge lives in
.cursor/rules/*.mdcand nestedCLAUDE.mdfiles; for cross-directory callers, follow the explicit guide mappings in the rootCLAUDE.md; do not duplicate specialist content here.