Build

Add a feature

Scaffold a workspace-scoped feature in one command.

01Scaffold it

Terminal
npm run new:feature -- invoices
npm run db:generate -- --name invoices
npm run db:migrate

The generator writes or edits:

  • a table in db/schema.ts
  • features/invoices/schema.ts, server/queries.ts and server/actions.ts
  • a create form and pages/invoices-page.tsx
  • routes for both personal and team workspaces, and a nav link
  • tests/unit/invoices.test.ts, plus the slug in the reserved list

02Scope every query

Every workspace-owned row has an organizationId. Get the workspace on the server, never from the browser:

features/invoices/server/actions.ts
const ctx = await requireWorkspace(workspace);
await db.insert(invoices).values({ ...input, organizationId: ctx.organization.id });

Pages use workspaceFromParams(params); actions and routes use requireWorkspace(workspace).

03Checklist

  • New /dashboard/<segment> route: add the segment to features/teams/reserved-slugs.ts.
  • Security-relevant actions call audit().
  • Server code logs with logger from lib/logger.ts.
  • Finish with npm run check.