domain-model
- Run by agents
- ux-architect
- Reached from commands
- /builder-os:bos-shape
At a glance
Mode. Standalone models the supplied domain and returns the entities, the rules and the prototype. In the lifecycle it runs in phase 4 after the flows and before the visual direction and the stack (the store depends on the shape of the data), writes SPEC.md → Design → ## Domain model, and gate 4.10 checks it. Both per operating modes. Read the domain method for the tables, the scenario technique, the logic prototype and a worked example.
- 1Start from what is settled
- 2Name the things
- 3Give each entity its states and transitions
- 4Write the invariants
- 5Stress it with scenarios
- 6Put the rules to the person, in their words
- 7Build a logic prototype
- 8Sketch the data
- 9Record and explain
The skill
ux-architecture designs what the screen shows when something is empty, loading or broken. This skill designs the things the product is about: what they are, what states they move through, who moves them, what must always be true, and how they are stored. A ticket reopened after it is closed, an invoice edited after it is sent: these are product decisions, and left to the build an agent makes them silently, one if at a time.
Mode. Standalone models the supplied domain and returns the entities, the rules and the prototype. In the lifecycle it runs in phase 4 after the flows and before the visual direction and the stack (the store depends on the shape of the data), writes SPEC.md → Design → ## Domain model, and gate 4.10 checks it. Both per operating modes. Read the domain method for the tables, the scenario technique, the logic prototype and a worked example.
Procedure
- Start from what is settled. Read the project's
DOMAIN.md, and the schema, migrations and status enums whererepo.readresolved. On a product that exists, model the delta: the entities this work adds, the states and transitions it adds or changes, the invariants it touches. Every existing rule it changes is named as a change, with the initiative that set it, and asked as a round question. Where an invariant tightens, count the existing rows that already break it (db.query) and hand the number to the spec's Impact on what exists. Done when you can list what exists, what this work changes, and the rows affected. - Name the things. From the flows, the spec scope and
PRODUCT.md: the entities the person acts on, each with a one-line definition in the product's words, checked againstPRODUCT.md→ Language. A term used two ways, or two terms for one thing, is a question for the person ("is a project the same as a workspace?"), settled first and written into Language. Done when every term has one meaning. - Give each entity its states and transitions. Per transition: who can trigger it, the guard (what must be true first), and the effect (notifications, other entities that change, what becomes irreversible). Draw each lifecycle under its table as a Mermaid
stateDiagram-v2, one arrow per transition labeled with who, every state of the table in it (gate 4.20); the person reads the drawing when the rules are put to them. An entity with no lifecycle gets a line saying so. Done when every transition has who, guard and effect, and every lifecycle is drawn. - Write the invariants: the rules that hold whatever happens ("a ticket has exactly one assignee or none", "a paid invoice changes only by credit note"). Each is a candidate test and, where the store allows, a constraint. Done when every rule the flows imply is written as an invariant.
- Stress it with scenarios. Walk concrete, awkward stories through the model: two people move the same ticket at once; the assignee leaves the team; a payment arrives for a cancelled order; the person undoes. Done when every scenario has an answer from the model or is listed as an undecided rule.
- Put the rules to the person, in their words. Every undecided rule becomes a
pressure-testinground question: options with what each means for the people using the product, a recommendation and why ("Can a closed ticket be reopened? A. Yes, by anyone… B. Only by its author… C. A new one is opened and linked…"). Hard-to-reverse ones (deletion, money, permissions) become ADRs. Done when every undecided rule has the person's answer. - Build a logic prototype when an entity has more than two states, a guarded transition, or a rule the person hesitated on: one HTML file at
.builderos/initiatives/{initiative}/design/domain-prototype.html, a button per action, guided scenarios from step 4, the full state shown after every click, in the product's language. The logic sits in one pure, in-memory script module the build can lift. Done when the person has played it, before accepting the model. - Sketch the data. Per entity: the fields that matter, the relationships, and what is deleted with what. The shape, short of a migration: enough for
system-design(stack) to choose a store and for the build to write the schema with every rule already decided. Done when each entity has fields, relationships and deletion behavior. - Record and explain. Write
## Domain modelinSPEC.md→ Design per the design template; at ship, phase 6 promotes it intoDOMAIN.md(gate 6.9), and standalone work on a product with aDOMAIN.mdproposes the edit there. Add a plain-language paragraph to the spec's## What we chose: the main objects and the two or three rules that will surprise someone. New terms go intoPRODUCT.md→ Language. Done when gate 4.10 passes on the file.
Watch for
| Do | Instead of |
|---|---|
| States, transitions, who, guard, effect | A status string whose rules get decided inside handlers |
| Ask "can it be reopened?" as a round question | A product rule made by whoever wrote the endpoint |
| One word per thing, written in Language | Two tables for one concept |
| An in-memory prototype with buttons | A prototype wired to the real database, testing plumbing |
| The entities this work touches | Weeks modeling the whole product |
| "Not applicable" only when nothing changes state or shape | Skipping the riskiest rules on a status change |
Capabilities
| Capability | Used for | Floor if absent |
|---|---|---|
repo.read | Existing entities, schemas, migrations, enums, status fields | Ask what exists; mark the model unverified against the code |
db.query | The real distribution of states and the rows that break the rules today | Model from the rules; mark counts unknown |
ui.render | Showing the logic prototype | A self-contained HTML file the person opens |
files.read / files.write | PRODUCT.md → Language, SPEC.md → Design, the prototype | Inline answers need no write; lifecycle writes require it |
Output Contract
## DOMAIN MODELED with the entities, the transitions with who and guard, the invariants, the rules the person decided, the prototype path when built, and the data sketch.
References
Read only when a step needs them, so they cost no context until then.
Domain Methodreferences/domain-method.md
The tables, scenarios, prototype rules and example behind domain-model. Read the section the current step needs.
Tables
### Entities
| Entity | Means | Lifecycle |
|--------|-------|-----------|
| Ticket | A piece of work someone is accountable for | yes |
| Comment | A note on a ticket; never edited after 10 minutes | no |
### Transitions: Ticket
| From | To | Who | Only if | Then |
|------|----|-----|---------|------|
| todo | in progress | assignee | it has an assignee | the assignee is notified once |
| in review | done | reviewer, not the assignee | every checklist item is ticked | the reporter is notified; reopening needs a new ticket |
```mermaid
stateDiagram-v2
[*] --> todo
todo --> in_progress : assignee
in_progress --> in_review : assignee
in_review --> done : reviewer
done --> [*]
```
### Invariants
- A ticket has exactly one assignee or none.
- A done ticket's fields are read-only.
### Data
| Entity | Key fields | Relations | Deleted with |
|--------|-----------|-----------|--------------|
| Ticket | title, state, assignee, reporter, team | many comments; one team | its team (soft delete) |Scenarios
The model is finished when awkward stories stop producing new questions. Run these families against every entity with a lifecycle:
| Family | Ask |
|---|---|
| Concurrency | Two people trigger conflicting transitions at the same moment. Who wins, what does the loser see? |
| People change | The owner leaves, loses permission, or is deleted mid-lifecycle |
| Going back | Undo, reopen, revert, cancel after partial completion |
| Money and time | A payment, a deadline or a scheduled job arrives in a state that no longer expects it |
| Volume | Zero, one, many, too many children (comments, items, members) |
| Outside world | An integration sends an update the model has no state for |
Write each scenario as one line with its answer, or as the round question it raised.
Logic Prototype
One self-contained HTML file the user opens with a double click. It answers "do these rules feel right?", not "does the backend work".
- The question at the top, in a visible paragraph: what model is being tested and which rules are new.
- A pure module in a single
block: a reducer(state, action) => stateor an explicit state machine, no DOM inside it. The page calls it; nothing flows back. This module is the part the build may lift. - Free play: one button per action, disabled when the guard forbids it, with the reason shown on hover.
- Guided scenarios: tabs that replay the stories from the Scenarios step, one step per click.
- State always visible: after every action, the whole state rendered in the product's words, plus a log of what happened and who was notified.
- No persistence, no network. In memory only.
The user plays it before the model is accepted. A rule they change while playing goes back into the Transitions table and, if heavy, into an ADR.
Worked Example
Rockys-like issue tracker, phase 4, after the flows. The scenarios raise three rules nobody decided; one round:
❓ **Q1 · Reopening**: a ticket is done and the bug comes back.
- **A** Reopen it → history stays in one place; "done" counts in reports can go down
- **B** Open a new linked ticket → reports stay stable; the history is split across two tickets
➡️ **B**: the phase 2 metric counts tickets closed per week and A would make it move backwards.
---
❓ **Q2 · Who closes** …
---
❓ **Q3 · Assignee leaves the team** …Then the prototype (design/domain-prototype.html) with tabs "bug comes back", "assignee leaves", "two reviewers at once". The user plays it, changes Q3 after the second tab, and the model is recorded.
Money has states too
A product for sale models its subscription like any other entity, before the build, because the edge cases are where revenue leaks: trial → active → past_due → cancelled, plus paused and refunded when the product offers them. The round asks what the product does at each edge: trial ends without a card, a payment fails three times, a customer downgrades mid-period with more seats than the new plan allows, a refund after the data was exported. The invariant every billing model needs: no access past the paid period without a written rule saying why (grace days, read-only mode). Who triggers each transition is named, as always: the customer, the payment provider's webhook, a person on the team.
Not Applicable
Write **Domain model:** not applicable, {reason} only when the work changes no entity's states, fields or relations: a copy change, a new chart over existing data, a style pass. A new status, a new field with rules, or a new relation is never "not applicable".
skills/domain-model/SKILL.mdView on GitHub