Skip to content

feat: add trpc crud router builder skill#6

Open
simon-tanna wants to merge 1 commit intomainfrom
simon/trpc-router-skill
Open

feat: add trpc crud router builder skill#6
simon-tanna wants to merge 1 commit intomainfrom
simon/trpc-router-skill

Conversation

@simon-tanna
Copy link
Contributor

@simon-tanna simon-tanna commented Mar 14, 2026

Summary

Adds a new /trpc-router skill that scaffolds complete tRPC v11 routers for a named entity, including optional schema append and test generation support. The skill is designed to be practical for monorepo API workflows and includes strict guardrails for naming, auth mode selection, procedure subsets, and generation order.

Changes

  • Added skills/trpc-router/SKILL.md (new, 224 lines)

    • Defines /trpc-router <entity> [options] usage with --help output
    • Supports interactive --guided mode and non-interactive argument parsing
    • Implements option handling for:
      • --procedures (all, query, mutation, or explicit subset)
      • --auth (mixed, public, protected)
      • --with-schema and --no-tests
    • Enforces pre-flight reads of project files before generation
    • Enforces deterministic execution order: schema (optional) -> router -> root registration -> tests (optional)
    • Includes post-scaffolding checklist and constraints (strict TS, no any, zod/v4, import ordering, etc.)
  • Added skills/trpc-router/templates/router.md (new, 53 lines)

    • Router code template with placeholder substitutions for <Entity>, <entity>, and entity-kebab file naming
    • Includes guidance for conditional import/procedure trimming based on options
  • Added skills/trpc-router/templates/schema.md (new, 39 lines)

    • Schema append template for packages/db/src/schema.ts
    • Includes guardrail to avoid duplicate imports and requires user-provided entity columns
  • Added skills/trpc-router/templates/test.md (new, 87 lines)

    • Router test template with authenticated/public caller patterns
    • Includes UUID fixture constraints and per-procedure test omission guidance when subset generation is requested

Technical Details

  • Triggering is scoped to new-router intent (create/scaffold/add endpoints) and explicitly excludes generic architecture/config discussion or edits to existing routers.
  • Identifier derivation rules cover normalisation across casing formats (camelCase, PascalCase, kebab-case outputs).
  • The skill encodes safety checks for router key collisions and valid TypeScript identifiers before scaffold steps proceed.

Testing

  • Validate --help returns expected usage text and exits without scaffolding
  • Validate guided mode prompts/confirmation flow end-to-end
  • Validate procedure subset generation omits non-selected procedures completely
  • Validate auth mode mapping (mixed/public/protected) applies correctly
  • Validate --with-schema path appends schema only after collecting column input
  • Validate generated outputs compile against monorepo conventions in a target project

Breaking Changes

None expected. This PR adds a new skill and templates only; existing skills and rules are unchanged.

Copilot AI review requested due to automatic review settings March 14, 2026 00:48
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new trpc-router skill that scaffolds a CRUD-style tRPC v11 router (optionally including Drizzle schema + Vitest tests) using markdown-based TypeScript templates.

Changes:

  • Introduces skills/trpc-router/SKILL.md defining CLI options, guided flow, and scaffolding steps.
  • Adds router/schema/test markdown templates under skills/trpc-router/templates/ for code generation.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
skills/trpc-router/SKILL.md Defines the skill workflow (parsing, guided mode, file generation order, constraints).
skills/trpc-router/templates/router.md Template for generating a tRPC router module for an entity.
skills/trpc-router/templates/schema.md Template for appending a Drizzle table + Zod schemas into a central schema.ts.
skills/trpc-router/templates/test.md Template for generating a Vitest CRUD test file for the router.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +72 to +74
const [updated] = await db.select().from(<Entity>).where(eq(<Entity>.id, record.id));
expect(updated?./* updated field */).toBe(/* expected value */);
});
import type { TRPCRouterRecord } from "@trpc/server";
import { z } from "zod/v4";

import { desc, eq } from "@acme/db"; // desc: only if 'all' is included; eq: always
- `<Entity>` → PascalCase (e.g. `ProductVariant`)
- `<entity>` → camelCase (e.g. `productVariant`)

Fill `/* required fields */` with the actual column values needed to satisfy the schema's non-nullable constraints. Use valid RFC 4122 UUIDs for all UUID fields — never bare strings like `"test-uuid"` or zero-padded strings like `"00000000-0000-4000-8000-000000000001"` (the 3rd group must start with `[1-8]` for version, 4th group with `[89ab]` for variant). Use the pattern `"00000000-0000-4000-8000-00000000000X"` for readable test fixtures.
Comment on lines +60 to +63
const records = await db.select().from(<Entity>);
expect(records).toHaveLength(1);
expect(records[0]?./* field */).toBe(/* expected value */);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants