Place at repo ROOT. Auto-loaded into every Claude Code session.
Distributed job scheduling platform. Postgres is both the queue and the system of record.
Four deployables: apps/api, apps/worker, apps/scheduler, apps/web.
Graded logic lives in packages/core — treat it as the crown jewel.
Concurrency
- Job claiming MUST use
SELECT ... FOR UPDATE SKIP LOCKED. - NEVER
SELECTthenUPDATEas separate statements. - NEVER application-level locking, in-memory mutexes, or advisory locks for claiming.
- Every claim sets
lock_expires_at. No exceptions. - Retry backoff always applies full jitter.
Database
- Parameterized queries only. NEVER string-interpolate SQL.
- Drizzle for schema and migrations. Raw SQL is allowed and expected for the claim query.
- Every partial index in
docs/DATABASE.mdmust exist. Do not "simplify" them. - Migrations run as a release step, never on service boot.
Security
- Every project-scoped query filters by
org_idderived from the JWT — NEVER from a request param. - Use the shared
assertProjectAccess()guard. No route bypasses it. - argon2id for passwords.
josefor JWT. Neverjsonwebtoken. http_requesthandler enforces the SSRF allowlist and blocks private CIDRs.- Never log
password,token,authorization,key, orsecret. - Never return stack traces in production responses. Log them, return the request ID.
API
- Cursor pagination only. NEVER
OFFSET. - zod validation on every body, query, and param.
- One error envelope:
{ error: { code, message, details, request_id } }. 201create,202enqueue accepted,409idempotency conflict,422validation,429rate limit.
Testing
- Concurrency tests run against real Postgres via Testcontainers. NEVER mock the database.
- Test-first for anything in
packages/core.
Frontend
- Tokens from
docs/UI_DESIGN_SYSTEM.mdexactly. Do not substitute Tailwind defaults. - Borders, not shadows. Radius 6px default, 10px cards.
- Monospace for every identifier. Status = dot + label, never a filled badge.
Process
- No new dependencies without asking first.
- Do not create files outside the structure in
docs/MODULES.md. - Prefer fewer, larger, well-organized files over many small ones.
- When the spec and your instinct disagree, follow the spec and say so.
Node 22 · TypeScript 5.7 strict · Express 5 · Drizzle + postgres.js · zod · pino · argon2 · jose · Vitest + Testcontainers · React 19 · Vite 6 · Tailwind v4 · TanStack Query/Router/Table · shadcn/ui · Biome · pnpm · Turborepo
pnpm dev all services
pnpm test full suite
pnpm test:chaos concurrency proof
pnpm db:migrate apply migrations
pnpm db:seed demo data
pnpm bench throughput benchmark
Append to docs/PROGRESS.md: what you built, files touched, and any decision
that differs from the spec with the reason.