agentleFS
requierequie/endostack/skills/principle-model-the-domain/SKILL.md

principle-model-the-domain

Skill4 starsChanged 16 days agoMITView on GitHub

Use when writing stateful logic, branch-heavy code, or the same shape assumption repeated across files. Capture domain rules with a state machine, typed model, or lookup table so invalid states cannot be built.

45 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use poteto-help, setup-pstack and 2 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • ianclearySkill

    poteto-help

    Guides users through pstack setup, /poteto-mode, and picking the skill, playbook, or principle for a task. Type /poteto-help with a question.

    Also in 14 projects that use this

  • bnemaSkill

    setup-pstack

    Configure which Pi models pstack uses per role. Detects available provider/model specs and writes pstack's user configuration. Use for /setup-pstack, "configure pstack models", or changing pstack model choices.

    Also in 24 projects that use this

  • tristanphvnSkill

    ketchup-video

    Catch the user up like /keel:ketchup, with a short silent video of slides for what happened and the waiting calls as text under it. Use for /keel:ketchup-video.

    Also in 10 projects that use this

  • instructureSkill

    ketchup

    Rebuild context after /clear by analyzing uncommitted changes across Canvas LMS and all plugin repositories

    Also in 17 projects that use this

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 45 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If nothing standard fits, write down what the code must never permit and how the data is read, then find a structure that encodes exactly …

    line 28

“Common” is measured: kept by at least 6 in 10 of the 45 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Model the domain

Encode the domain as a data structure in which invalid states cannot exist and branches become unnecessary, instead of scattering its rules through conditionals. Choosing the structure at the moment you write the code costs little. Introduced afterwards, it looks like a refactor, and refactors tend to be postponed indefinitely.

When it applies

Writing stateful logic, code with heavy branching, and the same assumption about a data shape repeated across files. Apply it whenever you name the data shape for a code task.

Skip it when the current shape is clear, local, and unlikely to grow. Prefer plain code there. Be wary of an abstraction that adds indirection unless it also eliminates something: a branch, a repeated rule, a reachable invalid state, or a lifecycle hazard.

What to do

Reach for the structure that fits:

  1. A state machine in place of scattered booleans, phase flags, or lifecycle checks. An agent session with is_authenticated, is_elevated, and is_locked booleans permits "locked and elevated". A state machine with Anonymous, Authenticated, Elevated, and Locked states and explicit transitions does not.
  2. A typed model in place of loose parameters or repeated assumptions about shape.
  3. A lookup table, map, registry, or tagged union in place of branching scattered over files. A tool registry that maps each tool name to its handler and required permission puts the authorization rule in one table a reviewer can read.
  4. A reducer or a command and event model in place of ad hoc mutation.
  5. Modules built around a single area of domain knowledge, rather than around steps in a pipeline. Execution order (load, validate, transform, save) does not define ownership.
  6. A small module boundary that collects repeated behavior, ownership, or invariants.
  7. Queues, caches, indexes, graphs, trees, or normalized collections where the access patterns call for them.
  8. If nothing standard fits, write down what the code must never permit and how the data is read, then find a structure that encodes exactly that.

Signs you skipped it

A new feature adds one more branch to an existing if/else chain. A second boolean has to be kept consistent with a first. Phase-named modules each repeat the same domain rule.

The failure it prevents

Rules duplicated across files that drift apart, and invalid states that are reachable because nothing prevents constructing them.

Done when

Domain rules live in one structure and invalid states cannot be constructed.

Related: principle-foundational-thinking, principle-type-system-discipline, principle-minimize-reader-load, statechart.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.