en un clic
infrastructure-worker
Handles project scaffolding, database schema, auth, middleware, and backend infrastructure for the Complete Care platform.
Menu
Handles project scaffolding, database schema, auth, middleware, and backend infrastructure for the Complete Care platform.
| name | infrastructure-worker |
| description | Handles project scaffolding, database schema, auth, middleware, and backend infrastructure for the Complete Care platform. |
Specialised worker for foundational backend and infrastructure tasks on the Complete Care UK care management platform. Handles everything that is not a user-facing feature with UI — project scaffolding, database schema design, authentication, middleware, service configuration, and environment setup.
| Layer | Technology |
|---|---|
| Runtime | Bun |
| Framework | Next.js 15 (App Router) |
| Database | Vercel Postgres (Neon) |
| ORM | Drizzle ORM |
| Auth | Auth.js v5 |
| AI | AWS Bedrock |
| Payments | Stripe |
| Styling | Tailwind CSS + shadcn/ui |
| Testing | Vitest |
| Language | TypeScript (strict) |
Use the infrastructure-worker when the task involves:
.env templates, validation (e.g. @t3-oss/env-nextjs), deployment configDo NOT use for tasks that include frontend UI components, pages, or interactive forms — those belong to the feature-worker.
None — this worker operates independently. It does not invoke other skills.
.factory/library/ files for project conventions, directory structure, and architectural decisions..factory/research/tech-stack-patterns.md for Drizzle, Auth.js, and connection pooling patterns..factory/research/regulatory-compliance.md if the task involves data handling or audit requirements.src/lib/, src/db/, src/middleware.ts, and src/auth.ts (or equivalent) to understand current patterns..factory/library/ and the codebase..factory/research/tech-stack-patterns.md:
drizzle-kit for migrations.$inferSelect, $inferInsert).matcher config for route protection.Run all verification commands:
bun run typecheck # TypeScript strict mode — zero errors
bun run lint # ESLint — zero warnings/errors
bun run test # Vitest — all tests pass
For database changes, also verify:
bun run db:generate # Generate Drizzle migration SQL
bun run db:push # Push schema to dev database (if available)
Write a clear, descriptive commit message following the project's convention:
feat(db): add organisation and membership schema with RLS policies
- organisations table with slug, subscription tier, settings JSONB
- memberships table linking users to orgs with role enum
- row-level security via org_id foreign keys on all tenant-scoped tables
- Drizzle migration generated and verified
{
"status": "completed",
"feature": "Multi-tenant database schema and organisation middleware",
"filesChanged": [
"src/db/schema/organisations.ts",
"src/db/schema/memberships.ts",
"src/db/schema/index.ts",
"src/db/migrations/0002_add_organisations.sql",
"src/middleware.ts",
"src/lib/auth/org-context.ts",
"src/lib/db.ts",
"tests/db/organisations.test.ts",
"tests/middleware/org-context.test.ts"
],
"summary": "Created organisations and memberships schema with Drizzle ORM. Organisations have slug-based routing, subscription tiers (free/professional/enterprise), and JSONB settings. Memberships link users to orgs with roles (owner/admin/manager/carer/viewer). Added middleware that extracts org slug from the URL path, validates membership, and injects orgId into the request context. All tenant-scoped tables require org_id foreign key. Wrote 14 tests covering schema constraints, role validation, middleware auth enforcement, and cross-tenant data isolation. Typecheck, lint, and all tests pass.",
"testResults": {
"total": 14,
"passed": 14,
"failed": 0
},
"verificationCommands": [
"bun run typecheck — 0 errors",
"bun run lint — 0 warnings",
"bun run test -- tests/db/organisations.test.ts — 8 passed",
"bun run test -- tests/middleware/org-context.test.ts — 6 passed",
"bun run db:generate — migration 0002_add_organisations.sql generated"
],
"commitHash": "a3f7c21",
"commitMessage": "feat(db): add multi-tenant org schema and membership middleware"
}
Return to the orchestrator when: