本文へスキップ
Skillpedia
APIとサーバー(バックエンド)48k · #5495

prisma-expert

できること

Prismaの専門家として動くエージェントです。Prismaは開発者がデータベースを扱うためのツールです。データの構造設計(スキーマ設計)、データベースの変更(マイグレーション)、クエリの高速化(クエリ最適化)、データ同士の関連付け(リレーションモデリング)を理解しています。

使う場面

  • ✓Prismaでデータベースをどのように構成すればよいか疑問があるとき。
  • ✓データベースのクエリの処理が遅いとき。
  • ✓データベースの更新を作成・管理する必要があるとき。

スキルのリンク

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/prisma-expert/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/prisma-expert/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“Prismaで、ユーザーとその投稿をより速く取得するには、クエリをどう最適化すればよいですか?”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントはコードとPrismaの設定を分析して、よくある問題を見つけ出します。簡単な調整から複雑な変更まで、Prismaのベストプラクティスに沿った修正案を提案します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

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

…

よくある質問

Prisma ORMとは何ですか?

Prisma ORMは、開発者がデータベースを扱う作業を簡単にするツールで、データを管理するための、より安全で効率的なコードを書く助けになります。

Prismaの「マイグレーション」とは何ですか?

データベースの構造に加えられた変更の「バージョン」のようなものです。データベースを管理された一貫性のある方法で更新できるようにします。

「クエリ最適化」とは何を意味しますか?

データベースの検索やデータ操作をより速く効率的にする作業のことで、アプリの動作が遅くなるのを防ぎます。

詳細

作者による元の説明

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.

repo: sickn33/agentic-awesome-skills

人気

GitHubのスター
48k
ランキング
#5495
ライセンス
MIT
更新日
2026/10/15

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル