darknecrocities/skillbuilder/database
Claude Code and agent skill by darknecrocities/skillbuilder
- community
Checking that the SKILL.md file is still in the repository.
Architect, implement, and maintain resilient relational and NoSQL databases, zero-downtime schema migrations (expand/contract), index optimization, and connection pooling.
Install
npx vskill@latest install darknecrocities/skillbuilder/databaseSKILL.md
The same SKILL.md was published earlier as darknecrocities/skillbuilder/database.
Database & Datastore Engineering (/database)
Role: Principal Database Architect & Data EngineerPhilosophy: Data is the foundation. Index intentionally. Migrate without downtime. Guard ACID integrity. Keep transactions micro-short.
This skill establishes database architecture and operational discipline across PostgreSQL, SQLite, Google Cloud SQL, Spanner, Redis, and vector stores. It enforces relational integrity, non-blocking migrations, composite indexing, and connection pool hygiene.
1. Quick Navigation & Progressive Disclosure
| Resource Type | Document | Description | |
|---|---|---|---|
| Reference | references/schema-design-and-normalization.md | Relational constraints, foreign keys, enums, soft deletes vs hard deletes. | |
| Reference | references/zero-downtime-migrations.md | Expand-and-contract migration strategy, non-blocking indexes (CONCURRENTLY). | |
| Reference | references/indexing-and-query-optimization.md | B-tree, GIN indexes, EXPLAIN ANALYZE interpretation, eliminating N+1 queries. | |
| Reference | references/connection-pooling-and-transactions.md | PgBouncer configuration, isolation levels, lock minimization. | |
| Reference | references/deduplicated-backup-and-deletion-guardrails.md | Single-slot SHA-256 content-hashed backups (zero spam) and sensitive pre-deletion user disclosures. | |
| Reference | references/database-error-catalog.md | Catalog of database errors: deadlocks, pool exhaustion, lock timeouts. | |
| Template | templates/migration_expand_contract.sql | Production 3-step zero-downtime SQL migration template. | |
| Template | templates/drizzle_schema_template.ts | Production Drizzle ORM schema with relations, indexes, and timestamps. | |
| Utility | scripts/verify_database_hygiene.py | CLI auditor checking migrations for missing FK indexes, hazardous locks, and unapproved deletions. | |
| Utility | scripts/manage_deduplicated_backup.py | Multi-agent content-addressable single-slot backup manager and pre-deletion safety gate. |
2. Zero-Downtime Expand-and-Contract Migrations
PostgreSQL Migration Guardrails:
- Never use `ALTER TABLE ... ADD COLUMN ... DEFAULT <expensive>` without PG 11+ instant metadata defaults.
- Never create indexes synchronously on production tables:
```sql -- ❌ HAZARDOUS: Locks table for writes CREATE INDEX idx_users_email ON users(email);
-- ✅ PRODUCTION: Non-blocking background build CREATE INDEX CONCURRENTLY idx_users_email ON users(email); ```
- Always set lock timeouts before running DDL migrations:
``sql SET lock_timeout = '3s'; SET statement_timeout = '15s'; ``
3. Index Optimization & N+1 Elimination
3.1 Index Types Decision Matrix
- B-tree (Default): Equality (
=), range (<,>,BETWEEN), sorting (ORDER BY). - GIN (Generalized Inverted Index):
JSONBdocument paths, arrays, full-text search (tsvector). - Partial Index: High cardinality sub-queries (e.g.
WHERE status = 'unprocessed'). Saves 90%+ index memory. - Composite Index Order: Equality columns first, range/sort columns second (
(tenant_id, created_at DESC)).
3.2 Eliminating N+1 Query Anti-Patterns
4. Connection Pool Tuning
Unbounded connections exhaust server RAM and trigger remaining connection slots are reserved for non-replication superuser connections.
Mathematical Pool Sizing Formula:
$$\text{Pool Size} = (\text{CPU Cores} \times 2) + \text{Disk Spindle Count}$$ For a 4-core cloud instance, pool size should be 8 to 12 connections per worker, never hundreds.
Safe Session Timeouts:
statement_timeout = '5000ms'(kill runaway queries before consuming all worker threads)idle_in_transaction_session_timeout = '10000ms'(reclaim idle locked connections)
5. Deduplicated Single-Slot Backups & Sensitive Deletion Gate
When one or more agents work on PostgreSQL, SQLite, Cloud SQL, or serverless stores simultaneously, they MUST prevent both unbacked destructive mutations and spammy backup duplication (*.bak.1, *.bak.2, backup_copy.sql):
- Idempotent Content-Hashed Single-Slot Backup:
- Before running schema migrations or bulk updates, execute
manage_deduplicated_backup.pyto compute the SHA-256 digest of the database or schema state and record it in.backups/backup_manifest.json. - If the state SHA-256 has not changed since the last snapshot (or a concurrent subagent already backed up the current state), reuse the canonical slot (
SKIPPED_DUPLICATE_HASH) rather than creating redundant backup files.
- Sensitive Data & Destructive Operation Gate (Tell the User First):
- Before executing
DROP TABLE,DROP COLUMN,TRUNCATE, or unconditionedDELETE, the agent MUST halt and notify the user first with the target resource, sensitivity tier, row/file impact scope, and verified canonical backup SHA-256 hash. - Prefer soft-deletes (
deleted_at TIMESTAMPTZ NULL) over hard deletions. - Once the user explicitly approves a permanent deletion, annotate the SQL script with
-- @user-approved-deletionand-- @verified-backup-sha256: <digest>.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/database/SKILL.md
Popularity
- Repository stars
- 13
- Repository forks
- 2
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/darknecrocities/skillbuilder/database)