agentleFS
Rikinshah787Rikinshah787/agent-skills-production-skills/skills/prisma/SKILL.md

prisma

Skill2 starsChanged 4 months agoMITView on GitHub

Use to model a database with a type-safe schema, run migrations, and query from TypeScript/Node with the Prisma Client.

  • Reads credentials
  • Installs packages

5 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use accessibility.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • ElasticSkill

    accessibility

    Accessibility guidance for Kibana. Use this skill when working with or reviewing EUI components, resolving a11y-related (@elastic/eui) ESLint issues, and ensuring proper use of ARIA attributes, focus management, keyboard interactions, and accessible naming conventions.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use when: you want end-to-end type safety between your DB and app code.

    line 21
  2. Very specific:

    Use when: you need a clear, versioned migration history (prisma/migrations).

    line 22
  3. Very specific:

    Don't use for: raw ultra-hot paths where you need hand-tuned SQL (use $queryRaw selectively).

    line 23
  4. Very specific:

    Prefer parameterized Prisma queries.

    line 132

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Prisma ORM — Skillship

Type-safe database toolkit for Node/TypeScript: declare models in a schema, generate a fully typed client, and evolve your database with versioned migrations.

🧭 When to use this skill

  • Use when: you want end-to-end type safety between your DB and app code.
  • Use when: you need a clear, versioned migration history (prisma/migrations).
  • Don't use for: raw ultra-hot paths where you need hand-tuned SQL (use $queryRaw selectively).

⚡ Quickstart

1. Install & init

npm install prisma --save-dev
npm install @prisma/client
npx prisma init --datasource-provider postgresql
# creates prisma/schema.prisma + .env with DATABASE_URL

2. Configure env

# .env
DATABASE_URL="postgresql://user:pass@host:5432/dbname?schema=public"

3. Define a model

// prisma/schema.prisma
generator client {
  provider = "prisma-client-js"
}
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
  posts Post[]
}

model Post {
  id       Int    @id @default(autoincrement())
  title    String
  author   User   @relation(fields: [authorId], references: [id])
  authorId Int
}

4. Migrate + generate

npx prisma migrate dev --name init   # creates + applies migration, regenerates client

5. Query

import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();

const user = await prisma.user.create({
  data: { email: "alice@prisma.io", name: "Alice", posts: { create: { title: "Hello" } } },
  include: { posts: true },
});

🧩 Common recipes

Recipe: CRUD

// Read
await prisma.user.findUnique({ where: { email: "a@b.com" } });
await prisma.user.findMany({ where: { email: { endsWith: "@prisma.io" } }, include: { posts: true } });

// Update / upsert
await prisma.user.update({ where: { id: 1 }, data: { name: "Bob" } });
await prisma.user.upsert({
  where: { email: "a@b.com" },
  update: { name: "Bob" },
  create: { email: "a@b.com", name: "Bob" },
});

// Atomic increment
await prisma.post.update({ where: { id: 1 }, data: { views: { increment: 1 } } });

// Delete
await prisma.user.delete({ where: { id: 1 } });

Recipe: Transactions

await prisma.$transaction([
  prisma.post.deleteMany({ where: { authorId: 7 } }),
  prisma.user.delete({ where: { id: 7 } }),
]);

Recipe: Singleton client (avoid connection storms in dev/serverless)

// lib/prisma.ts
import { PrismaClient } from "@prisma/client";
const g = globalThis as unknown as { prisma?: PrismaClient };
export const prisma = g.prisma ?? new PrismaClient();
if (process.env.NODE_ENV !== "production") g.prisma = prisma;

🚀 Ship to production

  • Use prisma migrate deploy (not migrate dev) in CI/CD — it only applies committed migrations.
  • Commit the entire prisma/migrations/ folder and schema.prisma to version control.
  • Run prisma generate during build (e.g. postinstall) so the client matches the schema.
  • On serverless/edge, use a pooled connection string (PgBouncer/Neon/Accelerate) to avoid exhausting DB connections.
  • Reuse a single PrismaClient (singleton) — never instantiate per request.

🔐 Security & secrets

  • DATABASE_URL holds DB credentials — keep it in env/secret manager, never in the repo.
  • Prefer parameterized Prisma queries; if you must use $queryRawUnsafe, never interpolate user input.

🐛 Common errors & fixes

SymptomLikely causeFix
Too many database connectionsNew client per request / serverless fan-outUse singleton + pooled connection string
Environment variable not found: DATABASE_URL.env not loadedEnsure .env exists / load dotenv; set in host env for prod
Migration drift / migrate dev wants resetSchema changed outside PrismaUse prisma db pull to introspect, or baseline the migration
Types out of date after schema editClient not regeneratedRe-run npx prisma generate (and restart TS server)

📚 Sources

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.