Database Administration

Design database schemas, write migrations, and optimize queries. Use this skill when database work is requested, including schema design, indexing, and data modeling.

5 stars

Best use case

Database Administration is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Design database schemas, write migrations, and optimize queries. Use this skill when database work is requested, including schema design, indexing, and data modeling.

Teams using Database Administration should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/database-admin/SKILL.md --create-dirs "https://raw.githubusercontent.com/BasharAmso/Bashi/main/.claude/skills/database-admin/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/database-admin/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How Database Administration Compares

Feature / AgentDatabase AdministrationStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Design database schemas, write migrations, and optimize queries. Use this skill when database work is requested, including schema design, indexing, and data modeling.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Skill: Database Administration

## Metadata

| Field | Value |
|-------|-------|
| **Skill ID** | SKL-0008 |
| **Version** | 1.0 |
| **Owner** | builder |
| **Inputs** | Task description, DECISIONS.md, existing migration/model files |
| **Outputs** | Migration files, schema changes, seed files, STATE.md updated |
| **Triggers** | `DATABASE_TASK_REQUESTED` |

---

## Purpose

Design schemas, write migrations, optimize queries, and ensure data integrity. Every schema change is a migration. Every migration is reversible.

---

## Procedure

1. **Read DECISIONS.md** — confirm database engine, ORM, migration tool, hosting.
   - Default: PostgreSQL + Prisma for Node.js projects.
2. **Design schema before writing migrations:**
   - List entities and relationships (1:N, M:N, self-referential)
   - Design indexes for read patterns
   - Soft-delete for critical records; plan archiving for unbounded data
3. **Naming conventions (PostgreSQL):**
   - Tables: `snake_case`, plural (`users`, `subscription_events`)
   - Columns: `snake_case` (`created_at`, `stripe_customer_id`)
   - PKs: `id` (UUID preferred); FKs: `[table_singular]_id`
   - Booleans: `is_[state]` / `has_[thing]`; always include `created_at`, `updated_at`
4. **Write migrations (never edit schema directly):**
   - Every migration has UP and DOWN sections — no exceptions
   - Never rename columns directly — add new, migrate data, drop old
   - Never add NOT NULL without DEFAULT to existing tables
   - Large tables (>1M rows): use `CREATE INDEX CONCURRENTLY`
5. **Indexing strategy:**
   - Always index: FKs, WHERE clause columns, ORDER BY columns, UNIQUE constraints
   - Use composite indexes when queries filter on multiple columns
   - Use partial indexes when queries filter on a subset of rows
6. **Query optimization:** Use `EXPLAIN ANALYZE` to diagnose slow queries. Fix N+1 with eager loading/JOINs.
7. **Seed data:** Create seed files for dev/test environments. Never seed production.
8. **Backup verification:** Document backup config in `docs/DATABASE.md` (provider, frequency, retention, restore procedure).
9. **Update STATE.md.**

---

## Constraints

- Never modifies schema directly — always through migrations
- Never writes a migration without a DOWN section
- Never adds NOT NULL without DEFAULT to existing tables
- Never runs blocking index creation on large tables
- Never seeds production with test data
- Always reads DECISIONS.md before writing database code

---

## Primary Agent

builder

---

## Definition of Done

- [ ] Database engine and ORM confirmed from DECISIONS.md
- [ ] Schema designed against query patterns before migration
- [ ] Migration includes UP and DOWN sections
- [ ] Foreign keys indexed
- [ ] Frequent WHERE/ORDER BY columns indexed
- [ ] Large table migrations use CONCURRENTLY
- [ ] Seed file created for dev environment
- [ ] Backup config documented
- [ ] STATE.md updated

## Output Contract

| Field | Value |
|-------|-------|
| **Artifacts** | Migration files, schema changes, index definitions, seed files, `docs/DATABASE.md` |
| **State Update** | `.claude/project/STATE.md` — mark task complete, log files modified |
| **Decision Log** | `.claude/project/knowledge/DECISIONS.md` — database engine, ORM, migration tool |
| **Handoff Event** | `TASK_COMPLETED` (database work complete) |

Related Skills

Supply Chain Audit

5
from BasharAmso/Bashi

Audit the dependency supply chain for security risks beyond what `npm audit` or `pip audit` catches. Analyzes dependency health, maintainer trust signals, typosquatting risk, and transitive dependency exposure.

SEO Audit

5
from BasharAmso/Bashi

Audit web pages for search engine optimization: meta tags, heading hierarchy, structured data, image optimization, mobile-friendliness, and content quality. Complements SKL-0013 (Growth & Distribution) by validating what was built.

Pitch Deck

5
from BasharAmso/Bashi

Create a structured pitch deck outline for investors, stakeholders, or partners. Covers problem, solution, market, traction, team, and ask. Natural output after PRD + Problem Stress Test validation.

Launch Checklist

5
from BasharAmso/Bashi

Pre-launch validation covering everything deployment (SKL-0021) doesn't: analytics, error tracking, social meta, legal pages, email setup, DNS, SSL, and go-live readiness. Produces a launch readiness report with pass/fail checklist. Use this skill before going live on any project.

Insecure Defaults Detection

5
from BasharAmso/Bashi

Detect insecure default configurations, hardcoded credentials, fail-open security patterns, and dangerous default values in application code and configuration files. Complements SKL-0015 (Security Audit) by focusing on configuration-level vulnerabilities that dependency scanners miss.

Differential Security Review

5
from BasharAmso/Bashi

Security-focused review of code changes using git diff analysis. Identifies security implications of recent modifications — new attack surfaces, removed protections, changed auth logic, and risky refactors. Complements SKL-0016 (Code Review) with a security lens on diffs.

Copywriting

5
from BasharAmso/Bashi

Write conversion-focused copy using proven frameworks (AIDA, PAS, BAB). Produces headlines, CTAs, landing page copy, email sequences, and micro-copy. Ensures copy matches brand voice and target audience.

Competitor Analysis

5
from BasharAmso/Bashi

Structured competitor research: features, pricing, positioning, gaps, and differentiation strategy. Feeds into PRD Writing (SKL-0004) and Problem Stress Test (SKL-0027) with better market context.

UX Design

5
from BasharAmso/Bashi

Design user experiences including wireframes, flows, and interaction patterns. Use this skill when UX design work is requested, including onboarding flows and interface layouts.

User Acceptance Testing

5
from BasharAmso/Bashi

Structured QA testing with four modes: diff-aware (auto-scoped to branch changes), full (systematic exploration), quick (30-second smoke test), and regression (compare against baseline). Produces health score, structured reports, and actionable bug lists. Use this skill when UAT is requested or a feature is ready for acceptance testing.

Token Audit

5
from BasharAmso/Bashi

Audit the current project for token waste patterns. Produces a Token Health Report with scored findings and actionable fixes. Use this skill when token usage feels high, sessions are hitting limits, or before optimizing costs.

Test Writing

5
from BasharAmso/Bashi

Write automated tests for existing or new functionality. Use this skill when tests are requested, including unit tests, integration tests, and end-to-end tests.