Loading...
Loading...
Use when the user needs end-to-end TypeScript development — from database schema through API layer to UI — with tRPC, Prisma, Next.js, authentication, and deployment. Triggers: full-stack feature implementation, database-to-UI pipeline, tRPC router creation, Prisma schema design, auth setup, deployment configuration.
npx skill4agent add pixel-process-ug/superkit-agents senior-fullstackmodel User {
id String @id @default(cuid())
email String @unique
name String
role Role @default(USER)
posts Post[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([email])
@@index([createdAt])
}
model Post {
id String @id @default(cuid())
title String
content String?
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
authorId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([authorId])
@@index([published, createdAt])
}| Query Pattern | Index Type | Example |
|---|---|---|
| Lookup by unique field | Unique index | |
| Filter by foreign key | Standard index | |
| Filter + sort combination | Composite index | |
| Full-text search | Full-text index | Database-specific |
| Geospatial query | Spatial index | Database-specific |
export const userRouter = router({
list: protectedProcedure
.input(z.object({
page: z.number().min(1).default(1),
pageSize: z.number().min(1).max(100).default(20),
search: z.string().optional(),
}))
.query(async ({ ctx, input }) => {
const { page, pageSize, search } = input;
const where = search ? { name: { contains: search, mode: 'insensitive' } } : {};
const [users, total] = await Promise.all([
ctx.db.user.findMany({
where, skip: (page - 1) * pageSize, take: pageSize, orderBy: { createdAt: 'desc' },
}),
ctx.db.user.count({ where }),
]);
return { users, total, totalPages: Math.ceil(total / pageSize) };
}),
create: protectedProcedure
.input(createUserSchema)
.mutation(async ({ ctx, input }) => {
return ctx.db.user.create({ data: input });
}),
});| Pattern | Use When | Example |
|---|---|---|
| Role-based (RBAC) | Simple permission model | Admin vs User |
| Resource-level | Owner-only access | User can edit own posts |
| Attribute-based (ABAC) | Complex rules | Org membership + role + resource state |
| Feature flags | Gradual rollout | Premium features |
| Need | Component Type | Data Source |
|---|---|---|
| Static content, data display | Server Component | Direct DB/API call |
| Interactive form | Client Component | tRPC mutation hook |
| Real-time updates | Client Component | tRPC subscription or polling |
| Search/filter | Client Component | tRPC query with debounce |
| Navigation chrome | Server Component | Session data |
| Solution | Best For | SSR Support | Self-Hosted |
|---|---|---|---|
| NextAuth.js (Auth.js) | OAuth providers, JWT/session | Yes | Yes |
| Clerk | Fast setup, managed service | Yes | No |
| Lucia | Custom, lightweight | Yes | Yes |
| Supabase Auth | Supabase ecosystem | Yes | Partial |
FROM node:20-alpine AS base
RUN corepack enable
FROM base AS deps
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
FROM base AS builder
WORKDIR /app
COPY /app/node_modules ./node_modules
COPY . .
RUN pnpm prisma generate
RUN pnpm build
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY /app/.next/standalone ./
COPY /app/.next/static ./.next/static
COPY /app/public ./public
EXPOSE 3000
CMD ["node", "server.js"]Prisma Schema -> Prisma Client (types) -> tRPC Router -> tRPC Hooks -> React Components
| | | | |
Migration Type-safe DB Validated API Auto-typed Rendered UI
queries with Zod queriesprisma/
schema.prisma
migrations/
seed.ts
src/
app/ # Next.js App Router
(auth)/ # Auth route group
(dashboard)/ # Protected route group
api/trpc/[trpc]/ # tRPC handler
server/
db.ts # Prisma client singleton
trpc.ts # tRPC init
routers/ # tRPC routers
services/ # Business logic
components/
ui/ # Design system atoms
features/ # Feature components
hooks/ # Custom React hooks
lib/
trpc.ts # tRPC client
auth.ts # Auth configuration
validators.ts # Zod schemas
tests/
unit/
integration/
e2e/| Anti-Pattern | Why It Is Wrong | Correct Approach |
|---|---|---|
| Raw SQL in components | Bypasses type safety and security | Use Prisma through tRPC |
| Client-side fetch when Server Components work | Unnecessary JavaScript, slower | Server Components for static data |
| Sharing Prisma client with frontend | Security breach, exposes DB | Prisma only in server code |
| Missing indexes on foreign keys | Slow joins and lookups | Index every foreign key |
| Storing tokens in localStorage | XSS vulnerability | HttpOnly cookies |
| Skipping Zod validation | Runtime type errors | Validate all inputs at API boundary |
| Monolithic tRPC router | Hard to maintain, merge conflicts | Split by domain (user, post, etc.) |
| Business logic in tRPC procedures | Hard to test, not reusable | Extract to service layer |
mcp__context7__resolve-library-idmcp__context7__query-docsreactnext.jsprismatailwindcss| Skill | Relationship |
|---|---|
| UI layer follows frontend patterns |
| API layer follows backend patterns |
| Architecture decisions guide service boundaries |
| Auth implementation follows security patterns |
| Full-stack testing uses strategy frameworks |
| Review covers all layers of the stack |
| Optimization applies to all layers |