Skip to content
Skillpedia
General coding15k · #10982

principle-model-the-domain

What it does

Gives the assistant a rule for modeling stateful logic with structures that match the domain. It is for engineers whose code is full of flags and nested conditions.

When to use it

  • ✓When you are writing stateful logic with lifecycles or phases.
  • ✓When code branches heavily or repeats the same shape assumptions across files.
  • ✓When invalid states keep getting into the system.

Skill link

https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-model-the-domain/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-model-the-domain/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“Our order flow uses a mess of booleans to track its status. Model it properly so impossible states cannot happen.”

5 new skills a week. 1 minute to read.

How it works

The assistant identifies the real states and rules, then encodes them in a fitting structure such as a state machine, typed model or lookup table. This removes many branches and makes invalid states harder to write.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

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.

FAQ

Does every problem need a new structure?

No. The skill says to prefer plain code when the current shape is clear and unlikely to grow.

What is a common example?

Replacing scattered booleans with a state machine that only allows valid transitions.

Why choose the structure early?

It is cheap at write time, while recovering the right structure later often gets deferred and costs more.

Details

Original description by the author

Apply when writing stateful logic, or when code branches a lot or repeats a shape assumption across files.

repo: cursor/plugins

Popularity

GitHub stars
15k
Ranking position
#10982
License
—
Updated
10/31/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills