db-review

$npx mdskill add tranhieutt/software_development_department/db-review

Reviews database schemas, migrations, and queries for correctness and performance.

  • Ensures schemas, migrations, and queries follow best practices and are error-free.
  • Uses Read, Glob, and Grep tools to analyze SQL files and project structure.
  • Evaluates schema design, indexing, migration safety, and query performance.
  • Outputs a structured review with checklists and actionable recommendations.

SKILL.md

.github/skills/db-reviewView on GitHub ↗
---
name: db-review
type: workflow
description: "Reviews database schemas, queries, and migrations for correctness, performance, security, and best practices. Use when reviewing SQL migration files or when the user mentions database review, schema review, or query audit."
argument-hint: "[path-to-schema-migration-or-query-files]"
user-invocable: true
allowed-tools: Read, Glob, Grep
context: fork
agent: data-engineer
effort: 2
when_to_use: "When reviewing database schemas, migrations, or queries for correctness, performance, and data integrity"
---

When this skill is invoked:

1. **Read the target schema, migration, or query files** in full.

2. **Evaluate schema design**:
   - [ ] All tables have a primary key
   - [ ] Tables have `created_at` and `updated_at` columns
   - [ ] Foreign key relationships defined with proper constraints
   - [ ] Column types are appropriate (don't use VARCHAR(255) for everything)
   - [ ] NULL vs NOT NULL is intentionally chosen and documented
   - [ ] Enum types used for fixed sets of values

3. **Evaluate indexing strategy**:
   - [ ] Every foreign key column is indexed
   - [ ] Columns in frequent WHERE, ORDER BY, or JOIN conditions are indexed
   - [ ] Composite indexes match the query patterns
   - [ ] No over-indexing (too many indexes slow writes)
   - [ ] Unique constraints used where business rules require uniqueness

4. **Evaluate migration safety**:
   - [ ] Migration is reversible (has a down/rollback script)
   - [ ] Adding columns with defaults is safe for zero-downtime
   - [ ] Removing columns uses soft-delete / multi-phase approach
   - [ ] Renaming columns uses multi-phase migration (add → backfill → drop old)
   - [ ] Large table operations consider locking implications

5. **Evaluate data integrity**:
   - [ ] Check constraints for value ranges where appropriate
   - [ ] No orphaned records possible (foreign keys or enforced at app layer)
   - [ ] Soft delete implemented (`deleted_at`) not hard delete for important records

6. **Evaluate query quality** (if queries provided):
   - [ ] No SELECT * in application queries
   - [ ] N+1 queries avoided (eager loading where needed)
   - [ ] Parameterized queries (no string concatenation)
   - [ ] Pagination on all list queries

7. **Output the review**:

```
## Database Review: [Schema/Migration Name]

### Schema Design: [CLEAN / ISSUES FOUND]
[List design problems]

### Indexes: [APPROPRIATE / MISSING / OVER-INDEXED]
[List index recommendations]

### Migration Safety: [SAFE / RISKY / BLOCKING]
[List migration risks and recommendations]

### Data Integrity: [ENFORCED / GAPS FOUND]
[List integrity concerns]

### Query Quality: [CLEAN / ISSUES FOUND]
[List query problems]

### Positive Observations
[What is well-designed]

### Required Changes
[Must-fix before applying]

### Suggestions
[Nice-to-have improvements]

### Verdict: [APPROVED / APPROVED WITH SUGGESTIONS / CHANGES REQUIRED]
```

## Protocol

- **Question**: Auto-starts from argument (schema, migration, or query files)
- **Options**: Skip — single review path
- **Decision**: Skip — verdict is advisory
- **Draft**: Full review shown in conversation only
- **Approval**: Skip — read-only; no files written

## Output

Deliver exactly:

- **Schema score** (X/6 design checks passing)
- **Migration safety**: `SAFE` / `RISKY` / `BLOCKING` with specific risks listed
- **Required changes** — must fix before applying migration (or "None")
- **Verdict**: `APPROVED` / `APPROVED WITH SUGGESTIONS` / `CHANGES REQUIRED`

More from tranhieutt/software_development_department

SkillDescription
agent-healthReads production/traces/agent-metrics.jsonl and displays a per-agent performance summary table for the current or a specified session. Highlights agents with high error rates or OPEN circuit breaker state.
agent-styleProvides the vendored agent-style v0.3.5 prose rule pack as a portable Claude skill. Use when installing, syncing, applying, or auditing SDD Agent-Style support in another project, or when a style-review workflow needs the bundled rules.
angular-best-practicesProvides Angular best practices for components, modules, services, and reactive patterns. Use when working with Angular TypeScript files, component templates, NgModules, RxJS observables, or when the user mentions Angular, ng, or Angular CLI.
annotateRecords unexpected API behaviors, undocumented caveats, version bugs, or non-obvious workarounds into .claude/memory/annotations.md. Use immediately when an undocumented behavior or surprising caveat is discovered during development.
aws-serverlessProvides AWS serverless architecture patterns for Lambda, API Gateway, DynamoDB, SQS, and SAM/CDK. Use when working with AWS serverless files (serverless.yml, CDK stacks) or when the user mentions Lambda, API Gateway, serverless, or AWS SAM.
backend-architectDesigns scalable backend architectures covering microservices, event-driven systems, API gateways, and data stores. Use when designing a backend system or when the user mentions backend architecture, scalability, or distributed systems.
cloud-run-puppeteerDeploys Puppeteer browser automation on Google Cloud Run with Docker. Use when running headless browser tasks on Cloud Run, or when the user mentions Cloud Run, Puppeteer, headless Chrome, or serverless browser automation.
codex-sddAdapts SDD for Codex while preserving Claude Code behavior. Use when working in Codex, setting up Codex compatibility, mapping Claude tools to Codex tools, or explaining how SDD should run outside Claude Code.
database-architectDesigns relational and NoSQL database schemas, indexing strategies, migration plans, and data modeling patterns. Use when designing a database or when the user mentions database architecture, schema design, or data modeling.
deep-interviewConducts a structured technical deep-dive to gather detailed requirements, constraints, and decisions from the user. Use when starting a complex feature or when the user wants to be asked structured clarifying questions before implementation.