- Workspace tasks MUST use `package.json` scripts; add a script when a missing workflow is repeatable like the existing commands, not ad hoc commands. - CI package path filters, matrix package ids, and root scripts `test:*` in `.github/workflows/ci.yml` and root `package.json` MUST stay synchronized when a workspace package is added, renamed, or moved; the `store` filter sync rule lives in `packages/trueforge-core/src/agent-session/store/AGENTS.md`. - Release wiring MUST keep dist-free host development, `pnpm smoke`, packed CJS/ESM consumers of `@truefoundry/trueforge-core`, and ESM consumers of `@truefoundry/trueforge-sdk` working without changes. Workspace loaders opt into SDK/core `src/` via the `trueforge-dev` export condition (never `"development"`); the SDK's `trueforge-dev` types MUST stay on generated `.d.mts` from `sdk:types` (source is not `exactOptionalPropertyTypes`-clean). - PRs that change published-package code (`packages/assistant-ui-runtime`, `packages/trueforge-core`, `packages/trueforge`, `packages/trueforge-ui`, `packages/trueforge-sdk`) or `packages/frontend` (ships inside `@truefoundry/trueforge`) MUST include a new `.changeset/*.md` file (`pnpm changeset`). Docs, CI/workflows, and docker-compose changes do not. A change to `packages/assistant-ui-runtime`, `packages/trueforge-ui`, `packages/frontend`, or `charts/trueforge` MUST also name `"@truefoundry/trueforge": patch`: those ship in the server image, and that package version is the chart `appVersion`. When the PR regenerates the SDK, ensure `"@truefoundry/trueforge-sdk": patch` appears in some changeset in that PR (same file or a separate one via `pnpm changeset:sdk-regen`). - Changeset bumps MUST be `patch` only. Minor (and major) version bumps are controlled by an external release process; PR changesets MUST NOT use `minor` or `major`. - Shared Postgres/Redis settings in `docker-compose.yml` and `docker-compose.dev.yml` (image versions, health checks, `env_file`) MUST stay synchronized; intentional differences (app services, data paths, project `name`, host ports, in-network `POSTGRES_HOST` / `REDIS_URL`) MUST stay explicit. `packages/trueforge/.env` is the host-dev + secrets source; `docker-compose.yml` may read it but MUST override container connectivity so host-dev localhost values are not used inside the smoke-test stack. - Changes to types or schemas MUST keep `packages/trueforge-core`, `packages/frontend`, `packages/trueforge`, and `patches` synchronized; they MUST NOT update only one affected layer. - TypeScript code MUST NOT use assertion escapes such as `as T`, `as unknown as T`, non-null `!`, or `as never` to silence type errors; implementations MUST use sound contracts, guards, or corrected types. - When catching an error and throwing another, the new error MUST set `{ cause: caught }` so the original failure is preserved for logs and debugging. - Every type, schema, helper, and contract MUST have one canonical owner; code MUST NOT introduce duplicate definitions or forwarding shims that hide ownership. - AgentUIServer / server-port types (`AgentChatServer`, `AgentBuilderServer`, catalog ports, session/turn DTOs, stream events) MUST be defined only in `packages/assistant-ui-runtime/src/server/types.ts` / `events.ts`. `@truefoundry/trueforge-ui` MUST re-export them from `src/server/types.ts` (pass-through aliases only) and MUST NOT add hand-written parallel definitions of those ports/DTOs. - Runtime types backed by Zod schemas MUST be derived with named `z.infer` aliases; code MUST NOT duplicate those schemas as hand-written interfaces or indirect utility-type chains. - Modules MUST use static `import` and `import type`; they MUST NOT use `require()`, `require.resolve()`, or lint suppressions to bypass import checks. - After editing ESLint-covered files, run `pnpm exec eslint --max-warnings=0` and fix findings in the same change. Do not drop `async` solely to silence `@typescript-eslint/require-await` when the body can throw: keep Promise rejections via `Promise.resolve()` / `Promise.reject()` / `Promise.resolve().then(...)`. - A change that makes code unused MUST remove that dead code in the same change; it MUST NOT leave stale exports, files, documentation, duplicates, or “just in case” shims. - Every nested `AGENTS.md` MUST have a sibling `CLAUDE.md` containing only `@AGENTS.md`, so Cursor and Claude Code load the same scoped rules. - OpenAPI specs under `.github/fern/openapi/openapi.json` and `docs/openapi.json`, and code under `packages/trueforge-sdk` and `python/trueforge_sdk`, are produced by `pnpm sdk:generate` (Docker required) and MUST NOT be hand-edited; both OpenAPI copies MUST stay identical. PRs that change OpenAPI/SDK inputs (`packages/trueforge/src/**`, `packages/trueforge/scripts/**`, relevant `packages/trueforge-core` surfaces, or Fern config) MUST run `pnpm sdk:generate`, commit the regenerated output, and ensure some changeset in the PR names `"@truefoundry/trueforge-sdk": patch` when the TS SDK changed. - Tests MUST live under a package-top-level `test` or `tests` directory that mirrors the `src` layout; they MUST NOT be inlined under `src`. - Functions with more than one parameter of the same type MUST take a single options object (e.g. `f({ a, b }: { a: string; b: string })`); they MUST NOT use multiple positional parameters of that repeated type (e.g. `f(a: string, b: string)`). - Zod unions MUST use `z.discriminatedUnion` whenever every member carries a shared literal discriminator field; `z.union` is only permitted when no such common discriminator exists. - HTTP/OpenAPI wire shapes (path params, query params, request/response JSON fields) and database identifiers (table/column names, persisted jsonb document keys) MUST use `snake_case`. - Server code MUST NOT read environment variables via `process.env` directly; all env reads MUST go through `packages/trueforge/src/config.ts`, unless there is a documented special requirement (for example bootstrap before config is loaded). - UI styles MUST use `rem` for lengths (not `px`); assume **1rem = 16px**. Prefer Tailwind spacing/type scale utilities when they fit. Exceptions: `0px` in `calc()`/`env()` fallbacks, existing media-query breakpoints, and canvas/measurement APIs that require CSS pixels. - GitHub Actions that push commits to `main` or `release-v*`, open or merge PRs into those branches, or write to another repository MUST use a TrueForge Dev Bot GitHub App installation token (`TRUEFORGE_DEV_APP_CLIENT_ID` / `TRUEFORGE_DEV_APP_PRIVATE_KEY` via `actions/create-github-app-token`). Same-repo API reads and creating package git tags or GitHub Releases MUST use `secrets.GITHUB_TOKEN`; do not mint the App token when `GITHUB_TOKEN` is enough. Any job that calls `api.github.com` with either token MUST join `tag:ci-github-egress` first (org IP allowlist). ## Code comments - Comments MUST explain intent, trade-offs, or constraints and remain brief; they MUST NOT restate the code, include issue-tracker IDs, or use `{@link …}` / deep cross-links. - Do NOT add file-level banners that enumerate implementations, backends, or call graphs; put a one-line note on the symbol that needs it, or omit. - Comments MUST NOT leak internal wiring into public or shared surfaces. - OpenAPI / route `description` and `.describe(…)` strings MUST stay under 50 words and describe the caller-visible contract only — not backend routing or storage. - TODOs stay to one short line when needed.