Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    trpc drizzle turborepo workflow

    1

    A strict TypeScript monorepo workflow for Drizzle, tRPC, and Turborepo with safe migrations and RLS-backed security.

    $12

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    trpc drizzle turborepo workflow

    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

    LayerActionFile/Command
    DomainCreate Period and Installment value objectspackages/domain/src/billing/
    DBDefine installment_schedules table and SQL RLS policiespackages/db/src/schema/billing.ts
    DBGenerate and review migration, then run db:safe-migratepnpm --filter @scope/db db:generate
    APIAdd createSchedule protected procedure with RLS contextpackages/api/src/routers/billing.ts
    WebBuild the installment form with React Hook Form + Zodapps/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

    1. Run pnpm db:backup before applying the new migration to your local environment.
    2. Implement the materializer function in packages/api to expand the schedule into individual payment rows.
    3. Add a Vitest integration test using withRollback to 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 push on 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

    1. Analyze the current task to determine which architectural layer (domain, db, api, or web) needs modification.
    2. Execute the top-down workflow, starting with pure domain logic and moving through schema changes to the tRPC router and UI.
    3. Verify every change against the quality gates, including strict TypeScript checks and cross-locale i18n key matching.
    4. 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.

    Requires a Pnpm Turborepo structure. Only supports Drizzle ORM on PostgreSQL. Will not work with Prisma or single-package repositories.

    How to use

    1. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    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

    Permissions

    Read Files
    Write Files
    Listed11 days ago

    What's inside

    Frequently Asked Questions

    This skill enforces a strict unidirectional data flow and Row Level Security (RLS) to prevent common monorepo issues like circular dependencies, direct DB imports in UI components, and accidental production data loss during migrations.

    It is designed for modern AI coding agents that support custom instructions or 'rules' files, working best in environments that can interpret complex project structures across Pnpm Workspaces.

    No, this skill is specifically architected for Drizzle ORM and PostgreSQL; it utilizes Drizzle-specific migration safety checks and PostgreSQL-only features like Row Level Security.

    You receive a comprehensive set of agent instructions, architectural rules, and CLI command patterns that guide your AI to handle schema changes, tRPC routing, and i18n parity correctly.

    The skill includes a specialized 'Safe Migration' protocol that mandates SQL reviews and enforces backups, specifically blocking dangerous commands like 'drizzle-kit push' in production environments.

    Yes, the workflow is built for Pnpm Workspaces and Turborepo, making it ideal for managing shared domain logic and database schemas across multiple Next.js applications or microservices.

    New in Agents & Orchestration