standards-database
Skill0 starsChanged 4 months agoMITView on GitHub
Use this skill when designing or reviewing database schemas, migrations, indexes, queries, transactions, constraints, backfills, data retention, or data integrity changes, even for a single query or column addition. Use role-data-engineer for analytics pipelines, warehouse models, and event stream design.
In this repository34 other files it gives its agents.
- AGENTS.mdAGENTS.md
- mcpSkill
- pattern-orchestration-complexSkill
- pattern-task-breakdownSkill
- role-architectSkill
- role-code-reviewSkill
- role-data-engineerSkill
- role-developerSkill
- role-orchestratorSkill
- role-product-engineerSkill
- role-qa-engineerSkill
- role-security-auditorSkill
- role-site-reliability-engineerSkill
- role-technical-writerSkill
- standards-analysisSkill
- standards-api-designSkill
- standards-codeSkill
- standards-documentationSkill
- standards-go-concurrencySkill
- standards-go-performanceSkill
- standards-goSkill
- standards-go-testingSkill
- standards-markdownSkill
- standards-observabilitySkill
- standards-pulumi-typescriptSkill
- standards-pythonSkill
- standards-securitySkill
- standards-shellSkill
- standards-skill-authoringSkill
- standards-testingSkill
- standards-typescriptSkill
- tool-storeSkill
- workflow-debuggingSkill
- workflow-pi-extensionSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
16 rules. About 0 are common, 15 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈15
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Golden Rule: Prefer explicit database integrity over application-only assumptions
- Distinctive: line 16
Add constraints where the database can enforce truth
- Distinctive: line 44
Put the invariant in the database when the database can express it:
- Distinctive: line 58
Prefer expand and contract for live systems.
- Distinctive: line 60
Expand: Add the new nullable column, table, or index without touching existing code paths.
- Distinctive: line 64
Contract: Remove the old structure in a later, separate change.
- Distinctive: line 66
Do not combine steps to save a deploy.
- Distinctive: line 79
Check selectivity. An index on a low-cardinality column that the planner skips is maintenance cost with no benefit.
- Distinctive: line 80
Verify the index supports the sort and pagination the query uses, not only the filter.
- Distinctive: line 81
Check join cardinality. A join that fans out multiplies rows and quietly changes aggregate results.
- Distinctive: line 82
Avoid N+1 access patterns unless the loop is bounded and the bound is known.
- Very specific: line 83
Look for redundant indexes.
- Distinctive: line 86
Keep them short. A transaction is a lock held over time.
- Distinctive: line 87
Never hold a transaction open across an HTTP call, a queue publish, or any other network operation.
- Distinctive: line 91
Types: Treat time zones, money, and decimal precision as schema concerns.
- Distinctive: line 97
Before finalizing database work:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Database Standards
Provides: Schema and constraint design decisions, expand/contract migration procedure, query and index review criteria, and transaction safety checks.
Quick Reference
Golden Rule: Prefer explicit database integrity over application-only assumptions
Default Stance:
- Model the invariant, not just the current UI
- Add constraints where the database can enforce truth
- Make migrations incremental, observable, and rollback-aware
- Index for known access patterns, not guesses
Never: hold a lock across a network call, run an unbounded backfill on a live table, or ship a destructive migration without an explicit decision
Design Decisions
Settle these before changing persistence:
| Decision | Question to answer |
| Ownership | Source of truth, lifecycle, retention, deletion semantics |
| Shape | Keys, uniqueness, nullability, defaults, timestamps, enums |
| Relationships | Foreign keys, cascade behavior, orphan handling |
| Consistency | Transaction boundaries, isolation needs, concurrency conflicts |
| Access | Expected queries, filters, sort order, cardinality, growth |
| Migration | Deploy order, backfill plan, rollback, verification |
| Privacy | PII classification, encryption, masking, audit needs |
Application code changes weekly; data outlives it. A missing constraint becomes thousands of rows that violate an invariant nobody can now enforce.
Constraints
Put the invariant in the database when the database can express it:
NOT NULLfor fields the domain requires.UNIQUEfor identity claims, including composite keys that express a grain.- Foreign keys with explicit cascade or restrict behavior, chosen deliberately.
CHECKconstraints for bounded values and cross-field rules.- Enum types or check-constrained strings rather than free text for closed sets.
Application-level validation is not a substitute. It runs in one code path; the constraint covers every path, including backfills, admin scripts, and the next service that connects to the same database.
Migration Safety
Prefer expand and contract for live systems. Each step deploys independently and is safe to stop at.
- Expand. Add the new nullable column, table, or index without touching existing code paths.
- Backfill. Populate in bounded batches, or dual-write from the application while old and new shapes coexist.
- Verify. Compare counts, check constraint satisfaction, and confirm application reads return the same results from both shapes.
- Switch. Move reads, then writes, to the new shape.
- Contract. Remove the old structure in a later, separate change.
Do not combine steps to save a deploy. The value of the pattern is that each step is individually reversible.
Avoid:
- Long-held locks on tables that serve live traffic. Adding an index or a
NOT NULLcolumn can lock writes for the duration; check your engine's behavior and use the concurrent variant where available. - Unbounded
UPDATEorDELETEstatements across large tables. - Destructive changes without an explicit decision and a verified backup.
- Migrations that require old and new application code to be incompatible, because that removes the ability to roll back.
Query and Index Review
- Confirm the query matches an indexed access path at the expected data volume, using the engine's query plan rather than inspection.
- Check selectivity. An index on a low-cardinality column that the planner skips is maintenance cost with no benefit.
- Verify the index supports the sort and pagination the query uses, not only the filter.
- Check join cardinality. A join that fans out multiplies rows and quietly changes aggregate results.
- Avoid N+1 access patterns unless the loop is bounded and the bound is known.
- Look for redundant indexes. An index on
(a)is usually unnecessary when(a, b)exists.
Transactions:
- Keep them short. A transaction is a lock held over time.
- Never hold a transaction open across an HTTP call, a queue publish, or any other network operation.
- Choose the isolation level deliberately, and know which anomalies the chosen level allows.
- Handle serialization failures and deadlocks with a bounded retry, and make the operation safe to repeat.
Types: Treat time zones, money, and decimal precision as schema concerns. Store timestamps with time zone, store money in a decimal or integer minor-unit type, and never in a float.
Checklist
Before finalizing database work:
- Constraints protect the required invariants
- The migration runs safely at the target table size, without long locks
- Old and new application code both work against the intermediate schema
- Backfill is bounded, resumable, and verifiable
- Indexes match real read and write paths and do not duplicate existing ones
- Transactions are short and handle concurrency failures with a safe retry
- A rollback or forward-fix plan is written down before the change ships
- Destructive steps are separated into their own later change
- Tests cover constraints, migration behavior, and representative queries
See also
- Load
standards-securityfor PII, tenancy, secrets, and audit requirements. - Load
standards-api-designwhen persistence choices leak into published contracts. - Load
role-site-reliability-engineerfor production migration and rollback risk. - Load
role-data-engineerfor analytics models, pipelines, and large backfills. - Load
standards-testingfor migration, repository, and integration tests.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

