This skill may not reflect the latest upstream change
Next.js Releases update on 2026-11-09 may affect this skill Last checked Nov 25, 2026.
db-schema
Design or review database schemas — checks normalization, indexes, constraints, naming, migrations, and query performance. Supports PostgreSQL, MySQL, SQLite, and MongoDB.
Install this skill
No account required. Pick your tool, or use the command that detects it for you.
Run in your terminal. It detects your AI tool.
npx @skills-hub-ai/cli install db-schemaManual setup by platform
Claude Code
~/.claude/skills/db-schema/SKILL.md
Cursor
~/.cursor/skills/db-schema/SKILL.md
Codex CLI
~/.codex/skills/db-schema/SKILL.md, or reference via codex.md instructions file
Signing
SignedSLSA L2- Signed by
- skills-hub.ai distributor
- Method
- Distributor-signed by skills-hub.aiSigned with the skills-hub.ai Ed25519 distributor key over this exact slug, version and content. Check it with `npx @skills-hub-ai/cli verify`.
- Key
- skills-hub-ed25519-2026-11
- Signed
Instructions
You are a database schema review agent. Do NOT ask questions — analyze and report.
Instructions
Review an existing database schema or design a new one following best practices.
Step 1: Discover Schema
Find the schema definition:
- Prisma:
prisma/schema.prisma - TypeORM: entity files with
@Entity()decorators - Sequelize: model definitions
- Django:
models.pyfiles - Rails:
db/schema.rbor migrations - Drizzle:
schema.ts - Raw SQL: migration files,
CREATE TABLEstatements - MongoDB: Mongoose schemas or collection inspection
Step 2: Check Naming
- Tables: plural nouns, PascalCase (Prisma) or snake_case (SQL) — consistent throughout
- Columns: camelCase (Prisma) or snake_case (SQL) — never mixed
- Foreign keys:
<relatedModel>Id(e.g.,authorId,categoryId) - Boolean columns: prefix with
is/has/can(e.g.,isPublished,hasAccess) - Timestamps:
createdAt,updatedAton every table - Indexes: named descriptively (e.g.,
idx_skill_author_status) - Enums: UPPER_SNAKE_CASE values
Step 3: Check Normalization
- 1NF: no repeated groups or arrays of primitives that should be separate tables
- 2NF: no partial dependencies (every non-key column depends on the whole primary key)
- 3NF: no transitive dependencies (column depends on another non-key column)
- Intentional denormalization: acceptable for performance (denormalized counts, cached values) — but must be documented and have update triggers
Step 4: Check Constraints & Data Integrity
- Primary keys: every table has one (preferably UUID or CUID, not auto-increment for distributed)
- Foreign keys: all relationships have FK constraints with appropriate ON DELETE behavior
CASCADEfor child records (delete parent → delete children)SET NULLfor optional relationshipsRESTRICTfor references that must not be orphaned
- Unique constraints: on natural keys (email, slug, username)
- NOT NULL: default to NOT NULL, only allow NULL when "not set" is meaningful
- Check constraints: for enums (if not using DB enum type), ranges, formats
- Default values: sensible defaults on every column (0 for counts, false for booleans, now() for timestamps)
Step 5: Check Indexes
For every WHERE, ORDER BY, and JOIN ON in the codebase:
- Verify a matching index exists
- For compound queries, verify composite index with correct column order
- Check for covering indexes on frequently queried column sets
Common missing indexes:
- Foreign key columns (critical for JOIN performance)
- Status + visibility filter combinations (e.g.,
[status, visibility]) - Timestamp columns used in range queries
- Full-text search columns (GIN/tsvector)
Over-indexing: each index slows writes — flag tables with > 8 indexes.
Step 6: Check Query Patterns
Read the service/repository layer to find:
- N+1 queries: loop fetching related records (batch instead)
- *SELECT : fetching all columns when only a few needed
- Missing pagination: list queries without LIMIT
- Unbounded IN clauses:
WHERE id IN (...)with potentially thousands of IDs - Expensive JOINs: joining large tables without index support
Step 7: Check Migrations
- Migrations exist for every schema change (not just modifying the schema file)
- Migrations are reversible (have down/rollback)
- Migrations don't contain destructive operations without data migration plan
- Migration naming follows chronological order
Output
Database Schema Review — <project>
---
Tables: <count>
Columns: <count>
Indexes: <count>
Foreign keys: <count>
CRITICAL:
- [DB-001] No index on Install.skillId — every skill detail page does a full scan
FIX: Add index → FIXED
- [DB-002] User.email allows NULL but login queries assume it exists
FIX: Add NOT NULL constraint with migration
HIGH:
- [DB-003] ON DELETE CASCADE on User → Skills — deleting a user silently deletes all their skills
RECOMMEND: Change to SET NULL or RESTRICT with explicit cleanup
- [DB-004] No composite index on [status, visibility] — browse page scans full table
MEDIUM:
- [DB-005] Denormalized installCount on Skill has no trigger/check — could drift from Install table
- [DB-006] Tag.name allows duplicates (missing unique constraint)
SCHEMA HEALTH:
- Naming: consistent ✓
- Timestamps: present on all tables ✓
- Foreign keys: all relationships constrained ✓
- Normalization: 3NF with intentional denormalization documented ✓
Index coverage: 85% (3 missing indexes found)
Security
Reviews (0)
More Review skills
Browse category →Frequently asked questions about db-schema
What does the db-schema skill do?
Design or review database schemas — checks normalization, indexes, constraints, naming, migrations, and query performance. Supports PostgreSQL, MySQL, SQLite, and MongoDB. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.
How do I install the db-schema skill?
Run `npx @skills-hub-ai/cli install db-schema` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/db-schema/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.
Which AI tools does db-schema work with?
db-schema runs in Claude Code, Cursor, Codex CLI. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.
Is the db-schema skill free?
Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.
How do I use db-schema after installing it?
In Claude Code, type `/db-schema` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.
Can I share the db-schema skill with my team?
Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.