# Supabase Monorepo pnpm 12 + Turborepo monorepo. Requires Node 26 (see `.nvmrc`). ## Structure | Directory | Purpose | | ------------------------ | ------------------------------------------------------------------------------------------------------------------ | | `apps/studio` | Supabase Studio/Dashboard — has its own `apps/studio/AGENTS.md` (see below) | | `apps/docs` | Documentation site — Next.js app router, MDX (port 3001, served under `/docs`) — has its own `apps/docs/AGENTS.md` | | `apps/www` | Marketing website — Next.js, app + pages (port 3000) | | `apps/design-system` | Component demos — source of truth for Studio UI patterns (port 3003) | | `apps/ui-library` | shadcn-style registry site for Supabase UI blocks (port 3004) | | `apps/lite-studio` | Lightweight Studio — React Router 7 + Vite + Tailwind v4 | | `apps/kb` | Knowledge base — Astro — has its own `apps/kb/AGENTS.md` | | `apps/learn` | Courses site — Next.js + Velite (port 3007), early stage | | `packages/ui` | Shared UI components (shadcn/ui based) — `import { Button } from 'ui'` | | `packages/ui-patterns` | Composite components — subpath imports, e.g. `ui-patterns/AssistantChat` | | `packages/common` | Shared utils, telemetry constants, feature flags | | `packages/api-types` | Generated platform Management API types | | `packages/pg-meta` | SQL builders for Postgres introspection (`SafeSqlFragment`) | | `packages/shared-data` | Static data: pricing, plans, regions, error codes | | `e2e/studio`, `e2e/docs` | Playwright E2E tests | | `supabase/` | Local Supabase project: edge functions, migrations, config.toml | ## Common Commands ```bash pnpm dev:studio # run Studio dev server → http://localhost:8082 pnpm dev:docs # run docs dev server pnpm dev:www # run www dev server pnpm dev:kb # run knowledge base dev server pnpm test:studio # Studio unit tests (vitest) pnpm e2e # Studio E2E tests (playwright) pnpm build --filter=studio # build Studio pnpm lint --filter=studio # lint Studio pnpm typecheck # typecheck all packages pnpm format # oxfmt write for {apps,packages,blocks,i18n} (check: pnpm format:check; other paths: pnpm exec oxfmt --check ) pnpm generate:types # local DB types → supabase/functions/common/database-types.ts pnpm api:codegen # platform Management API types → packages/api-types ``` ## CI & Generated Files Every PR runs typecheck, lint, `oxfmt`, and typos checks, plus path-filtered test/build workflows, lint ratchets (warning counts cannot increase), and Tailwind token rules (`shadcn/*`). Never hand-edit generated files: `packages/api-types/types/**`, `**/routeTree.gen.ts`, `**/__generated__/**`, `apps/docs/features/docs/generated/**`, `apps/www/.generated/**`, `supabase/functions/common/database-types.ts`, `apps/docs/content/_partials/access-control/scoped_pat_*.mdx` (`make -C apps/docs/spec generate.partials.access-control`). ## Conventions - **UI & styling** — Import primitives from `'ui'` (`Button`, not raw `Button_Shadcn_`; check `packages/ui/index.tsx` first) and composed patterns from `'ui-patterns'`. Use Tailwind semantic tokens (`bg-muted`, `text-foreground-light`), never hardcoded colors. - **Exports & language** — Named exports only (default exports only where a framework requires them; lint-enforced). Use U.S. English everywhere. - **Public surfaces** — This repo is world-readable. Keep internal content out of code, comments, PRs, and issues: absolute production metrics (use percentages/ratios), internal vendor/legal/pricing/strategy detail, competitor names (protocol identifiers like user-agents are fine), private repo paths/symbols, and internal teammate names. Link Linear for internal context. - **Comments** — Explain non-obvious _why_ (invariants, ordering constraints, or temporary workarounds with a Linear ticket ID) — never _what_, file headers, change/mock history, or scratchpad narration. - **Dependencies & diff scope** — Use `"catalog:"` for shared workspace deps (add script tools to `devDependencies`, update the lockfile, remove unused deps). Keep diffs surgical: strip `console.log`s, isolate major dep bumps, and keep tooling version updates scoped to their own semantic boundary. ## Skills `.agents/skills/` is the source of truth for conventions — load the relevant skill before working instead of guessing. (For docs **content** style, `apps/docs/style-guide/` is the source of truth applied by the docs skills.) - `code-review` — read-only assessments and development-task readiness checks - `copywriting` — any user-facing text, anywhere in the monorepo - `react-hook-form` — writing or modifying any form code, anywhere in the monorepo - `safe-sql-execution` — any code building or executing SQL against user databases or analytics logs - `telemetry-standards` — PostHog events, `packages/common/telemetry-constants.ts` - `api-types` — regenerating `packages/api-types` and verifying production OpenAPI drift - `dev-toolbar-review` — `packages/dev-tools`, `packages/common/posthog-client.ts`, `packages/common/feature-flags.tsx` - `turbo-scripts` — `package.json` scripts or `turbo.jsonc` tasks, `maybe-turbo`, caching, env - `pm-the-docs` / `write-the-docs` / `edit-the-docs` / `ask-the-docs` / `review-the-docs` / `test-the-docs` — anything under `apps/docs` (see `apps/docs/CONTRIBUTING.md`) ## Studio Before working on anything in `apps/studio`, read `apps/studio/AGENTS.md` — it maps Studio tasks to skills and covers Studio architecture, principles, and repo-specific traps.