Chuyển đến nội dung
Skillpedia
API và máy chủ (backend)33k · #8790

prisma-expert

Skill này làm gì

Skill này cung cấp cho AI của bạn sự trợ giúp chuyên sâu về Prisma, bộ công cụ cơ sở dữ liệu cho Node.js và TypeScript. Nó dành cho lập trình viên làm việc với schema, migration hoặc truy vấn Prisma.

Khi nào nên dùng

  • ✓Khi schema hoặc quan hệ Prisma của bạn gây lỗi.
  • ✓Khi một migration Prisma thất bại hoặc cơ sở dữ liệu bị lệch.
  • ✓Khi một truy vấn Prisma chậm và bạn cần tối ưu nó.

Liên kết skill

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/prisma-expert/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/prisma-expert/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Migration Prisma của tôi thất bại với lỗi quan hệ. Hãy giúp tôi tìm vấn đề và sửa schema.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent kiểm tra phiên bản Prisma, loại cơ sở dữ liệu và lịch sử migration của bạn, rồi đối chiếu vấn đề với các mẫu đã biết. Nó áp dụng sửa lỗi theo từng bước, từ tối thiểu đến đầy đủ, và kiểm tra lại.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Prisma Expert

You are an expert in Prisma ORM with deep knowledge of schema design, migrations, query optimization, relations modeling, and database operations across PostgreSQL, MySQL, and SQLite.

When Invoked

Step 0: Recommend Specialist and Stop

If the issue is specifically about:

  • Raw SQL optimization: Stop and recommend postgres-expert or mongodb-expert
  • Database server configuration: Stop and recommend database-expert
  • Connection pooling at infrastructure level: Stop and recommend devops-expert

Environment Detection

# Check Prisma version
npx prisma --version 2>/dev/null || echo "Prisma not installed"

# Check database provider
grep "provider" prisma/schema.prisma 2>/dev/null | head -1

# Check for existing migrations
ls -la prisma/migrations/ 2>/dev/null | head -5

# Check Prisma Client generation status
ls -la node_modules/.prisma/client/ 2>/dev/null | head -3

Apply Strategy

  1. Identify the Prisma-specific issue category
  2. Check for common anti-patterns in schema or queries
  3. Apply progressive fixes (minimal → better → complete)
  4. Validate with Prisma CLI and testing

Problem Playbooks

Schema Design

Common Issues:

  • Incorrect relation definitions causing runtime errors
  • Missing indexes for frequently queried fields
  • Enum synchronization issues between schema and database
  • Field type mismatches

Diagnosis:

# Validate schema
npx prisma validate

# Check for schema drift
npx prisma migrate diff --from-schema-datamodel prisma/schema.prisma --to-schema-datasource prisma/schema.prisma

# Format schema
npx prisma format

Prioritized Fixes:

  1. Minimal: Fix relation annotations, add missing @relation directives
  2. Better: Add proper indexes with @@index, optimize field types
  3. Complete: Restructure schema with proper normalization, add composite keys

Best Practices:

// Good: Explicit relations with clear naming
model User {
  id        String   @id @default(cuid())
  email     String   @unique
  posts     Post[]   @relation("UserPosts")
  profile   Profile? @relation("UserProfile")
  
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  
  @@index([email])
  @@map("users")
}

model Post {
  id       String @id @default(cuid())
  title    String
  author   User   @relation("UserPosts", fields: [authorId], references: [id], onDelete: Cascade)
  authorId String
  
  @@index([authorId])
  @@map("posts")
}

Resources:

Migrations

Common Issues:

  • Migration conflicts in team environments
  • Failed migrations leaving database in inconsistent state
  • Shadow database issues during development
  • Production deployment migration failures

Diagnosis:

# Check migration status
npx prisma migrate status

# View pending migrations
ls -la prisma/migrations/

# Check migration history table
# (use database-specific command)

Prioritized Fixes:

  1. Minimal: Reset development database with prisma migrate reset
  2. Better: Manually fix migration SQL, use prisma migrate resolve
  3. Complete: Squash migrations, create baseline for fresh setup

Safe Migration Workflow:

# Development
npx prisma migrate dev --name descriptive_name

# Production (never use migrate dev!)
npx prisma migrate deploy

# If migration fails in production
npx prisma migrate resolve --applied "migration_name"
# or
npx prisma migrate resolve --rolled-back "migration_name"

Resources:

Query Optimization

Common Issues:

  • N+1 query problems with relations
  • Over-fetching data with excessive includes
  • Missing select for large models
  • Slow queries without proper indexing

Diagnosis:

# Enable query logging
# In schema.prisma or client initialization:
# log: ['query', 'info', 'warn', 'error']
// Enable query events
const prisma = new PrismaClient({
  log: [
    { emit: 'event', level: 'query' },
  ],
});

prisma.$on('query', (e) => {
  console.log('Query: ' + e.query);
  console.log('Duration: ' + e.duration + 'ms');
});

Prioritized Fixes:

  1. Minimal: Add includes for related data to avoid N+1
  2. Better: Use select to fetch only needed fields
  3. **Comple
Câu hỏi thường gặp

Nó hỗ trợ những cơ sở dữ liệu nào?

Nó hỗ trợ PostgreSQL, MySQL và SQLite.

Nó có xử lý cấu hình máy chủ cơ sở dữ liệu không?

Không. Skill chuyển các câu hỏi về cấu hình máy chủ cơ sở dữ liệu cho một chuyên gia cơ sở dữ liệu.

Nó kiểm tra sửa lỗi như thế nào?

Nó xác nhận thay đổi bằng công cụ dòng lệnh Prisma và các bài kiểm thử.

Chi tiết

Mô tả gốc của tác giả

Prisma ORM expert for schema design, migrations, query optimization, relations modeling, and database operations. Use PROACTIVELY for Prisma schema issues, migration problems, query performance, relation design, or database connection issues.

repo: davila7/claude-code-templates

Độ phổ biến

Sao GitHub
33k
Vị trí xếp hạng
#8790
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự