← Back to list

database-health-optimization
by Shiminize
⭐ 0🍴 0📅 Jan 22, 2026
SKILL.md
name: Database Health & Optimization description: Tools to validate schema, check for missing indexes, and audit Prisma patterns.
🗄️ Database Health & Optimization Skill
This skill operationalizes the knowledge of the Database Specialist agent. It ensures your Prisma schema is performant and your data integrity is maintained.
🎯 When to Use
- Modifying Schema: ALWAYS run audit before
prisma migrate. - Debugging Slow Queries: Check for missing indexes.
- Data Modeling: When adding new relations.
🛠️ Toolbelt
1. The Schema Auditor (Automated)
Checks schema.prisma for performance killers and missing indexes.
node .agent/skills/db-optimizer/scripts/audit-prisma-schema.js
2. The Migration Canary (Manual Guide)
STOP. Before you run a migration, verify against this table:
| Action | Risk Level | The Safe Way |
|---|---|---|
| Renaming Column | 🛑 DATA LOSS | Use @map("old_name") to keep DB column same, or write a manual SQL migration. |
| Changing Type | ⚠️ LOCKS | Be careful with large tables. Might need maintenance window. |
| Adding Relation | ⚠️ PERF | MUST add @@index([foreignKeyId]) on the child side. |
🚀 Workflows
Workflow A: The Safe Migration
Use this whenever you edit schema.prisma.
- Design: Edit the schema.
- Audit: Run
audit-prisma-schema.js. Fix any missing indexes. - Dry Run: Run
npx prisma migrate dev --create-only. - Review: Check the generated SQL file. Does it drop data?
- Apply: Only then, apply the migration.
Workflow B: The Performance Tune-up
Use this when users complain about slowness.
- Identify: Which query is slow? Find the
whereororderByclause. - Index: Add a composite index
@@index([fieldA, fieldB]). - Verify: Run
audit-prisma-schema.jsto ensure you didn't break rules.
🧠 Best Practices
- Foreign Keys: Prisma does NOT index FKs by default. You MUST do it manually.
- Json Fields: Avoid if possible. Relational tables are faster and safer.
- IDs: Use CUID (
cuid()) or UUID (uuid()) for primary keys. Never auto-increment integers for public IDs.
Score
Total Score
50/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
Reviews
💬
Reviews coming soon