Design Data Model
Propose the database design for a feature and write it up as a short
data-model.md. The data model comes before the PRD: it settles what we
store and how it relates, so the PRD can build on it.
Your job is to recommend, not just record. Suggest the model you'd build — the simplest one that is scalable, consistent with the existing schema, and fits the queries the feature needs — and explain the big choices briefly.
When to Apply
- User asks to design a data model, schema, tables, or ER diagram for a feature
- User asks how to store something new, or to restructure existing tables
- User runs
/design-data-model
References
references/project-knowledge.md— how to load, and when to create, the project knowledge files in.agents/knowledge/. Read first.references/modeling-guide.md— conventions to find in the codebase, defaults, the design checks to run on every table, and thedata-model.mdknowledge file template. Read before drafting.references/data-model-template.md— the output template. Read before writing.
Related Skills (optional)
This skill is the first step of a planning flow: design-data-model →
create-prd → plan-phases → plan-tickets. The other skills help but are
never required.
When you suggest another step, check whether that skill is available (in
your skills list, or in the project's or user's skills folder, e.g.
.agents/skills/ or .claude/skills/). If it is, offer to run it. If not,
say it's optional and give the install command:
npx skills add MdTehseenKhan/planning-skills --skill <name>. Never install a skill
without the user's OK, and never stop because one is missing.
Workflow
Copy and track:
- [ ] Load project knowledge
- [ ] Understand the feature
- [ ] Study the existing schema
- [ ] Draft the model
- [ ] Ask the questions that change the schema
- [ ] Save project knowledge, if missing
- [ ] Ask where to save
- [ ] Write data-model.md and self-check
- [ ] Report
1. Load project knowledge
Follow references/project-knowledge.md. This skill needs the topics Save
location, Tenancy and scope, Compliance, Codebase map, and Data model
conventions. Note which ones the knowledge files, AGENTS.md, and
CLAUDE.md already answer; you'll fill only the rest.
2. Understand the feature
Accept a description, brief, ticket, mockup, notes, or a link (an issue tracker, a wiki, a shared doc — read it with the matching connector tool). If the user gave nothing to work from, ask for a short description of what users will be able to do.
Pull out: the things being stored (nouns), who owns them (tenant, team, user, or a parent record), how they relate, how they change over time, and what screens or reports will read them.
3. Study the existing schema
Before designing anything, look at what exists. This is what keeps the model consistent with the codebase.
- If
.agents/knowledge/data-model.mdexists (orAGENTS.md/CLAUDE.mddescribe the schema conventions), use it as the starting point: it says where the schema lives and which conventions to follow. Verify it against the tables you read. - Otherwise find where the schema lives (ORM model files, schema definitions, or SQL migrations) and which tool generates migrations.
- Search the schema for tables in the same domain and for tables the feature will link to. Read the closest ones fully, including constraints, indexes, and access policies.
- Check existing enums and value sets you can reuse.
- Note the conventions the nearby tables follow for each area in the
Codebase Conventions table of
references/modeling-guide.md. Fill gaps with its defaults. If there is no knowledge file, these notes become one in step 6. - If the feature touches a shared, config-driven engine (forms, workflows, custom fields), read its docs or code first.
Keep it focused: the tables you'll reuse, change, or reference. Don't audit the whole schema.
4. Draft the model
Draft the full model before asking anything. Run every table through the
design checks in references/modeling-guide.md.
- Prefer changing or extending an existing table over adding a new one.
- Start with the smallest set of tables that supports the feature; note likely future needs in Decisions instead of building them now.
- Write down what one row of each table represents in one sentence.
- Map the main reads to indexes and the "one per X" rules to unique constraints.
- Decide access control and migration/backfill needs for each table.
- List every point where the answer depends on product intent.
5. Ask the questions that change the schema
First, if step 1 left project knowledge topics that the code couldn't
answer, ask that one short round as references/project-knowledge.md
describes. Then ask only what would change tables, columns, keys, or
constraints. Typical ones:
- Cardinality: can an X have more than one Y? Can a Y belong to several X?
- Scope: is this global, tenant, team, user, or record level? Shared across tenants?
- Lifecycle: does it change after being final (signed/completed/published)? Do we need history or versions?
- Configurability: fixed values, or will tenants customize them?
- Existing data: is there production data that needs a backfill?
- Volume and reads: how many rows per user or tenant, and what lists or reports read them?
Rules:
- Answer from the code and project knowledge first; never ask what they already tell you.
- Batch questions; at most 4 per round and 2 rounds. Use
AskUserQuestionwhen available, with your recommended option first and a one-line tradeoff for each option. - With the first round, share a short outline of the proposed tables (name + one sentence each) so the user can correct the shape early.
- If something is still open after two rounds, pick the safer default, say so in Decisions, and move on.
6. Save project knowledge, if missing
Skip this step when every topic from step 1 was already answered.
Otherwise write only the unanswered topics, as references/project-knowledge.md
describes:
- Data model conventions →
.agents/knowledge/data-model.md, using the Knowledge File template inreferences/modeling-guide.mdand the conventions you recorded in step 3. - Other topics →
.agents/knowledge/project.md.
Record project-wide conventions only, never anything specific to this feature.
7. Ask where to save
Always ask where to save the output. Suggest the save location from project
knowledge when there is one. Otherwise suggest data-model.md in the
feature's existing folder (next to its brief or PRD) or the project's usual
place for specs, and offer docs/<feature-slug>/data-model.md. Don't
overwrite an existing file without confirming.
8. Write data-model.md
Fill references/data-model-template.md. Writing rules:
- Concise. Hierarchy and diagram first, then one compact block per table. Delete sections that don't apply.
- Hierarchy always; mark tables
(NEW)or(CHANGED: ...). Add the Mermaid ER diagram when relationships aren't a simple tree (join tables, multiple parents, self-references, links to existing tables). - Lifecycle (Mermaid
stateDiagram-v2, right after the ER diagram; one diagram per status column) when a table has a status column with more than two states, or rows move between states through jobs, retries, or user actions. Show every state, the event on each arrow, terminal states, and how related tables' statuses move together. Mark new transitions (for example★) and note which layer owns them. - Naming follows the codebase: table and column names exactly as they appear in the schema files.
- Two tables per table: a columns table, then a separate constraints
table listing every unique, partial unique, composite FK, index, and check
by its full name (
<table>_<purpose>_unique|_idx|_fk|_check), with kind, definition, and purpose. Simple single-column FKs stay in the columns table. - Notes under a table are one line each: rules not obvious from the columns or constraints. Say which layer owns rules the DB doesn't enforce.
- JSON types nest at most one level: group related values under one key
and keep the values flat (
total.inputTokens, nottotal.tokens.input). - Decisions at the top hold the reasoning for big choices — one line each. Don't repeat reasoning per table.
- Changes to existing tables list only what is added, changed, or removed, in the same two tables (columns, then constraints) with a Change column.
- No implementation code beyond JSON type shapes.
Self-check before finishing:
- Every stored concept from the feature maps to a table or column
- Each table's one-row sentence is clear and the table does one job
- Existing tables and enums were reused where they fit
- The model follows the project knowledge conventions, or says in Decisions why not
- Every main read has an index; every "one per X" rule has a unique constraint
- Ownership columns (tenant and owner keys) are present and drift is prevented
- Every table has an access rule; backfill is covered for existing data
- Nothing instance-specific was added to a shared, config-driven engine's tables
- Every constraint and index is named in a constraints table, not in the columns table
- JSON types nest at most one level
- Every multi-state status column has a Lifecycle diagram listing all states and transitions
- Matches the template; no empty sections
9. Report
Give the saved path, the new and changed tables with one line each, the key
decisions, and any assumptions made in place of an answer. If you created or
extended a knowledge file, name it and suggest committing it; name any stale
AGENTS.md / CLAUDE.md lines you found. Suggest create-prd as the next
step, following Related Skills.