domain-modeling
Step 3 of the pipeline (WORKFLOW.md), before archi and before api-design. Those two ask where
does this plug in and what's the contract. This one asks the question underneath: what is this
thing, and what's true about it. Getting that wrong produces a schema and an API that are both
faithful implementations of a misunderstanding.
When
As soon as the work introduces a new domain concept, or touches one that's showing strain: a status
field that keeps gaining values, a rule reimplemented in three places, a name that means different
things to two teams. Not for a straightforward addition to a concept that's already clear.
Steps
1. Name things the way the business says them
- Use the words the business uses, in code as in conversation. When the business says "quote"
and the code says "draft order", every discussion needs a translation, and translations drift.
- One name, one meaning. If a word means two things depending on the screen, that's two
concepts wearing one name: name them separately. This is the most common finding and the most
often waved away.
- Write down the words you rejected and why. The next person will otherwise reopen the same
debate with no memory of it.
2. Find the rules and decide where they live
- List what must always be true about the concept, in plain sentences ("an order can't be
validated without a customer", "a contract's end date is never before its start"). These are
invariants, and they are the model.
- Decide where each one is enforced, and prefer the narrowest place that can guarantee it: the
type or the schema if it can (a non-nullable column, an enum), otherwise a single point in the
domain code. A rule enforced in the UI only is a suggestion.
- A rule duplicated across layers will diverge. If it must exist in two places (a frontend check
for feedback, a backend check for truth), say which one is authoritative and treat the other as
ergonomics.
3. Model state as states, not as flags
- A concept with a lifecycle has a state, not a pile of independent booleans. Three booleans
describe eight combinations, and usually only four are legal: the other four are bugs waiting for
the right sequence of clicks.
- List the legal transitions, and what triggers each. A status enum with no transition rules
just relocates the problem into whoever writes the update.
- Model the states that exist, including the awkward ones: "awaiting approval", "partially
delivered", "cancelled but invoiced". A model that only covers the clean path pushes reality into
nullable columns and special cases.
4. Draw the boundary
- Say what the concept does not cover. A boundary stated once prevents the slow accumulation
where an entity ends up owning half the domain.
- Check the concept against the existing model (this is where
archi's dedup pass starts): a
"new" concept is often an existing one under a different name, or a state of it.
Output / checkpoint
The vocabulary settled, the invariants listed with the place each is enforced, the states and legal
transitions, and the boundary. If the decision is significant or contested, it becomes an ADR
(documentation-adr) so the reasoning survives; otherwise it feeds straight into archi.
Guardrails
- This step produces understanding, not a schema. Don't design tables or endpoints here: doing so
freezes the model around the first storage idea.
- Don't invent domain rules to fill a gap. An unanswered question about the business goes to the
business. A guess written into an invariant is the most expensive kind of wrong, because everything
downstream then depends on it.
- Renaming an established concept across an existing codebase is a coordinated refactor and a human
decision, never a quiet rename inside a feature branch.
- Timebox it. This block exists to prevent a week of rework, not to become the week.
Origin
Rewrite of the domain-modeling idea from a recognised market skill author, which sat in our backlog
unwritten because it looked like it overlapped documentation-adr. Reading it again, the overlap is
only in the output: the ADR block is a recording template, and nothing in the framework covered
reaching the decision. Vocabulary-follows-the-business and invariants-as-the-model are
domain-driven-design staples rather than anyone's private invention; the states-not-flags rule and
"list the awkward states" come from our own repeated finding that boolean combinations encode illegal
states, including the auth case where "awaiting approval" was flattened into "login failed"
(auth-session-conventions §4.6).
1---2name: domain-modeling3description: "Use when the work introduces or reshapes a domain concept: agree the vocabulary and where the rules live before designing the schema or the API. Runs before archi."4metadata:5 source: https://skillmd.com/skills/techmefr/domain-modeling6---78# domain-modeling910Step 3 of the pipeline (`WORKFLOW.md`), before `archi` and before `api-design`. Those two ask *where11does this plug in* and *what's the contract*. This one asks the question underneath: **what is this12thing, and what's true about it**. Getting that wrong produces a schema and an API that are both13faithful implementations of a misunderstanding.1415## When16As soon as the work introduces a new domain concept, or touches one that's showing strain: a status17field that keeps gaining values, a rule reimplemented in three places, a name that means different18things to two teams. Not for a straightforward addition to a concept that's already clear.1920## Steps2122### 1. Name things the way the business says them231. **Use the words the business uses**, in code as in conversation. When the business says "quote"24 and the code says "draft order", every discussion needs a translation, and translations drift.252. **One name, one meaning.** If a word means two things depending on the screen, that's two26 concepts wearing one name: name them separately. This is the most common finding and the most27 often waved away.283. **Write down the words you rejected** and why. The next person will otherwise reopen the same29 debate with no memory of it.3031### 2. Find the rules and decide where they live321. **List what must always be true** about the concept, in plain sentences ("an order can't be33 validated without a customer", "a contract's end date is never before its start"). These are34 invariants, and they are the model.352. **Decide where each one is enforced**, and prefer the narrowest place that can guarantee it: the36 type or the schema if it can (a non-nullable column, an enum), otherwise a single point in the37 domain code. A rule enforced in the UI only is a suggestion.383. **A rule duplicated across layers will diverge.** If it must exist in two places (a frontend check39 for feedback, a backend check for truth), say which one is authoritative and treat the other as40 ergonomics.4142### 3. Model state as states, not as flags431. **A concept with a lifecycle has a state**, not a pile of independent booleans. Three booleans44 describe eight combinations, and usually only four are legal: the other four are bugs waiting for45 the right sequence of clicks.462. **List the legal transitions**, and what triggers each. A status enum with no transition rules47 just relocates the problem into whoever writes the update.483. **Model the states that exist, including the awkward ones**: "awaiting approval", "partially49 delivered", "cancelled but invoiced". A model that only covers the clean path pushes reality into50 nullable columns and special cases.5152### 4. Draw the boundary531. **Say what the concept does not cover.** A boundary stated once prevents the slow accumulation54 where an entity ends up owning half the domain.552. **Check the concept against the existing model** (this is where `archi`'s dedup pass starts): a56 "new" concept is often an existing one under a different name, or a state of it.5758## Output / checkpoint59The vocabulary settled, the invariants listed with the place each is enforced, the states and legal60transitions, and the boundary. If the decision is significant or contested, it becomes an ADR61(`documentation-adr`) so the reasoning survives; otherwise it feeds straight into `archi`.6263## Guardrails64- **This step produces understanding, not a schema.** Don't design tables or endpoints here: doing so65 freezes the model around the first storage idea.66- **Don't invent domain rules to fill a gap.** An unanswered question about the business goes to the67 business. A guess written into an invariant is the most expensive kind of wrong, because everything68 downstream then depends on it.69- Renaming an established concept across an existing codebase is a **coordinated refactor and a human70 decision**, never a quiet rename inside a feature branch.71- Timebox it. This block exists to prevent a week of rework, not to become the week.7273## Origin74Rewrite of the `domain-modeling` idea from a recognised market skill author, which sat in our backlog75unwritten because it looked like it overlapped `documentation-adr`. Reading it again, the overlap is76only in the output: the ADR block is a *recording* template, and nothing in the framework covered77*reaching* the decision. Vocabulary-follows-the-business and invariants-as-the-model are78domain-driven-design staples rather than anyone's private invention; the states-not-flags rule and79"list the awkward states" come from our own repeated finding that boolean combinations encode illegal80states, including the auth case where "awaiting approval" was flattened into "login failed"81(`auth-session-conventions` §4.6).