database-schema-reviewer
Reviews database schemas for normalization issues, missing indexes, naming inconsistencies, and scalability risks.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Reviews database schemas for normalization issues, missing indexes, naming inconsistencies, and scalability risks.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Runs a systematic checklist review on any code diff or file, covering correctness, security, performance, and readability.
Writes a high-quality CLAUDE.md, .cursorrules, or .windsurfrules file that gives a coding agent the right project context, conventions, and constraints to work effectively.
Designs an eval suite for an LLM agent or pipeline including success metrics, trajectory scoring, LLM-as-judge setup, and regression test cases.
Designs a hybrid retrieval pipeline combining dense vector search and BM25 sparse search with reciprocal rank fusion, and explains when to use each configuration.
Converts a workflow description into a LangGraph node/edge graph with typed state, conditional routing, and human-in-the-loop checkpoints.
Audits an AI application for unnecessary token spend and recommends prompt caching, model routing, and token reduction techniques to cut costs.
| name | Database Schema Reviewer |
| description | Reviews database schemas for normalization issues, missing indexes, naming inconsistencies, and scalability risks. |
| category | data |
| tags | ["database","sql","schema","postgresql","mysql"] |
| author | simplyutils |
This skill directs the agent to review a database schema — provided as SQL DDL, an ORM model file (Drizzle, Prisma, SQLAlchemy, ActiveRecord, etc.), or a plain description — and produce a prioritized list of issues. It checks normalization, indexes, constraints, naming conventions, nullable columns, and overall scalability. Every issue includes a concrete SQL or ORM fix.
Use this before deploying a new schema to production, during code review of a migration file, or when a database is growing and you're starting to feel query pain.
Copy this file to .agents/skills/database-schema-reviewer/SKILL.md in your project root.
Then share your schema and ask:
shared/schema.ts."Provide the full schema file, a SQL DDL dump, or paste the relevant CREATE TABLE statements.
Add the "Prompt / Instructions" section to your .cursorrules file. Open your schema or migration file and ask Cursor to review it.
Paste the schema DDL or ORM model definitions into the chat along with the instructions below. Include any known query patterns if you want index recommendations tailored to your workload.
When asked to review a database schema, follow these steps:
Parse the schema. Accept any format:
CREATE TABLE statements)model blocks)Check normalization:
zip_code and city in the same table as user_id)Check indexes:
WHERE, ORDER BY, or JOIN conditions should be indexed — infer from column names (e.g., email, status, created_at, user_id)email in a users table)Check constraints:
REFERENCES constraintNOT NULL but are nullable: primary-purpose columns like email, name, created_atDEFAULT value but don't (e.g., created_at, boolean flags)ON DELETE / ON UPDATE behavior on foreign keysCheck naming conventions:
id (or table_id) — flag non-standard PK namesreferenced_table_id — flag deviationsis_, has_, or can_ prefix — flag ambiguous names like active or enabledFlag scalability risks:
TEXT or VARCHAR(MAX) for columns that are used in WHERE clauses or indexesENUM types in PostgreSQL/MySQL where the values change frequently (painful to alter)SELECT * traps: wide tables with many columns that are rarely all needed together (suggest splitting)Suggest missing tables or relationships if the schema implies data that has no home (e.g., a role column on users with no roles table, suggesting future extensibility issues).
Prioritize findings:
Output format:
## Schema Review Results
### Summary
[X] High · [Y] Medium · [Z] Low findings across [N] tables
---
### High Priority
#### [Issue title] — [Table.column]
**Problem:** [Plain English explanation]
**Risk:** [What goes wrong if this isn't fixed]
**Fix:**
```sql
[concrete SQL or ORM fix]
[repeat by priority level]
## Example
**Input to Agent:**
> "Use the Database Schema Reviewer skill on this schema:
>
> ```sql
> CREATE TABLE users (
> id SERIAL PRIMARY KEY,
> name VARCHAR(255),
> email VARCHAR(255),
> role VARCHAR(50),
> address TEXT,
> city VARCHAR(100),
> zip VARCHAR(20),
> created TIMESTAMP
> );
>
> CREATE TABLE orders (
> order_id SERIAL PRIMARY KEY,
> userId INTEGER,
> items TEXT,
> status VARCHAR(50),
> total DECIMAL(10,2)
> );
> ```"
**Output from Agent:**
> ## Schema Review Results
>
> ### Summary
> 4 High · 3 Medium · 2 Low findings across 2 tables
>
> ---
>
> ### High Priority
>
> #### Missing UNIQUE constraint on users.email
> **Problem:** Email is the primary identifier for login but has no unique constraint. Duplicate accounts can be created.
> **Risk:** Authentication bugs, data corruption, duplicate account merging nightmare.
> **Fix:**
> ```sql
> ALTER TABLE users ADD CONSTRAINT users_email_unique UNIQUE (email);
> CREATE INDEX idx_users_email ON users (email);
> ```
>
> #### orders.userId has no foreign key constraint
> **Problem:** `userId` references the `users` table logically but has no `REFERENCES` constraint. Orphaned orders with deleted users will exist silently.
> **Risk:** Referential integrity violations, broken order history views.
> **Fix:**
> ```sql
> ALTER TABLE orders ADD CONSTRAINT fk_orders_user
> FOREIGN KEY (userId) REFERENCES users(id) ON DELETE RESTRICT;
> CREATE INDEX idx_orders_user_id ON orders (userId);
> ```
>
> #### orders.items stores multiple values in a TEXT column (1NF violation)
> **Problem:** Storing order items as a text blob violates first normal form and makes querying individual items impossible without string parsing.
> **Risk:** Impossible to query "which orders contain product X", no referential integrity on items.
> **Fix:** Create an `order_items` table:
> ```sql
> CREATE TABLE order_items (
> id SERIAL PRIMARY KEY,
> order_id INTEGER NOT NULL REFERENCES orders(order_id) ON DELETE CASCADE,
> product_id INTEGER NOT NULL,
> quantity INTEGER NOT NULL DEFAULT 1,
> unit_price DECIMAL(10,2) NOT NULL
> );
> ```
>
> ---
>
> ### Medium Priority
>
> #### users.city and users.zip are a transitive dependency (3NF violation)
> **Problem:** City and zip code describe each other, not the user. Moving address data to an `addresses` table is cleaner for reuse and consistency.
>
> #### users.created should be NOT NULL with a DEFAULT
> **Fix:** `created TIMESTAMP NOT NULL DEFAULT NOW()`
>
> #### Naming inconsistency: orders uses order_id and userId (mixed conventions)
> **Fix:** Rename to `id` and `user_id` to match PostgreSQL snake_case convention.
>
> ---
>
> ### Passed Checks
> - Primary keys are present on both tables
> - DECIMAL used correctly for monetary values (not FLOAT)