Model the Domain
Encode the real domain in a data structure instead of scattering it across conditionals.
Why: Scattered booleans, repeated shape assumptions, and branching spread across files are accidental complexity. A structure that matches the domain makes invalid states unrepresentable and deletes branches. Choosing it at write time is cheap. Recovering it later reads as a refactor and gets deferred.
Reach for structures like these:
- A state machine instead of scattered booleans, phases, or lifecycle checks.
- A typed object/model instead of loose parameters or repeated shape assumptions.
- A map, registry, lookup table, or discriminated union instead of branching spread across files.
- A reducer or command/event model instead of ad hoc state mutations.
- A module organized around one body of domain knowledge instead of a sequence such as load, validate, transform, and save. Execution order is not ownership.
- A small module boundary that gathers repeated behavior, ownership, or invariants.
- A queue, cache, index, graph/tree, or normalized collection where the data access pattern calls for it.
- Any other structure that fits. When none fits, work out what the code must never allow and how the data gets read, then find the structure that encodes exactly that.
Do not force an abstraction. Prefer boring code if the current shape is already clear, local, and unlikely to grow. Be skeptical of an abstraction that adds indirection without removing branches, duplicated rules, invalid states, or lifecycle risk.
The sign that you skipped this is a new feature that grows an existing if/else chain by one more branch, or a second boolean that must stay in sync with the first. Temporal decomposition is another sign. Phase-named modules repeat the same domain rules across steps.
This repository (Asymmetric-al/core)
Vendored from p3-stack (MIT) at commit 09909eb. Provenance is in references/upstream.md. On conflict, the current user request, root AGENTS.md, the nearest nested AGENTS.md, and the matching docs/ai/rules/* rulebook win over this skill.
- Explicit invocation only: use it when the user invokes
/principle-model-the-domain (Claude Code, Cursor, T3 Code) or $principle-model-the-domain (Codex), or when an invoked p3-stack skill routes here. Do not route other work to it.
- Confirm before outward-facing or hard-to-reverse actions such as pushing, merging, deploying, deleting, or posting messages, unless the user authorized that action for this task.
Edit this canonical copy in docs/ai/skills/principle-model-the-domain/, then run bun run skills:sync and bun run skills:verify.
1---2name: principle-model-the-domain3description: "Apply when writing stateful logic, or when code branches a lot or repeats a shape assumption across files. Encode the domain in a structure instead of scattered conditionals."4disable-model-invocation: true5metadata:6 source: https://skillmd.com/skills/asymmetric-al/principle-model-the-domain7---89# Model the Domain1011Encode the real domain in a data structure instead of scattering it across conditionals.1213**Why:** Scattered booleans, repeated shape assumptions, and branching spread across files are accidental complexity. A structure that matches the domain makes invalid states unrepresentable and deletes branches. Choosing it at write time is cheap. Recovering it later reads as a refactor and gets deferred.1415**Reach for structures like these:**1617- A state machine instead of scattered booleans, phases, or lifecycle checks.18- A typed object/model instead of loose parameters or repeated shape assumptions.19- A map, registry, lookup table, or discriminated union instead of branching spread across files.20- A reducer or command/event model instead of ad hoc state mutations.21- A module organized around one body of domain knowledge instead of a sequence such as load, validate, transform, and save. Execution order is not ownership.22- A small module boundary that gathers repeated behavior, ownership, or invariants.23- A queue, cache, index, graph/tree, or normalized collection where the data access pattern calls for it.24- Any other structure that fits. When none fits, work out what the code must never allow and how the data gets read, then find the structure that encodes exactly that.2526Do not force an abstraction. Prefer boring code if the current shape is already clear, local, and unlikely to grow. Be skeptical of an abstraction that adds indirection without removing branches, duplicated rules, invalid states, or lifecycle risk.2728The sign that you skipped this is a new feature that grows an existing if/else chain by one more branch, or a second boolean that must stay in sync with the first. Temporal decomposition is another sign. Phase-named modules repeat the same domain rules across steps.2930<!-- CORE-OVERLAY-START -->3132## This repository (Asymmetric-al/core)3334Vendored from [p3-stack](https://github.com/uzairansaruzi/p3-stack) (MIT) at commit `09909eb`. Provenance is in `references/upstream.md`. On conflict, the current user request, root `AGENTS.md`, the nearest nested `AGENTS.md`, and the matching `docs/ai/rules/*` rulebook win over this skill.3536- Explicit invocation only: use it when the user invokes `/principle-model-the-domain` (Claude Code, Cursor, T3 Code) or `$principle-model-the-domain` (Codex), or when an invoked p3-stack skill routes here. Do not route other work to it.37- Confirm before outward-facing or hard-to-reverse actions such as pushing, merging, deploying, deleting, or posting messages, unless the user authorized that action for this task.3839Edit this canonical copy in `docs/ai/skills/principle-model-the-domain/`, then run `bun run skills:sync` and `bun run skills:verify`.4041<!-- CORE-OVERLAY-END -->