- Home
- Skills
- Agents & Orchestration
- trpc drizzle turborepo workflow
Works with the AI Agents you already use
trpc drizzle turborepo workflow
A strict TypeScript monorepo workflow for Drizzle, tRPC, and Turborepo with safe migrations and RLS-backed security.
$12
trpc drizzle turborepo workflow
Example session with this skill installed
I need to add an 'installments' feature to the billing package. We need a new schema for the schedule, an API endpoint to create them, and it must support RLS.
- Read your context and instructions
- Compiled the trpc drizzle turborepo
I will implement the installments feature following the top-down workflow: defining the domain logic for payment periods, updating the Drizzle schema with RLS policies, creating the tRPC router with transaction-local context, and adding the materialized view logic.
Installments Implementation Plan
| Layer | Action | File/Command |
|---|---|---|
| Domain | Create Period and Installment value objects | packages/domain/src/billing/ |
| DB | Define installment_schedules table and SQL RLS policies | packages/db/src/schema/billing.ts |
| DB | Generate and review migration, then run db:safe-migrate | pnpm --filter @scope/db db:generate |
| API | Add createSchedule protected procedure with RLS context | packages/api/src/routers/billing.ts |
| Web | Build the installment form with React Hook Form + Zod | apps/web/src/components/billing/ |
Database Schema Snippet
import { pgTable, uuid, text, integer, timestamp, check } from "drizzle-orm/pg-core";
export const installmentSchedules = pgTable("installment_schedules", {
id: uuid("id").primaryKey().defaultRandom(),
userId: uuid("user_id").notNull(),
totalAmount: integer("total_amount").notNull(),
occurrences: integer("occurrences").notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
});
// Note: RLS policy to be added to the versioned SQL file:
// CREATE POLICY user_isolation_policy ON installment_schedules
// FOR ALL USING (user_id = current_setting('app.user_id')::uuid);
API Procedure
export const billingRouter = router({
createSchedule: protectedProcedure
.input(z.object({ amount: z.number(), count: z.number() }))
.mutation(async ({ ctx, input }) => {
return await ctx.db.transaction(async (tx) => {
await tx.execute(sql`SELECT set_config('app.user_id', ${ctx.user.id}, true)`);
return await tx.insert(installmentSchedules).values({
userId: ctx.user.id,
totalAmount: input.amount,
occurrences: input.count,
});
});
}),
});
Next steps
- Run
pnpm db:backupbefore applying the new migration to your local environment. - Implement the materializer function in
packages/apito expand the schedule into individual payment rows. - Add a Vitest integration test using
withRollbackto verify the RLS policy blocks unauthorized access.
Connects securely to your tools. The creator never sees your data.
About this skill
Managing a TypeScript monorepo shouldn't feel like a constant battle against dependency drift and unsafe database changes. This skill enforces a strict, layered architecture for projects using Pnpm Workspaces, Turborepo, Drizzle ORM, and tRPC. It eliminates common pitfalls like UI components importing the database directly or migrations that accidentally drop production columns.
What it does
- Layered Architecture Enforcement validates that code flows from domain and shared packages to the DB, API, and Web layers without circular dependencies or boundary violations.
- Safe Migration Workflow prevents catastrophic schema changes by enforcing backups, SQL reviews, and blocking
drizzle-kit pushon non-test environments. - RLS-Backed Security implements a double-layered defense using tRPC protected procedures and transaction-local PostgreSQL Row Level Security.
- Finance Data Materialization manages recurring schedules like installments and subscriptions by expanding them into idempotent, materialized rows.
- Quality Gate Automation runs i18n parity checks, Biome linting, and Vitest integration tests using a real database with automated rollbacks.
How it works
- Analyze the current task to determine which architectural layer (domain, db, api, or web) needs modification.
- Execute the top-down workflow, starting with pure domain logic and moving through schema changes to the tRPC router and UI.
- Verify every change against the quality gates, including strict TypeScript checks and cross-locale i18n key matching.
- Deploy database changes using the safe-migrate command after verifying the generated SQL and creating a recovery dump.
Frameworks & tools
TypeScript, Pnpm, Turborepo, Drizzle ORM, PostgreSQL, tRPC, Next.js App Router, TanStack Query, Biome, Vitest, and decimal.js.
Why this beats prompting it yourself
Writing these instructions manually usually leads to agents suggesting db push or messy cross-package imports. This skill provides a battle-tested blueprint that treats the database as a first-class citizen with RLS and ensures your monorepo remains maintainable as it scales.
Use cases
- Adding new database entities with triggers, RLS policies, and corresponding tRPC endpoints.
- Implementing complex recurring billing systems like installments or subscriptions.
- Refactoring shared domain logic across multiple Next.js applications in a monorepo.
- Auditing existing tRPC procedures for session-user scoping and transaction safety.
Known limitations
Does not support Python or Django backends, Prisma-based projects, or single-package Node apps. The target database for migrations must be PostgreSQL.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Agents & Orchestration.
Requires a Pnpm Turborepo structure. Only supports Drizzle ORM on PostgreSQL. Will not work with Prisma or single-package repositories.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 11 days ago