Skip to main content
skill CX Codex

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.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add backnotprop/pstack --skill principle-model-the-domain -a claude-code
Open on GitHub

What 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/else chain 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-code

2Manually: put the files in place

~/.claude/skills/principle-model-the-domain/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/principle-model-the-domain/

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

Similar skills

Everything for Code review and refactoring →

From the same set44

principle-sequence-verifiable-units Guides coding agents to break multi-step sweeps and migrations into verifiable units. Keeps each step verified before proceeding to the next. CX Codex +1 5,100installs principle-test-behavior-not-implementation A rule for tests you write or keep: assert what callers can observe. Turns tests that break on every refactor into ones that catch real bugs. CX Codex +1 5,200installs principle-minimize-reader-load A skill that spots unnecessary layers of abstraction and hidden state slowing down code comprehension. Use it when reviewing complex code where the logic is hard to trace. CX Codex +1 5,200installs principle-migrate-callers-then-delete-legacy-apis Instructs the assistant to migrate internal callers and delete legacy APIs in a single wave, skipping temporary compatibility layers. CX Codex +1 5,200installs principle-redesign-from-first-principles A skill that makes the agent rebuild an existing design as if the new requirement had been there from day one. Use it when a change ripples through types, docs, and examples. CX Codex +1 5,200installs principle-never-block-on-the-human Instructs coding agents to execute reversible changes immediately instead of asking for approval. Useful for autonomous sessions under asynchronous supervision. CX Codex +1 5,200installs principle-build-the-lever A skill that pushes the agent to write a codemod, script or generator for non-trivial work instead of editing by hand, so the result can be rerun. CX Codex +1 5,200installs principle-make-operations-idempotent A skill for writing commands and processing loops that converge to the same state regardless of restarts, crashes, or retries. Use it when operations need to survive partial runs and still reach the correct outcome. CX Codex +1 5,200installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor