principle-model-the-domain — Claude Code skill
Guides an agent to model domain rules in data structures instead of growing conditionals. Use it when stateful code or repeated shape assumptions start spreading.
npx skills add backnotprop/pstack --skill principle-model-the-domain -a claude-codeWhat principle-model-the-domain does
This skill steers implementation away from scattered booleans and expanding if/else chains toward a structure that captures domain rules. It suggests state machines, typed models, lookup tables, registries, discriminated unions, reducers, and command or event models.
It also calls for a small module boundary when behaviour, ownership, or invariants repeat. A queue, cache, index, graph, tree, or normalized collection fits when the access pattern calls for one. A feature that adds another branch to an old conditional chain, or a second boolean that must track the first, is a reason to revisit the model.
It does not push abstraction for its own sake. If the code is clear, local, and unlikely to grow, the skill favours keeping it simple.
What it helps with
- replace an
if/elsechain with a state model - collect repeated data-shape rules in a typed model
- remove booleans that must stay in sync
- select a structure for an access pattern
- move shared invariants behind a module boundary
Example prompts for the agent
- Review this stateful logic and propose a state machine instead of boolean flags.
- Find repeated assumptions about the data shape and define a typed model.
- Check whether these branches should become a lookup table or discriminated union.
How to install principle-model-the-domain
1Skills CLI (Vercel)
npx skills add backnotprop/pstack --skill principle-model-the-domain -a claude-code2Manually: put the files in place
~/.claude/skills/principle-model-the-domain/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/principle-model-the-domain/
1Skills CLI (Vercel)
npx skills add backnotprop/pstack --skill principle-model-the-domain -a codex2Manually: put the files in place
.agents/skills/principle-model-the-domain/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add backnotprop/pstack --skill principle-model-the-domain -a cursor2Manually: put the files in place
.cursor/skills/principle-model-the-domain/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install backnotprop/pstack principle-model-the-domain2Manually: put the files in place
.github/skills/principle-model-the-domain/SKILL.md1Skills CLI (Vercel)
npx skills add backnotprop/pstack --skill principle-model-the-domain -a gemini-cli2Platform CLI
gemini skills install https://github.com/backnotprop/pstack --path skills/principle-model-the-domainManually: put the files in place
.devin/skills/principle-model-the-domain/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add backnotprop/pstack --skill principle-model-the-domain -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about principle-model-the-domain
How do I install principle-model-the-domain in Claude Code?
Run npx skills add backnotprop/pstack --skill principle-model-the-domain -a claude-code, then run npx skills add backnotprop/pstack --skill principle-model-the-domain -a claude-code again. The skill file is at ~/.claude/skills/principle-model-the-domain/SKILL.md.
What does principle-model-the-domain do?
It guides an agent to encode domain rules in suitable data structures. It suggests state machines, typed models, registries, or reducers when they remove scattered branches and duplicated rules.
When does the skill advise against an abstraction?
It favours plain code when the current shape is already clear, local, and unlikely to grow. It warns against indirection that does not remove branches, duplicated rules, invalid states, or lifecycle risk.
Source text
SKILL.md · MIT
--- name: principle-model-the-domain description: "Apply when writing stateful logic, or when code branches a lot or repeats a shape assumption across files." disable-model-invocation: true --- # Model the Domain Encode the real domain in a data structure instead of scattering it across conditionals. 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: - A state machine instead of scattered booleans, phases, or lifecycle checks. - A typed 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 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.
© backnotprop · MIT · backnotprop/pstack