principle-model-the-domain

Encodes domain rules in data structures instead of scattered conditionals across code.

Updated Sep 18, 2026
One-click install
npx skills add https://github.com/fern-works/greenline --skill principle-model-the-domain-fern-works
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: principle-model-the-domain
Source: https://github.com/fern-works/greenline/tree/main/corpus/upstream/pstack/f5bdd6826fd0a0d9cbc4347134c3a74a200b9d9d/principle-model-the-domain
Command: npx skills add https://github.com/fern-works/greenline --skill principle-model-the-domain-fern-works

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Stateful logic often ends up as scattered booleans, repeated shape assumptions, and branching spread across files, which creates accidental complexity and allows invalid states. This Skill guides you to encode the real domain in a structure so invalid states become unrepresentable and branches disappear. ## Core Features & Use Cases - Structure Selection Guidance: Recommends state machines, typed models, registries, discriminated unions, reducers, and command/event models as replacements for ad hoc conditionals. - Anti-Pattern Detection: Identifies warning signs such as growing if/else chains, booleans that must stay in sync, and temporal decomposition across phase-named modules. - Restraint Against Over-Abstraction: Advises preferring boring, clear code when the current shape is local and unlikely to grow, and rejecting abstractions that add indirection without removing branches. - Use Case: When adding a new lifecycle phase to a feature, instead of extending an if/else chain and adding another boolean, model the lifecycle as a state machine so illegal transitions cannot compile. ## Quick Start Apply the model-the-domain principle to refactor this module's scattered conditionals into a structure that encodes the domain rules.

Frequently Asked Questions about principle-model-the-domain

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I replace scattered conditionals with a domain model?▼

Identify what the code must never allow and how the data gets read, then pick a structure that encodes exactly that. Common choices include state machines for lifecycles, discriminated unions for branching, and typed models for repeated shape assumptions.

When should I use a state machine instead of booleans?▼

Use a state machine when multiple booleans must stay in sync or when lifecycle checks are scattered across files. A state machine makes invalid states unrepresentable and deletes the branches that kept the booleans consistent.

What are signs that code needs domain modeling?▼

Key signs are a new feature growing an existing if/else chain by one more branch, a second boolean that must stay in sync with the first, and temporal decomposition where phase-named modules repeat the same domain rules across steps.

When should I avoid adding a domain abstraction?▼

Avoid it when the current shape is already clear, local, and unlikely to grow. Be skeptical of any abstraction that adds indirection without removing branches, duplicated rules, invalid states, or lifecycle risk.

Why is it better to model the domain at write time?▼

Choosing the structure at write time is cheap, while recovering it later reads as a refactor and gets deferred. Scattered conditionals accumulate accidental complexity that becomes harder to untangle as features grow.