Install
$ agentstack add skill-kreek-consult-database ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
About
Database
Iron Law
PROTECT PRODUCTION DATA FIRST: PROVE ROLLOUT, LOCKING, AND RECOVERY BEFORE CHANGE.
When to Use
- Schema design, migrations, indexes, query plans, isolation levels,
connection pools, soft delete, N+1 fixes, online DDL, transactional outbox/CDC, or production data changes.
When NOT to Use
- API contract design; use
api. - Rollout sequencing outside the database; pair with
release. - Cache freshness and invalidation; use
performance.
Core Ideas
- Schema, migration, and destructive data changes are the user's call.
Route schema and migration changes through contract-first; data deletion and non-reversible backfills need the same approval for data safety. An approving design or RFC is not that approval; the concrete schema, migration, or destructive change gets its own sign-off before landing.
- Use the project's existing database unless the task is choosing a store.
For greenfield defaults and store-selection caveats, use architecture.
- Expand, migrate, verify, switch, then contract in separate
deployable steps.
- Review SQL and lock behavior, not just ORM code.
- Backfills are batched, resumable, observable, and reversible.
- Constraints enforce invariants. Every uniqueness invariant needs a DB-level
UNIQUE, EXCLUDE, composite, or partial equivalent. Application-layer checks race under concurrency.
- Indexes and plans follow real access paths. New foreign keys and known
WHERE, JOIN, or ORDER BY predicates need supporting indexes in the same migration, or a stated reason they do not; query changes need EXPLAIN/ANALYZE plans on production-shaped data.
- Isolation level is a design decision; retries are part of
serializable correctness.
- State changes and durable publication need atomicity through
transactional outbox, CDC, or an equivalent handoff when the two cannot silently diverge.
- Data recovery is part of the change: backup/PITR must cover the
blast radius.
Workflow
- Classify the change as schema, data, query, index, constraint,
transaction, or operational tuning. Identify table size, write rate, lock risk, rollback path, and deploy order.
- Review migration files directly for destructive operations and lock
behavior. Capture EXPLAIN/ANALYZE for important query changes on representative data.
- Split unsafe changes into expand-contract phases. Document
verification and rollback in the PR or deploy note.
Verification
- [ ] Migration SQL was reviewed for destructive changes and locking.
- [ ] Destructive or tightening changes are split across expand-contract
phases.
- [ ] Backfills are batched and resumable; each batch holds locks
briefly.
- [ ] Every uniqueness invariant in the change is enforced by a DB constraint
or equivalent engine-specific mechanism, not application-layer logic.
- [ ] New FK columns and known query predicates (
WHERE,JOIN,ORDER BY)
have supporting indexes in the same migration, or the omission is explicitly justified.
- [ ] Index/constraint creation uses the online mechanism for the
target database.
- [ ] Engine-specific DDL uses
references/online-ddl.mdand was verified
against the target engine before claiming done. SQLite passing is not proof of Postgres behavior.
- [ ] Important query changes include representative EXPLAIN/ANALYZE
evidence.
- [ ] Isolation level and retry behavior are explicit for transactional
changes.
- [ ] State changes and event/job publication cannot diverge silently
when the workflow depends on both.
- [ ] Rollback and backup/PITR coverage are documented.
- [ ] Schema and migration changes were routed through
contract-first,
and destructive data operations (deletion, non-reversible backfills) had explicit user approval before landing.
- [ ] An approving design or RFC did not stand in for sign-off on the concrete
schema, migration, or destructive data change. Each got explicit approval before landing.
Tripwires
Use these when the shortcut thought appears:
- Use the target engine's online mechanism or document why production size and
write rate cannot matter.
- Measure lock behavior on representative load or assume the worst case.
- Ship the backfill plan now or leave the schema expand-only.
- Decide soft-delete lifecycle once and enforce reads, indexes, and schema
around it.
- Observe a full traffic cycle before dropping an index.
- Enforce correctness invariants with DB constraints, not application checks.
- Add supporting indexes in the same migration when access paths are known.
- Check target-engine semantics for partial, expression, deferrable, exclusion,
and specialized indexes before relying on them.
- Load
securitybefore adding password, token, API key, MFA, recovery-code, or
sensitive-PII storage.
Handoffs
contract-first: schema, migration, or stored-shape approval before
implementation locks the change.
release: deploy ordering, rollback rehearsal, feature flags.performance: measured query latency or throughput change.observability: migration and query dashboards/alerts.async-systems: stream or worker consumers after durable handoff.security: credentials, secrets, tokens, MFA factors, sensitive PII.
References
references/online-ddl.md: online migration patterns.references/explain-and-isolation.md: EXPLAIN and isolation notes.
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: kreek
- Source: kreek/consult
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.