Automated summary
Provides a database review checklist covering schema design, query optimization, migrations, and SQL security, insisting that execution plans be understood before deployment.
Strengths
- Issue/solution tables make schema, query, migration, and security defects quick to spot
- Concrete before/after examples: N+1 queries, SQL injection, and a three-step safe NOT NULL column addition
- An explicit iron law (an execution plan plus index analysis per query, cardinality for every JOIN) with severity guidelines
- Separate reference files for violations, correct patterns, and automated detection commands
Limitations
- Read-only skill (Read, Grep, Glob): it cannot run EXPLAIN or inspect a live database, so plan verification is guidance rather than evidence
- Advice is mostly SQL/PostgreSQL-oriented, with little coverage of NoSQL or ORM-specific behavior
- Examples are brief and assume familiarity with relational databases
Use it when reviewing a PR that touches queries, indexes, schema, or migration files.
Don't use it for live production performance profiling or for actually executing a migration against a database.
Security analysis
SafeThe skill is a documentation/review reference for database design, query optimization, migrations, and security. It declares only read-only tools (Read, Grep, Glob) and contains no executable commands, destructive actions, exfiltration, or obfuscated payloads. Example SQL/TypeScript snippets are illustrative and not executed by the skill.
No concerns found
How this analysis is madeExamples
Review this migration that adds a NOT NULL email column to our 5M-row users table — what could break in production and how do I make it safe?Here's the order-listing endpoint that loops over users and queries orders inside the loop — check for N+1 queries and tell me which indexes the WHERE and JOIN columns need.Audit these query builders for SQL injection and check whether the application user really needs GRANT ALL on this schema.name: database description: This skill should be used when reviewing database queries, migrations, indexes, or schema changes. user-invocable: false allowed-tools: Read, Grep, Glob
Database Patterns
Domain expertise for database design and optimization. Use alongside devflow:review-methodology for complete database reviews.
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 |
Example - Missing Constraints:
-- VIOLATION
CREATE TABLE products (id SERIAL, name VARCHAR(100), price DECIMAL);
-- CORRECT
CREATE TABLE products (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL CHECK (LENGTH(TRIM(name)) > 0),
price DECIMAL(10, 2) NOT NULL CHECK (price >= 0)
);
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 |
Example - N+1 Query:
// VIOLATION: 101 queries for 100 users
for (const user of users) {
user.orders = await db.query('SELECT * FROM orders WHERE user_id = ?', [user.id]);
}
// CORRECT: 2 queries total
const orders = await db.query('SELECT * FROM orders WHERE user_id = ANY($1)', [userIds]);
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 |
Example - Safe Column Addition:
-- Step 1: Add nullable (instant)
ALTER TABLE users ADD COLUMN phone VARCHAR(20);
-- Step 2: Backfill in batches
UPDATE users SET phone = 'UNKNOWN' WHERE phone IS NULL AND id BETWEEN 1 AND 10000;
-- Step 3: Add constraint after backfill
ALTER TABLE users ALTER COLUMN phone SET NOT NULL;
4. Security Issues
| Issue | Problem | Solution | |-------|---------|----------| | SQL Injection | String interpolation in queries | Parameterized queries only | | Excessive Privileges | App has GRANT ALL | Minimum required privileges |
Example - SQL Injection:
// VULNERABLE
const query = `SELECT * FROM users WHERE email = '${email}'`;
// SECURE
const query = 'SELECT * FROM users WHERE email = $1';
await db.query(query, [email]);
Extended References
For detailed examples and detection commands, see:
- 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 |
Database Checklist
Before approving database changes:
- [ ] All queries have appropriate indexes
- [ ] N+1 patterns identified and resolved
- [ ] Migrations have rollback scripts
- [ ] Data types are appropriate
- [ ] Constraints enforce business rules
- [ ] Foreign keys maintain referential integrity
- [ ] No SQL injection vulnerabilities
- [ ] Performance tested with production-like data volume
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/database-patterns-mryiqgja/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/database-patterns-mryiqgja' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/database-patterns-mryiqgja/download' --output '.skill-downloads/database-patterns-mryiqgja/SKILL.md.part' && mv '.skill-downloads/database-patterns-mryiqgja/SKILL.md.part' '.skill-downloads/database-patterns-mryiqgja/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
Tools declared by the author (check availability in your agent): Read, Grep, Glob
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/database-patterns-mryiqgja/SKILL.md' && test -s '.skill-downloads/database-patterns-mryiqgja/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/database' && cp -R '.skill-downloads/database-patterns-mryiqgja' '.claude/skills/database'Cursor
test -f '.skill-downloads/database-patterns-mryiqgja/SKILL.md' && test -s '.skill-downloads/database-patterns-mryiqgja/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/database' && cp -R '.skill-downloads/database-patterns-mryiqgja' '.cursor/skills/database'Codex
test -f '.skill-downloads/database-patterns-mryiqgja/SKILL.md' && test -s '.skill-downloads/database-patterns-mryiqgja/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/database' && cp -R '.skill-downloads/database-patterns-mryiqgja' '.agents/skills/database'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/database-patterns-mryiqgja'openskills read 'database-patterns-mryiqgja'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/database-patterns-mryiqgja/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.