prisma
TypeScript and Prisma ORM best practices for schema design, type-safe queries, migrations, and error handling.
Skill by nateslabach
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/nateslabach-prisma
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: design, backend, writing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/prisma
What's inside
- Skill name
prisma- Description
- TypeScript and Prisma ORM best practices for schema design, type-safe queries, migrations, and error handling. Use when writing Prisma schemas, building database access layers, or debugging query performance in TypeScript projects.
- License
- MIT
- Instructions
- 95 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# prisma
Ensures Prisma code is type-safe, performant, and architecturally clean — covering the non-obvious patterns that trip up even experienced developers.
## Core Principles
- **One PrismaClient per process.** Multiple instances create multiple connection pools and exhaust your database connection limit.
- **Enums vs client imports.** Import from the generated `enums.ts` in client/shared code; import from `client.ts` only in server-side code. Never import `client.ts` in client components.
- **Repository pattern.** Keep data access logic separate from business logic. Create repository modules for complex query sets.
- **Transactions for multi-step writes.** Any operation that modifies more than one record should use `$transaction`.
- **Never modify existing migrations.** Treat migrations as append-only history.
## When to Use
- Writing or reviewing Prisma schema models
- Building or refactoring a database access layer
- Debugging N+1 queries or performance regressions
- Setting up Prisma in a new project (especially Next.js)
## Implementation Guide
### Client Setup (Singleton)
The hot-reload guard is required in Next.js — without it, dev mode creates a new PrismaClient on every file change and exhausts connections:
```ts
// lib/prisma.ts
import { PrismaClient } from "@prisma/client";
const globalForPrisma = globalThis as unknown as { prisma: PrismaClient };
export const prisma =
globalForPrisma.prisma ?? new PrismaClient();
if (process.env.NODE_ENV !== "production")
globalForPrisma.prisma = prisma;
```
### Enums vs Client Imports
```ts
// ✅ Client component or shared validation code
import { Role, Status } from "@prisma/client/enums";
// ✅ Server-side only (API routes, server components, background jobs)
import { prisma } from "@/lib/prisma";
import type { User } from "@prisma/client";
// ❌ Never in client components
import { PrismaClient } from "@prisma/client";
```
### Schema Design
- Use domain-driven model names. Keep schemas normalized and DRY.
- Declare all relations explicitly with `@relation`.
- Implement soft delete via `deletedAt DateTime?` — never hard-delete records that may be referenced.
- Use Prisma's native type decorators for database-level precision.
### Queries & Performance
- **N+1**: Use nested `include` or `select` instead of looping with separate queries.
- **Pagination**: Use `take` and `skip`; add a `cursor`-based approach for large datasets.
- **Field selection**: Use `select` to fetch only needed fields; avoid over-fetching with blanket `include`.
- **Join strategy**: `relationLoadStrategy` (`"join"` or `"query"`) is available but requires enabling the `relationJoins` preview feature flag. `"join"` uses a single `LATERAL JOIN`; `"query"` sends one query per table and joins at the application level.
### Error Handling
Catch Prisma-specific errors at the repository boundary:
- `PrismaClientKnownRequestError` — structured DB errors. Check `error.code`:
- `P2002` — unique constraint violation
- `P2025` — record not found (replaces the removed `NotFoundError` from Prisma 5)
- `PrismaClientUnknownRequestError` — unstructured DB errors
- `PrismaClientValidationError` — invalid query shape (usually a type error)
Provide user-friendly messages upstream; log the full error with context for debugging.
### Migrations
- Use descriptive names: `prisma migrate dev --name add_user_email_index`.
- Review generated SQL before applying to production.
- Never edit existing migration files — create a new migration instead.
- Keep migrations idempotent where possible.
## Review Checklist
- Is there a single PrismaClient instance with the hot-reload guard in place?
- Are enums imported from `enums.ts` in any client or shared code?
- Do multi-record writes use `$transaction`?
- Are N+1 patterns avoided (no DB calls inside loops)?
- Are `PrismaClientKnownRequestError` codes handled at the repository boundary?
- Do migrations have descriptive names and remain unmodified after creation?From nateslabach/skills, MIT.
More from nateslabach/skills
- 0.627score
openrouter
nateslabach
Choose OpenRouter models and routers, query live catalog data, use structured outputs and batch inference, and debug routing with metadata.
SkillAFreshness: A★ 6Claude Code +9 - 0.622score
deep-research
nateslabach
Produces thorough, multi-source cited research reports from web and news without paid APIs.
SkillAFreshness: A★ 6Claude Code +9 - 0.622score
code-review
nateslabach
Structured 3-phase peer review of a diff or PR — intent, issues by severity, then pointed merge-readiness questions and a verdict.
SkillAFreshness: A★ 6Claude Code +9 - 0.622score
branding
nateslabach
Builds personal brand assets using Seth Godin's frameworks: signature symbol, slogan, surprise (Purple Cow), salient idea, and signature story.
SkillAFreshness: A★ 6Claude Code +9 - 0.622score
adversarial-challenge
nateslabach
Devil's-advocate attack on AI workflow designs — threat model, assumption challenges, code critiques, and hypothetical redesigns with no file edits.
SkillAFreshness: A★ 6Claude Code +9 - 0.622score
ai-systems-review
nateslabach
Hostile self-review of recently written AI workflow code that then applies fixes (agents, tools, chat context, summarization, tokens, attachments).
SkillAFreshness: A★ 6Claude Code +9 - 0.582score
asd-ste100
nateslabach
Writes in ASD-STE100 simplified technical English — short sentences, plain words, active voice.
SkillBFreshness: B★ 6Claude Code +9 - 0.532score
adhd
nateslabach
Formats output for ADHD-friendly action — lead with the next step, number tasks, restate state, cut fluff.
SkillCFreshness: C★ 6Claude Code +9 - 0.532score
brutal-truth
nateslabach
Disables the AI's default hedging, diplomatic softening, and social-nicety layers to deliver cold, unfiltered, consequentialist analysis on any topic.
SkillCFreshness: C★ 6Claude Code +9 - 0.532score
depth-ui
nateslabach
Applies depth-driven layered color and shadow principles to elevate average UI into polished, readable interfaces for both light and dark themes.
SkillCFreshness: C★ 6Claude Code +9 - 0.532score
pushback
nateslabach
Stress-tests ideas by surfacing assumptions, counterarguments, and confidence gaps.
SkillCFreshness: C★ 6Claude Code +9 - 0.532score
css-reset
nateslabach
Applies a modern CSS reset covering box-sizing, margin removal, text rendering, media defaults, and root stacking context.
SkillCFreshness: C★ 6Claude Code +9
Signals
- Stars
- 6
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- May 21, 2026 (5 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/nateslabach/skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from nateslabach
- 0.627score
openrouter
nateslabach
Choose OpenRouter models and routers, query live catalog data, use structured outputs and batch inference, and debug routing with metadata.
SkillAFreshness: A★ 6Claude Code +9 - 0.622score
code-review
nateslabach
Structured 3-phase peer review of a diff or PR — intent, issues by severity, then pointed merge-readiness questions and a verdict.
SkillAFreshness: A★ 6Claude Code +9 - 0.622score
ai-systems-review
nateslabach
Hostile self-review of recently written AI workflow code that then applies fixes (agents, tools, chat context, summarization, tokens, attachments).
SkillAFreshness: A★ 6Claude Code +9 - 0.622score
adversarial-challenge
nateslabach
Devil's-advocate attack on AI workflow designs — threat model, assumption challenges, code critiques, and hypothetical redesigns with no file edits.
SkillAFreshness: A★ 6Claude Code +9 - 0.622score
deep-research
nateslabach
Produces thorough, multi-source cited research reports from web and news without paid APIs.
SkillAFreshness: A★ 6Claude Code +9 - 0.622score
branding
nateslabach
Builds personal brand assets using Seth Godin's frameworks: signature symbol, slogan, surprise (Purple Cow), salient idea, and signature story.
SkillAFreshness: A★ 6Claude Code +9
Cite this page
prisma skill. Agent Mart. https://agentmart.dev/skills/nateslabach-prisma (last updated 2026-10-24)