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
- Table — copy
projects.tstopackages/db/src/schema/tasks.ts, keeporganizationId, export it fromschema/index.ts, then:pnpm db:generate && pnpm db:migrate - API — copy
routes/projects.tstoroutes/tasks.ts. Chain the handlers (.get().post().patch().delete()), validate withzValidator, filter every query byactiveOrganizationId(c). Mount it inapps/api/src/app.ts:.route("/api/tasks", taskRoutes). - Web — add
apps/web/src/app/(app)/dashboard/tasks/page.tsx, callapi.api.tasks.$get(), type rows withInferResponseType<typeof api.api.tasks.$get, 200>. Add a link to the sidebar incomponents/app-shell.tsx. - Mobile — add
apps/mobile/src/app/(app)/tasks.tsxwith the sameapicalls 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.