nextjs-prisma
Use when working on a Next.js App Router project that uses Prisma as the ORM — covers server component data fetching, singleton client setup, and type-safe query patterns.
Best use case
nextjs-prisma is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Use when working on a Next.js App Router project that uses Prisma as the ORM — covers server component data fetching, singleton client setup, and type-safe query patterns.
Teams using nextjs-prisma should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/nextjs-prisma/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How nextjs-prisma Compares
| Feature / Agent | nextjs-prisma | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Use when working on a Next.js App Router project that uses Prisma as the ORM — covers server component data fetching, singleton client setup, and type-safe query patterns.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Next.js + Prisma Combo Skill
## When to Use
- Setting up Prisma in a new Next.js App Router project
- Reviewing or refactoring data-fetching logic in Server Components
- Debugging Prisma client instantiation issues (hot-reload client explosion)
- Implementing type-safe CRUD operations across Server Actions and API routes
## Workflow
### 1. Singleton Client Setup
Ensure Prisma client is instantiated only once across hot reloads:
> **Next.js version note**: The `global` cache pattern below is recommended for Next.js 13/14.
> In Next.js 15 (with React 19), module-level singletons are stable across hot reloads —
> you can use `export const prisma = new PrismaClient(...)` directly in `lib/prisma.ts`.
```typescript
// lib/prisma.ts (Next.js 13/14 pattern)
import { PrismaClient } from "@prisma/client"
const globalForPrisma = global as unknown as { prisma: PrismaClient }
export const prisma =
globalForPrisma.prisma ??
new PrismaClient({
log: process.env.NODE_ENV === "development" ? ["query", "error"] : ["error"],
})
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma
```
### 2. Data Fetching in Server Components
```typescript
// app/users/page.tsx
import { prisma } from "@/lib/prisma"
export default async function UsersPage() {
// Runs on the server — safe to use Prisma directly
const users = await prisma.user.findMany({
select: { id: true, name: true, email: true },
orderBy: { createdAt: "desc" },
})
return <UserList users={users} />
}
```
### 3. Server Actions with Prisma
```typescript
// app/users/actions.ts
"use server"
import { prisma } from "@/lib/prisma"
import { revalidatePath } from "next/cache"
export async function createUser(data: { name: string; email: string }) {
await prisma.user.create({ data })
revalidatePath("/users")
}
```
### 4. Avoiding Common Pitfalls
- Never import `prisma` in `"use client"` components — it will fail at runtime
- Use `prisma.$transaction()` when a page requires multiple dependent writes
- Apply `select` to limit fields — avoid sending sensitive columns to the client
- Run `prisma generate` after every schema change before running the dev server
### 5. Environment Setup Checklist
```bash
# 1. Install
pnpm add prisma @prisma/client
pnpm prisma init
# 2. Add DATABASE_URL to .env
# 3. Define schema in prisma/schema.prisma
# 4. Run first migration
pnpm prisma migrate dev --name init
# 5. Generate client
pnpm prisma generate
```
## Rules Applied
- `rules/frameworks/nextjs.md` — App Router, Server Components, environment variables
- `rules/frameworks/prisma.md` — schema design, singleton client, query safety
- `rules/common/security.md` — secrets management, input validationRelated Skills
nestjs-prisma
Use when building a NestJS application with Prisma — covers PrismaService setup as an injectable singleton, repository pattern integration, and testing with Prisma mocks.
verification-before-completion
Use before claiming any task is done — run the exact command that proves the fix works, read the output, and only then report success.
using-git-worktrees
Use when you need multiple branches checked out at once — create isolated working directories for parallel development without cloning the repository repeatedly
triage
Use when a single issue needs structured triage — classify it, reproduce if needed, request missing information, and leave a durable brief or close-out note in the tracker.
to-issues
Use when a plan, spec, or PRD must become an actionable backlog — break it into thin dependency-aware issues that each deliver a verifiable vertical slice
sprint-workflow
Use when starting a new feature, refactor, or multi-step dev task — runs the full sprint cycle (Think → Plan → Build → Review → Test → Ship → Monitor) using Copilot CLI's plan/autopilot modes.
sprint-retro
Use at the end of a sprint to run a data-driven retrospective — analyzes session history and git metrics to surface what shipped, what slowed you down, and concrete improvements.
security-audit
Use when a codebase needs a formal security audit beyond a quick scan — applies OWASP Top 10 and STRIDE threat modeling from a CSO perspective to surface systemic vulnerabilities.
release
Use when a sprint or feature is complete and ready to ship — tags the version, generates GitHub Release notes, runs rollout or smoke verification, and publishes to npm/PyPI/Docker registries.
prompt-optimizer
Use when a rough prompt, vague idea, or task description needs to become a finished copy-pasteable prompt for a chat-based LLM - rewrite it into one ready-to-send prompt with no blanks, no placeholders, and a clear output shape.
outside-voice
Use when you need an independent second opinion before, during, or after implementation — run challenge, consult, or review mode in a direct builder-to-builder voice
llm-wiki
Use when research or domain knowledge keeps getting rediscovered across sessions — build a supplementary markdown wiki that compounds synthesized knowledge without replacing GitHub or committed project guidance