skills/mav-bp-database-management/SKILL.md
Database and data management conventions for all projects using databases. Covers schema migrations, backup strategy, data lifecycle, index management, and connection pooling. Applied when designing, implementing, or reviewing database interactions.
npx skillsauth add thermiteau/maverick mav-bp-database-managementInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Ensure all database interactions are safe, reproducible, and well-managed. Covers schema migrations, backup strategy, data lifecycle, index management, and connection pooling.
Before applying these standards, load the project-specific database management implementation:
digraph lookup {
"docs/maverick/skills/database-management/SKILL.md exists?" [shape=diamond];
"Read and use alongside these standards" [shape=box];
"Invoke upskill" [shape=box];
"Read generated skill" [shape=box];
"docs/maverick/skills/database-management/SKILL.md exists?" -> "Read and use alongside these standards" [label="yes"];
"docs/maverick/skills/database-management/SKILL.md exists?" -> "Invoke upskill" [label="no"];
"Invoke upskill" -> "Read generated skill";
"Read generated skill" -> "Read and use alongside these standards";
}
docs/maverick/skills/database-management/SKILL.mddo-upskill skill with:
migration|migrate|createTable|addColumn|Schema\.create|db\.execute|pool\.query|connectionString|DATABASE_URL**/migrations/**, **/db/**, **/database/**, **/schema.*, **/knexfile.*, **/prisma/schema.prismaEvery migration must be a versioned file with a sequential or timestamp-based identifier:
migrations/
001_create_users_table.sql
002_add_email_index.sql
003_create_orders_table.sql
Or with timestamps:
migrations/
20240115100000_create_users_table.sql
20240116143000_add_email_index.sql
20240117091500_create_orders_table.sql
IF NOT EXISTS, IF EXISTS guards)| Ecosystem | Tool | Notes | | ----------- | ----------------------------- | ---------------------------------------------- | | Node.js | Prisma Migrate, Knex, TypeORM | Use the project's chosen ORM migration system | | Python | Alembic, Django Migrations | Auto-generate from models, review before apply | | Java/Kotlin | Flyway, Liquibase | SQL-based or XML/YAML changelogs | | Go | golang-migrate, goose | Plain SQL migrations | | Ruby | Active Record Migrations | Ruby DSL with reversible blocks | | Rust | Diesel, sqlx | Compile-time checked SQL |
Avoid these patterns in production migrations:
| Pattern | Risk | Safe Alternative |
| --------------------------------- | --------------------------------- | -------------------------------------------------------- |
| DROP COLUMN immediately | Breaks running application code | Deploy code that stops reading the column first |
| ALTER COLUMN change type | Locks table, may lose data | Add new column, backfill, switch reads, drop old column |
| RENAME COLUMN | Breaks running queries | Add new column, backfill, update code, drop old column |
| Large UPDATE in migration | Locks table for extended period | Backfill in batches outside the migration |
| NOT NULL on existing column | Fails if any rows have null | Backfill nulls first, then add constraint |
Maintain a runbook that covers:
WHERE, JOIN, ORDER BY, and GROUP BY clauses of actual queriesINSERT, UPDATE, and DELETE| Check | Action | | ---------------------------------------- | -------------------------------------------------------- | | New query without index coverage | Add index or verify table is small enough for scan | | New index on a high-write table | Measure write performance impact before deploying | | Composite index with low-selectivity lead| Reorder columns for better selectivity | | Duplicate or overlapping indexes | Remove the redundant index | | Index on a boolean or low-cardinality column | Usually not useful — verify with query plan |
| Setting | Guideline |
| -------------------- | -------------------------------------------------------------- |
| min pool size | 2-5 connections for low-traffic services |
| max pool size | Start with (CPU cores * 2) + disk spindles, tune from there |
| idleTimeout | 10-30 seconds — release unused connections back to the pool |
| connectionTimeout | 5-10 seconds — fail fast if pool is exhausted |
| maxLifetime | 30 minutes — rotate connections to handle DNS/IP changes |
When reviewing code, flag these patterns:
| Pattern | Issue | Fix |
| -------------------------------------------------- | ---------------------------------- | ------------------------------------------------------ |
| Raw SQL without parameterised queries | SQL injection risk | Use parameterised queries or ORM |
| Manual schema change (ad-hoc DDL) | Unreproducible, untracked change | Create a migration file |
| Editing an already-applied migration | Breaks migration history | Write a new migration |
| No index on columns used in WHERE/JOIN | Performance degradation at scale | Add appropriate index |
| Opening connection per request (no pooling) | Connection exhaustion | Use connection pool |
| Hardcoded connection string | Security risk, environment coupling| Use environment variables or secrets manager |
| Missing down migration | Cannot revert in development | Add reversible down operation |
| Production data in seed files | Data leak, privacy violation | Use synthetic data only |
| DROP TABLE or DROP COLUMN without staged rollout| Breaks running application | Stage the change: remove code references first |
| No transaction wrapping for multi-step migration | Partial application on failure | Wrap in transaction where the database supports it |
development
--- name: do-test description: Write or update tests for a code change. Operates in two modes: `unit` (module-scoped, fast, deterministic) and `integration` (crosses module / service / database boundaries). Intended to be invoked once per testable change from inside a do-issue-* or do-epic phase. Mode is required. argument-hint: mode: unit or integration user-invocable: true disable-model-invocation: false --- **Depends on:** mav-bp-unit-testing, mav-bp-integration-testing, mav-local-verificati
development
Implement a focused code change. Use this skill as the wrapper for any implementation work so the Maverick workflow report captures what was done and so the agent applies the project's coding standards before editing. Intended to be invoked once per task from inside a do-issue-* or do-epic phase, not standalone.
testing
How to stack a PR on top of an unmerged sibling branch, and how to retarget it to the repo's default branch once the sibling merges. Prevents orphan-merge incidents when a dependent story is ready before its parent.
development
Claim, lease, heartbeat, and release protocols for when multiple Claude Code instances may act on the same issue or epic concurrently. GitHub labels and marker comments are the coordination surface; local state is a cache.