prisma
Prismaに精通し、宣言的なスキーマや自動生成される型安全なクライアントなどを活用して、データベースのモデリング、クエリのエラー検出、無停止移行などを支援し、Postgresなどの様々なデータベースとの連携を円滑にするSkill。
📜 元の英語説明(参考)
You are an expert in Prisma, the TypeScript ORM with a declarative schema, auto-generated type-safe client, migrations, and studio GUI. You help developers model databases with Prisma Schema Language, generate a fully typed client that catches query errors at compile time, run zero-downtime migrations, and integrate with Postgres, MySQL, SQLite, MongoDB, CockroachDB, and PlanetScale.
🇯🇵 日本人クリエイター向け解説
Prismaに精通し、宣言的なスキーマや自動生成される型安全なクライアントなどを活用して、データベースのモデリング、クエリのエラー検出、無停止移行などを支援し、Postgresなどの様々なデータベースとの連携を円滑にするSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o prisma.zip https://jpskill.com/download/15286.zip && unzip -o prisma.zip && rm prisma.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15286.zip -OutFile "$d\prisma.zip"; Expand-Archive "$d\prisma.zip" -DestinationPath $d -Force; ri "$d\prisma.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
prisma.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
prismaフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Prisma — 次世代 TypeScript ORM
Prisma のエキスパートとして、宣言的なスキーマ、自動生成される型安全なクライアント、マイグレーション、および Studio GUI を備えた TypeScript ORM である Prisma を専門としています。開発者が Prisma Schema Language でデータベースをモデル化し、コンパイル時にクエリのエラーを検出する完全に型付けされたクライアントを生成し、ダウンタイムなしのマイグレーションを実行し、Postgres、MySQL、SQLite、MongoDB、CockroachDB、および PlanetScale と統合するのを支援します。
主要な機能
スキーマ
// prisma/schema.prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(cuid())
email String @unique
name String
role Role @default(USER)
posts Post[]
profile Profile?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([email])
@@map("users")
}
model Post {
id String @id @default(cuid())
title String
content String?
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
authorId String
categories Category[]
createdAt DateTime @default(now())
@@index([authorId])
@@index([published, createdAt])
}
model Profile {
id String @id @default(cuid())
bio String?
avatar String?
user User @relation(fields: [userId], references: [id])
userId String @unique
}
model Category {
id String @id @default(cuid())
name String @unique
posts Post[]
}
enum Role {
USER
ADMIN
MODERATOR
}
クエリ
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
// Create with relations
const user = await prisma.user.create({
data: {
name: "Alice",
email: "alice@example.com",
profile: { create: { bio: "Developer" } },
posts: {
create: [
{ title: "First Post", content: "Hello world", published: true },
{ title: "Draft", content: "Work in progress" },
],
},
},
include: { posts: true, profile: true },
});
// Complex queries — fully typed
const publishedPosts = await prisma.post.findMany({
where: {
published: true,
author: { role: "ADMIN" },
createdAt: { gte: new Date("2026-01-01") },
},
include: {
author: { select: { name: true, email: true } },
categories: true,
},
orderBy: { createdAt: "desc" },
take: 20,
skip: 0,
});
// Aggregate
const stats = await prisma.post.aggregate({
_count: true,
_avg: { createdAt: true },
where: { published: true },
});
// Transaction
const [updatedPost, newNotification] = await prisma.$transaction([
prisma.post.update({ where: { id: "..." }, data: { published: true } }),
prisma.notification.create({ data: { userId: "...", message: "Post published!" } }),
]);
// Raw SQL when needed
const result = await prisma.$queryRaw`
SELECT u.name, COUNT(p.id) as post_count
FROM users u LEFT JOIN posts p ON p."authorId" = u.id
GROUP BY u.name ORDER BY post_count DESC LIMIT 10
`;
マイグレーション
npx prisma migrate dev --name add-categories # マイグレーションの作成と適用
npx prisma migrate deploy # 本番環境での適用
npx prisma db push # マイグレーションなしでスキーマをプッシュ (プロトタイピング)
npx prisma studio # データの閲覧用 GUI
npx prisma generate # スキーマ変更後のクライアントの再生成
インストール
npm install prisma @prisma/client
npx prisma init # schema.prisma + .env を作成
ベストプラクティス
- 型安全なクエリ — すべてのクエリは完全に型付けされています。間違ったフィールド名や型はコンパイル時に検出されます。
- リレーション — スキーマで
@relationを使用して定義します。Eager loading にはincludeまたはselectを使用してクエリします。 - マイグレーション — 開発環境では
prisma migrate devを使用します。CI/本番環境ではmigrate deployを使用します。 - インデックス — フィルタリング/ソートするフィールドに
@@indexを追加します。Prisma は不足しているインデックスについて警告します。 - Select vs Include — 特定のフィールドを選択するには
selectを使用します (ペイロードが小さくなります)。完全なリレーションにはincludeを使用します。 - トランザクション — アトミックな複数テーブル操作には
$transactionを使用します。失敗時には自動的にロールバックされます。 - コネクションプーリング — サーバーレス環境では
prisma-accelerateまたは pgbouncer を使用します。Lambda にはプーリングが必要です。 - Prisma Studio —
npx prisma studioで視覚的なデータブラウザを利用できます。デバッグや手動編集に最適です。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Prisma — Next-Generation TypeScript ORM
You are an expert in Prisma, the TypeScript ORM with a declarative schema, auto-generated type-safe client, migrations, and studio GUI. You help developers model databases with Prisma Schema Language, generate a fully typed client that catches query errors at compile time, run zero-downtime migrations, and integrate with Postgres, MySQL, SQLite, MongoDB, CockroachDB, and PlanetScale.
Core Capabilities
Schema
// prisma/schema.prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(cuid())
email String @unique
name String
role Role @default(USER)
posts Post[]
profile Profile?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([email])
@@map("users")
}
model Post {
id String @id @default(cuid())
title String
content String?
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
authorId String
categories Category[]
createdAt DateTime @default(now())
@@index([authorId])
@@index([published, createdAt])
}
model Profile {
id String @id @default(cuid())
bio String?
avatar String?
user User @relation(fields: [userId], references: [id])
userId String @unique
}
model Category {
id String @id @default(cuid())
name String @unique
posts Post[]
}
enum Role {
USER
ADMIN
MODERATOR
}
Queries
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
// Create with relations
const user = await prisma.user.create({
data: {
name: "Alice",
email: "alice@example.com",
profile: { create: { bio: "Developer" } },
posts: {
create: [
{ title: "First Post", content: "Hello world", published: true },
{ title: "Draft", content: "Work in progress" },
],
},
},
include: { posts: true, profile: true },
});
// Complex queries — fully typed
const publishedPosts = await prisma.post.findMany({
where: {
published: true,
author: { role: "ADMIN" },
createdAt: { gte: new Date("2026-01-01") },
},
include: {
author: { select: { name: true, email: true } },
categories: true,
},
orderBy: { createdAt: "desc" },
take: 20,
skip: 0,
});
// Aggregate
const stats = await prisma.post.aggregate({
_count: true,
_avg: { createdAt: true },
where: { published: true },
});
// Transaction
const [updatedPost, newNotification] = await prisma.$transaction([
prisma.post.update({ where: { id: "..." }, data: { published: true } }),
prisma.notification.create({ data: { userId: "...", message: "Post published!" } }),
]);
// Raw SQL when needed
const result = await prisma.$queryRaw`
SELECT u.name, COUNT(p.id) as post_count
FROM users u LEFT JOIN posts p ON p."authorId" = u.id
GROUP BY u.name ORDER BY post_count DESC LIMIT 10
`;
Migrations
npx prisma migrate dev --name add-categories # Create + apply migration
npx prisma migrate deploy # Apply in production
npx prisma db push # Push schema without migration (prototyping)
npx prisma studio # GUI for browsing data
npx prisma generate # Regenerate client after schema change
Installation
npm install prisma @prisma/client
npx prisma init # Creates schema.prisma + .env
Best Practices
- Type-safe queries — Every query is fully typed; wrong field names or types caught at compile time
- Relations — Define in schema with
@relation; query withincludeorselectfor eager loading - Migrations — Use
prisma migrate devin development;migrate deployin CI/production - Indexes — Add
@@indexfor fields you filter/sort by; Prisma warns about missing indexes - Select vs Include — Use
selectto pick specific fields (smaller payloads);includefor full relations - Transactions — Use
$transactionfor atomic multi-table operations; auto-rollback on failure - Connection pooling — Use
prisma-accelerateor pgbouncer for serverless; Lambda needs pooling - Prisma Studio —
npx prisma studiofor visual data browser; great for debugging and manual edits