Skip to content
Back to skills

Database

ASecurity

Use when reviewing queries, migrations or schema changes.

  • 23 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 3, 2026
developmentgosqldatabasesecurityperformance

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned November 9, 2026

npx -y skills add dean0x/devflow --skill database --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Database?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Database
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/dean0x-database/badge)](https://www.skillsdirectory.com/skills/dean0x-database)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: database
description: Use when reviewing queries, migrations or schema changes.
user-invocable: false
allowed-tools: Read, Grep, Glob
---

# Database Patterns

Detection patterns for database design and query review. Use with `devflow:review-methodology`.

## Iron Law

> **Every query must have an execution plan.**
>
> Never deploy a query without understanding its execution plan. Every WHERE clause needs
> an index analysis. Every JOIN needs cardinality consideration. "It works in dev" is not
> validation. Production data volumes will expose every missing index and inefficient join.

## Database Categories

### 1. Schema Design Issues

| Issue | Problem | Solution |
|-------|---------|----------|
| Missing Foreign Keys | No referential integrity, orphaned records | Add FK with ON DELETE action |
| Denormalization | Unnecessary duplication, update anomalies | Normalize unless performance requires |
| Poor Data Types | VARCHAR for everything, lost precision | Use appropriate types (DECIMAL, BOOLEAN, TIMESTAMP) |
| Missing Constraints | No data validation at DB level | Add NOT NULL, CHECK, UNIQUE constraints |

### 2. Query Optimization Issues

| Issue | Problem | Solution |
|-------|---------|----------|
| N+1 Queries | Query per iteration, O(n) round trips | JOIN or batch with IN/ANY |
| Missing Indexes | Full table scans on large tables | Add indexes for WHERE/JOIN columns |
| Full Table Scans | Functions prevent index use | Functional indexes or query rewrite |
| Inefficient JOINs | Joining before filtering | Filter early, select specific columns |

### 3. Migration Issues

| Issue | Problem | Solution |
|-------|---------|----------|
| Breaking Changes | Data loss, no recovery path | Phased approach with backups |
| Data Loss Risk | Type changes truncate data | Validate before changing types |
| Missing Rollback | Cannot undo migration | Always implement down() method |
| Performance Impact | Table locks during migration | Add columns nullable, backfill in batches, then add the constraint |

### 4. Security Issues

| Issue | Problem | Solution |
|-------|---------|----------|
| SQL Injection | String interpolation in queries | Parameterized queries only |
| Excessive Privileges | App has GRANT ALL | Minimum required privileges |

## Extended References

- `references/violations.md` - Extended violation examples with explanations
- `references/patterns.md` - Correct patterns and migration strategies
- `references/detection.md` - Automated detection commands

## Severity Guidelines

| Severity | Criteria | Examples |
|----------|----------|----------|
| **CRITICAL** | Data integrity or severe performance | SQL injection, N+1 unbounded, data loss migrations, missing FK on critical relations |
| **HIGH** | Significant database issues | Inefficient JOINs, missing constraints, migrations without rollback |
| **MEDIUM** | Moderate concerns | Minor denormalization, missing non-critical indexes |
| **LOW** | Minor improvements | Naming conventions, index organization |

Files in this skill

  • SKILL.md4.7 KB
  • references/detection.md5.7 KB
  • references/patterns.md9.7 KB
  • references/violations.md8.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.