Recipe: add a feature to web and mobile

The project resource (packages/db/src/schema/projects.ts, apps/api/src/routes/projects.ts, apps/web/src/app/(app)/dashboard/projects.tsx, mobile src/app/(app)/index.tsx) is the reference implementation. A new resource takes four steps.

With an AI agent

Open the repo in Claude Code, Cursor or Codex and ask, for example:

Add "tasks" to projects: each task has a title, a done flag and belongs to a project. List and add tasks on the project page on web and mobile.

The agent reads AGENTS.md (recipe "endpoint + migration + screen") and makes the changes below. Review the diff, then run pnpm db:migrate and pnpm typecheck.

By hand

  1. Table — copy projects.ts to packages/db/src/schema/tasks.ts, keep organizationId, export it from schema/index.ts, then:
    pnpm db:generate && pnpm db:migrate
    
  2. API — copy routes/projects.ts to routes/tasks.ts. Chain the handlers (.get().post().patch().delete()), validate with zValidator, filter every query by activeOrganizationId(c). Mount it in apps/api/src/app.ts: .route("/api/tasks", taskRoutes).
  3. Web — add apps/web/src/app/(app)/dashboard/tasks/page.tsx, call api.api.tasks.$get(), type rows with InferResponseType<typeof api.api.tasks.$get, 200>. Add a link to the sidebar in components/app-shell.tsx.
  4. Mobile — add apps/mobile/src/app/(app)/tasks.tsx with the same api calls and NativeWind classes.

Then pnpm typecheck. The types flow from the API route to both apps, so a renamed field shows up as a type error everywhere it's used.