prisma-database

Guidance for using Prisma, a tool that maps application code to database tables and helps manage database changes. It covers schemas, migrations, generated client code, and database queries.

In plain words
What is it for?
Use it when designing Prisma schemas, creating or reviewing migrations, regenerating Prisma Client, defining relationships, and writing queries.
Why use it?
It helps prevent unsafe production changes, stale generated code, accidental data loss, and database performance problems caused by missing indexes or unclear relationships.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/monkilabs/opencastle/prisma
Any agent
npx skills add monkilabs/opencastle --skill prisma
Clone the repo
git clone --depth 1 https://github.com/monkilabs/opencastle

Made for: Claude Code, Codex.

Per session 37 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 569 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00037 $0.00569
Opus 5 $0.00018 $0.00284
Sonnet 5 $0.00007 $0.00114
Haiku 4.5 $0.00004 $0.00057

Measured 3d ago against content hash 0bd52b7c7da9, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

prisma-database scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (config.ts), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

src/orchestrator/plugins/prisma/SKILL.md · 40 lines

How it starts

The opening of the file, as written. The whole thing — 40 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Prisma Database

Project schema and connection details: database-config.md. Docs: https://www.prisma.io/docs

Migration rules

  • npx prisma migrate dev in development only — never in production; it can reset data. CI/production uses npx prisma migrate deploy.
  • Inspect prisma/migrations/<timestamp>/migration.sql before applying. Destructive operations (drops, column rewrites) need an explicit backfill step added to the migration.
  • Never edit an already-applied migration file — the checksum is recorded and will fail. Write a corrective migration instead.
  • npx prisma generate after every schema change; a stale client silently mismatches the DB. npx prisma db push skips migration history entirely — prototyping only.

Schema gotchas

  • Use cuid() / uuid() for IDs, not serial increments, in anything distributed.
  • Renaming a field without matching @map/@@map produces a column drop plus add, not a rename. Check both when renaming.
  • Add @@index explicitly on frequently queried columns — the schema does not imply them.
  • Write @relation explicitly, including onDelete (e.g. onDelete: Cascade); leaving it implicit means the delete behavior is whatever the connector defaults to.
  • Include createdAt @default(now()) and updatedAt @updatedAt for auditability.

Client and queries

Hot reload in dev creates a new PrismaClient per reload and exhausts the connection pool. Use the global singleton:

const globalForPrisma = globalThis as unknown as { prisma?: PrismaClient };
export const prisma = globalForPrisma.prisma ?? new PrismaClient();
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;

Use select for narrow reads, include for relations, prisma.$transaction for multi-step writes. Catch error code P2002 for unique-constraint violations and handle it rather than letting it surface as a 500.

Read the full file on GitHub · 40 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 40 lines · 37 tokens per session scan A 0bd52b7c7da9

Subscribe to this mod's changes

prisma-database is a skill published in the GitHub repository monkilabs/opencastle (61 stars, last pushed 5d ago), licensed MIT. It adds 37 tokens to every session and 569 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

architecture-database-design

Master of PostgreSQL schema design, optimization, and safe migrations. Enforces strict conventions for IDs, indexes, JSONB, and transactional DDL. Use whenever modifying the data layer.

Sn4kyGit/antigravity-project-starter · 42 tokens

spring-data-jpa

Use when generating JPA entities, repositories, queries, or anything touching the persistence layer. Covers entity conventions, N+1 prevention, projections, and query patterns.

rrezartprebreza/spring-boot-skills · 38 tokens

transactional-patterns

Use when working with @Transactional, multi-step database operations, distributed transactions, or any code that needs atomicity guarantees. Covers propagation rules, isolation levels, read-only optimization, and common pitfalls.

rrezartprebreza/spring-boot-skills · 44 tokens

flyway-migrations

Use when creating database migrations, schema changes, seed data, or any SQL that modifies database structure. Covers Flyway naming conventions, versioning, and safe migration patterns.

rrezartprebreza/spring-boot-skills · 39 tokens

spring-data-redis

Use when implementing caching, session storage, rate limiting, or any Redis integration. Covers cache-aside pattern, key naming, TTL strategy, and serialization config.

rrezartprebreza/spring-boot-skills · 37 tokens

product-architect

Complete product development system with 64 agents and 35 frameworks. Use when the user wants to build a product, write a PRD, plan an MVP or roadmap, design an app, research a market or check whether a feature already exists or is novel, do competitive analysis, run a security audit, build a financial model, plan…

ankitjha67/product-architect · 211 tokens