prisma
БесплатноБез исполняемых скриптовНе проверенPrisma ORM for Node.js/TypeScript. Covers schema definition, migrations, and type-safe queries. Use when working with Prisma. USE WHEN: user mentions…
от claude-dev-suite★ 51 звезда на GitHubОб этом скилле
Prisma Core Knowledge
Deep Knowledge: Use
mcp__documentation__fetch_docswith technology:prismafor comprehensive documentation.
When NOT to Use This Skill
- Raw SQL Operations: Use the
database-queryMCP server for direct SQL queries and database inspection - Other ORMs: Use appropriate skills (
drizzle,typeorm,sqlalchemy) for other ORM frameworks - Database Design: Consult
architect-expertorsql-expertfor database architecture decisions - Performance Profiling: Use
performance-profilerMCP for query performance analysis - Migration Rollbacks: Engage
devops-expertfor production migration strategies
Schema Definition
// 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[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Post {
id Int @id @default(autoincrement())
title String
content String?
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
authorId Int
}
CRUD Operations
// Create
const user = await prisma.user.create({
data: { email: '[email protected]', name: 'John' }
});
// Read
const users = await prisma.user.findMany({
where: { email: { contains: '@example.com' } },
include: { posts: true },
orderBy: { createdAt: 'desc' },
take: 10
});
const user = await prisma.user.findUnique({
where: { id: 1 }
});
// Update
await prisma.user.update({
where: { id: 1 },
data: { name: 'Jane' }
});
// Delete
await prisma.user.delete({ where: { id: 1 } });
Relations
// Create with relation
await prisma.user.create({
data: {
email: '[email protected]',
posts: {
create: [
{ title: 'First Post' },
{ title: 'Second Post' }
]
}
}
});
// Query with relation
const userWithPosts = await prisma.user.findUnique({
where: { id: 1 },
include: { posts: { where: { published: true } } }
});
Commands
npx prisma init
npx prisma migrate dev --name init
npx prisma generate
npx prisma studio
Anti-Patterns
| Anti-Pattern | Why It's Bad | Better Approach |
|---|---|---|
synchronize: true in production |
Can cause data loss, no migration history | Use prisma migrate deploy |
No select or include on queries |
Fetches all fields, performance waste | Select only needed fields |
N+1 queries without include |
Multiple round trips to database | Use include or select with nested relations |
| Missing indexes on foreign keys | Slow joins and lookups | Add @@index([foreignKeyField]) |
| Hardcoded connection strings | Security risk, no environment flexibility | Use env("DATABASE_URL") |
| No transaction for multi-step operations | Data inconsistency risk | Wrap in $transaction |
Using findMany() without pagination |
Memory issues with large datasets | Add take and skip or cursor-based pagination |
| Ignoring Prisma error codes | Poor user experience, security risks | Handle PrismaClientKnownRequestError codes |
| No connection pool limits | Connection exhaustion | Configure connection_limit in URL |
| Running migrations manually in prod | Human error, no audit trail | Automate via CI/CD with migrate deploy |
Quick Troubleshooting
| Issue | Likely Cause | Solution |
|---|---|---|
| "Can't reach database server" | Wrong DATABASE_URL or DB not running | Verify connection string, check DB status |
| "Unique constraint failed" (P2002) | Duplicate value in unique field | Check for existing record, handle error gracefully |
| "Foreign key constraint failed" (P2003) | Referenced record doesn't exist | Verify related record exists before insertion |
| "Record not found" (P2025) | Query returned no results | Use findUnique with null check or handle error |
| Slow queries | Missing indexes, N+1 problem | Add indexes, use include for relations |
| "Type 'X' is not assignable" | Generated client out of sync | Run npx prisma generate |
| Migration conflicts | Multiple developers creating migrations | Coordinate migrations, use git properly |
| Connection pool exhausted | Too many concurrent connections | Increase connection_limit or use Prisma Accelerate |
| "Client is not connected" | PrismaClient not initialized | Ensure new PrismaClient() before use |
| Schema drift | Manual DB changes not in schema | Use prisma db pull to sync or create migration |
Production Readiness
Security Configuration
// schema.prisma - Secure connection
datasource db {
provider = "postgresql"
url = env("DATABASE_URL") // Use env vars, never hardcode
}
// DATABASE_URL format with SSL
// postgresql://user:pass@
Установить prisma в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobWriteEditВложенные файлы
FAQ
Что делает скилл prisma?
Prisma ORM for Node.js/TypeScript. Covers schema definition, migrations, and type-safe queries. Use when working with Prisma. USE WHEN: user mentions "prisma", "schema.prisma", "prisma migrate", "prisma generate", "prisma studio", "@prisma/client", asks about "how to define models in prisma", "prisma relations", "prisma transactions", "type-safe database queries" DO NOT USE FOR: raw SQL queries - use `database-query` MCP; Drizzle ORM - use `drizzle` skill; TypeORM - use `typeorm` skill; SQLAlchemy - use `sqlalchemy` skill
Как установить скилл prisma?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл prisma запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic