database-design
Skill3 starsChanged 7 months agoMITView on GitHub
Use when designing a new schema, writing a migration, adding or auditing indexes, reviewing query performance, choosing between hard delete and soft delete, or establishing database conventions for a project.
- Deletes or force-pushes
42 other projects use a version of this.
Adopted by
Most recently taken up by
- vekzz-dev/opencode-skillstheir own version, first seen Oct 3, 2026
- hemapriyan-rk/claude-rigor-skillstheir own version, first seen Sep 26, 2026
- ZeroTokenClaw/agents-skillstheir own version, first seen Sep 21, 2026
- KbWen/agentic-ostheir own version, first seen Sep 10, 2026
- RealDougEubanks/ClaudeMarketplacetheir own version, first seen Sep 10, 2026
- VoDaiLocz/kilo-kit-mcptheir own version, first seen Aug 21, 2026
Used with
Projects with it also use intelligent-routing, i18n-localization and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
tiendatworkSkillintelligent-routing
Automatic agent selection and intelligent task routing. Analyzes user requests and automatically selects the best specialist agent(s) without requiring explicit user mentions.
Also in 3 projects that use this
xfstudioSkilli18n-localization
Internationalization and localization patterns. Detecting hardcoded strings, managing translations, locale files, RTL support.
Also in 5 projects that use this
xfstudioSkillbehavioral-modes
AI operational modes (brainstorm, implement, debug, review, teach, ship, orchestrate). Use to adapt behavior based on task type.
Also in 3 projects that use this
GenerativeAgentsSkillarchitecture-design
アーキテクチャ設計書を作成するための詳細ガイドとテンプレート。アーキテクチャ設計時にのみ使用。
Also in 8 projects that use this
- +8 more from xfstudio
Other versions42 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 42
- CloudAI-X/claude-workflow-v2★ 1.4ksame name
- MoizIbnYousaf/ai-agent-skills★ 1.1ksame name
- KbWen/agentic-os★ 206same name
- thiientv/godmode★ 96same name
- KbWen/agent-virtual-office★ 35same name
- VoDaiLocz/kilo-kit-mcp★ 27same name
- krzysztofsurdy/code-virtuoso★ 22same name
- DauQuangThanh/hanoi-rainbow★ 17same name
- ishandutta2007/Awesome-Claude-Skills★ 15same name
- svngoku/coding-agents-skills★ 11same name
32 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository43 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- accessibilitySkill
- api-designSkill
- architecture-and-contractsSkill
- brand-and-identitySkill
- code-review-and-qualitySkill
- competitive-analysisSkill
- component-librarySkill
- cross-validationSkill
- data-visualizationSkill
- debugging-and-recoverySkill
- demo-narrativeSkill
- design-systemSkill
- documentation-hygieneSkill
- error-handling-and-resilienceSkill
- feedbackSkill
- forge-migrateSkill
- forge-syncSkill
- git-workflowSkill
- gtm-strategySkill
- idea-grillerSkill
- incident-response-and-postmortemsSkill
- incremental-implementationSkill
- interaction-patternsSkill
- observabilitySkill
- page-compositionSkill
- parallel-execution-strategySkill
- performance-and-cost-optimizationSkill
- planning-and-task-breakdownSkill
- redaction-and-cleanupSkill
- refactoring-and-tech-debtSkill
- scalability-analysisSkill
- security-and-complianceSkill
- seed-data-and-fixturesSkill
- shipping-and-launchSkill
- spec-driven-developmentSkill
- tddSkill
- testing-strategySkill
- triage-issueSkill
- using-forge-skillsSkill
- visual-polishSkill
- writing-skillsSkill
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 3 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 41 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 53
Write these to .forge/database-design.md:
- Very specific: line 64
Run a check: every FK has an index?
- Very specific: line 69
Reversibility: every migration has an explicit down.
- Distinctive: line 72
Expand-contract pattern: add new column → backfill → switch reads → drop old column over multiple deploys.
- Very specific: line 78
Every hot-path query has been EXPLAINed (Postgres) or EXPLAIN ANALYZEd
- Distinctive: line 79
No sequential scan on a table >100k rows
- Distinctive: line 80
No N+1 — verify with query logs in a test that simulates the loop
- Very specific: line 92
Every business table has tenant_id and a Row-Level Security policy
“Common” is measured: kept by at least 6 in 10 of the 41 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Database Design
Overview
Define the project's schema conventions and migration safety policy before migrations land in production. Outputs .forge/database-design.md (naming, FK rules, audit columns, soft-delete policy, index strategy, partition strategy, RLS/tenant-scoping rules) and .forge/migrations-policy.md (reversibility, idempotency, locking-aware patterns, the query-review checklist). Consumed by architecture-and-contracts and incremental-implementation.
When to Use
- A new project starts and the schema is being designed
- A migration is being written that touches a table >1M rows
- An ORM is generating N+1 queries in a hot path
- An audit reveals tables with no FK constraints or missing indexes
- The team is debating soft delete vs hard delete and there's no policy
- A production query is timing out and there's no EXPLAIN process
When NOT to Use
- Adding a column to a tiny dev-only table where conventions already apply
- Schema-less stores (Mongo, DynamoDB) — see
architecture-and-contractsdata-model section instead - A migration on an existing project that has documented conventions and the change is local
Common Rationalizations
| Thought | Reality |
| "We can add indexes later" | Missing indexes in production cause outages, not slowdowns. A full table scan on a 50M-row table locks the DB. |
| "Soft delete is always better" | Soft delete without a cleanup job becomes data hoarding. GDPR forces real deletion eventually. |
| "ORMs handle it" | ORMs generate N+1 queries by default. Lazy loading + a loop = production incident. |
| "One big migration is fine" | Irreversible migrations are deployment landmines. Forward-only with a long expand-contract window is the safe path. |
| "We don't need FK constraints, the app enforces it" | The app has bugs. The DB doesn't. FK constraints are the last line of defense against orphan rows. |
| "Let's just denormalize for speed" | Denormalization without a sync job creates two sources of truth that diverge. |
Red Flags
ALTER TABLE large_table ADD COLUMN ... NOT NULLwith no locking review- Foreign key columns without indexes
- A migration that drops or renames a column without a deprecation window
- Soft delete columns (
deleted_at) with no cleanup or RLS policy - ORM
findAll()followed by.map(item => item.related)(N+1) - A query that scans rows without an EXPLAIN run
- No
created_at/updated_ataudit columns - Multi-tenant tables without RLS or
tenant_idindexes
Core Process
Step 1: Define naming conventions
Write these to .forge/database-design.md:
- Tables:
snake_case, plural (users,task_assignments) - Columns:
snake_case, no abbreviations (created_atnotcr_at) - Primary keys:
id(UUIDv7 preferred — sortable, no hot shards) - Foreign keys:
<table_singular>_id(user_id,task_id) - Indexes:
idx_<table>_<columns> - Constraints:
chk_<table>_<rule>,unq_<table>_<columns> - Audit columns required on every business table:
created_at,updated_at(timestamptz, server-set)
Step 2: Audit existing schema (if applicable)
Run a check: every FK has an index? every business table has audit columns? every soft-delete table has cleanup? Record violations in .forge/database-design.md with an owner and a deadline.
Step 3: Set migration guardrails
In .forge/migrations-policy.md:
- Reversibility: every migration has an explicit
down. Forward-only migrations require an ADR. - Idempotency:
CREATE TABLE IF NOT EXISTS,ADD COLUMN IF NOT EXISTS,CREATE INDEX IF NOT EXISTS. - Locking-aware:
CREATE INDEX CONCURRENTLYon Postgres. Online schema change (gh-ost, pt-osc) for MySQL on large tables. NeverALTER TABLEwithACCESS EXCLUSIVE LOCKduring business hours. - Expand-contract pattern: add new column → backfill → switch reads → drop old column over multiple deploys.
- Backup before destructive: any
DROP COLUMN,DROP TABLE,TRUNCATE, or destructiveUPDATErequires a snapshot reference in the PR.
Step 4: Write the query-review checklist
Append to .forge/database-design.md:
- Every hot-path query has been EXPLAINed (Postgres) or
EXPLAIN ANALYZEd - No sequential scan on a table >100k rows
- No N+1 — verify with query logs in a test that simulates the loop
- Index used for every JOIN and WHERE condition
- LIMIT used on any user-facing list query
- Pagination uses cursor (not OFFSET) for large tables
Step 5: Identify partition candidates
Tables likely to exceed 100M rows (events, logs, audit, time-series): plan partitioning before they grow. Document the partition key (usually created_at range or tenant_id hash) and the retention/cleanup job.
Step 6: Document RLS / tenant-scoping rules
For multi-tenant systems:
- Every business table has
tenant_idand a Row-Level Security policy - Application-side defense (every query filters by
tenant_id) + DB-side defense (RLS) — both, not either-or - The contract from
architecture-and-contractsMUST specify which tables are tenant-scoped
Step 7: Headers
Prepend a forge:meta header on both .forge/database-design.md and .forge/migrations-policy.md (co-output — both share the same depends_on + generated_from): generated_by: database-design, generated_at: <ISO 8601 UTC with Z>, depends_on: [.forge/architecture.md] — paths only, never hashes, generated_from: {.forge/architecture.md: <upstream content_hash AT generation time>}, content_hash: <sha256 first 8 of THIS file's body> (each file computes its own). See forge-dependency-graph.
Verification
.forge/database-design.mdwritten with naming conventions, soft-delete policy, partition strategy.forge/migrations-policy.mdwritten with reversibility, idempotency, locking-aware rules- Every migration in the codebase is idempotent (
IF NOT EXISTSor equivalent) - Every FK has an index (verified via schema query)
- Every business table has
created_atandupdated_at - Every hot-path query has an EXPLAIN attached to the PR (or linked in
.forge/database-design.md) - No migration drops user-visible data without an ADR
- Multi-tenant tables have RLS policies and
tenant_idindexes - N+1 queries are gone from the codebase (verified by query-count test in CI)
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.

