database-schema-design
Skill2 starsChanged 4 months agoMITView on GitHub
Design database schemas (MongoDB document models or Postgres/relational schemas via Prisma/Drizzle) with correct normalization, indexing, and relationship modeling. Use whenever the user is modeling data, designing a schema, choosing between embedding vs referencing in MongoDB, adding indexes, or asking "how should I structure this data".
6 other projects use a version of this.
Adopted by
Most recently taken up by
- anuragsarkar97/skillstheir own version, first seen Nov 8, 2026
- reddygopalkrishna/developer-agent-skillstheir own version, first seen Nov 8, 2026
- WST2002/claude-code-skillstheir own version, first seen Oct 17, 2026
- timwukp/agent-skills-best-practicetheir own version, first seen Sep 16, 2026
- yueheng-rgb/codex-factorytheir own version, first seen Sep 15, 2026
- agent-packs/registrytheir own version, first seen Jun 15, 2026
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 6
- yueheng-rgb/codex-factory★ 100same name
- timwukp/agent-skills-best-practice★ 10same name
- reddygopalkrishna/developer-agent-skills★ 8same name
- WST2002/claude-code-skills★ 4same name
- agent-packs/registry★ 0same name
- anuragsarkar97/skills★ 0same name
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 repository22 other files it gives its agents.
- accessibility-a11ySkill
- design-system-tailwindSkill
- motion-design-toolkitSkill
- nextjs-architectureSkill
- react-component-engineeringSkill
- react-three-fiber-3dSkill
- responsive-mobile-firstSkill
- auth-authorizationSkill
- form-validation-error-handlingSkill
- mern-stack-architectureSkill
- rest-api-integrationSkill
- state-managementSkill
- landing-page-conversionSkill
- payment-gateway-integrationSkill
- saas-dashboard-adminSkill
- startup-mvp-developmentSkill
- ux-research-flow-designSkill
- visual-design-languageSkill
- ai-assisted-frontend-workflowSkill
- deployment-vercel-productionSkill
- performance-seo-optimizationSkill
- project-architecture-clean-codeSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 3 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
Embed: when data is always read/written together, has a bounded size, and doesn't need independent querying (e.g.
- Distinctive: line 12
Avoid unbounded array growth inside a single document (MongoDB's 16MB doc limit) — if a collection can grow indefinitely (e.g.
- Distinctive: line 19
Don't over-index — every index costs write performance and storage.
- Very specific: line 20
Use explain()/EXPLAIN ANALYZE to verify a slow query is actually hitting the index you expect before declaring it optimized.
- Distinctive: line 47
Every schema change ships as a tracked migration (Prisma Migrate, or a versioned migration script for Mongoose) — never hand-edit …
“Common” is measured: kept by at least 6 in 10 of the 5 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 Schema Design Skill
Choose the right data model for the engine — don't force one paradigm onto the other
MongoDB (document): model around access patterns, not normalization. Ask "what do I read together most often?" before "what is technically non-redundant?"
- Embed when data is always read/written together, has a bounded size, and doesn't need independent querying (e.g.
order.shippingAddress,post.commentsif comment volume is small and bounded). - Reference (separate collection + ObjectId) when data is large/unbounded (thousands of comments), shared across many parents, or needs independent access/updates (e.g.
user,product). - Avoid unbounded array growth inside a single document (MongoDB's 16MB doc limit) — if a collection can grow indefinitely (e.g. all-time order history on a user doc), reference it instead.
Postgres/relational (Prisma/Drizzle): normalize by default (3NF), denormalize deliberately only for measured read-performance needs (e.g. a materialized view or a cached count column), and document why when you do.
Indexing rules
- Index every foreign key / reference field used in
WHERE/$matchqueries. - Compound indexes: order fields by (equality filters first, then range/sort fields) — e.g.
{ orgId: 1, createdAt: -1 }for "latest items in this org." - Don't over-index — every index costs write performance and storage; add indexes based on actual query patterns, not speculatively.
- Use
explain()/EXPLAIN ANALYZEto verify a slow query is actually hitting the index you expect before declaring it optimized.
Example: Prisma relational schema
model User {
id String @id @default(cuid())
email String @unique
orgId String
org Organization @relation(fields: [orgId], references: [id])
role Role @default(MEMBER)
createdAt DateTime @default(now())
@@index([orgId])
}Example: Mongoose schema with embedding vs referencing
const OrderSchema = new Schema({
userId: { type: Schema.Types.ObjectId, ref: 'User', required: true, index: true },
shippingAddress: { line1: String, city: String, zip: String }, // embedded: always read with the order
items: [{ productId: { type: Schema.Types.ObjectId, ref: 'Product' }, qty: Number, price: Number }], // referenced product, embedded line-item snapshot
createdAt: { type: Date, default: Date.now, index: true },
});Note: price is captured on the order at time of purchase (a snapshot), not just referenced from Product — product prices change, but historical orders shouldn't.
Migration & versioning discipline
- Every schema change ships as a tracked migration (Prisma Migrate, or a versioned migration script for Mongoose) — never hand-edit production schema.
- For MongoDB schema evolution, add a
schemaVersionfield on documents that need staged migration, and write a backfill script rather than assuming all documents match the latest shape.
Anti-patterns to flag
- Unbounded arrays embedded in a MongoDB document (comments, logs, order history)
- Missing index on a field used in every list-page query, causing full collection scans
- Referencing
Product.pricelive in historical orders instead of snapshotting it - Denormalizing in Postgres without a documented reason and a plan to keep it in sync
Example prompt this skill should trigger on
"Design the database schema for a multi-tenant SaaS with users, organizations, and projects."
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.

