principle-model-the-domain

Encodes domain logic into data structures instead of scattered conditionals across code.

Updated Aug 22, 2026
One-click install
npx skills add https://github.com/squidllee/skills --skill principle-model-the-domain-squidllee
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: principle-model-the-domain
Source: https://github.com/squidllee/skills/tree/main/principle-model-the-domain
Command: npx skills add https://github.com/squidllee/skills --skill principle-model-the-domain-squidllee

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Codebases accumulate accidental complexity when domain rules are scattered across booleans, if/else chains, and repeated shape assumptions in multiple files. This Skill guides you to encode the domain directly in a structure, making invalid states unrepresentable and deleting branches at write time. ## Core Features & Use Cases - Structure Selection Guidance: Recommends concrete structures such as state machines, typed models, lookup tables, discriminated unions, reducers, and domain-organized modules to replace branching logic. - Anti-Pattern Detection: Identifies tells like growing if/else chains, booleans that must stay in sync, and phase-named modules that repeat domain rules across steps. - Restraint Against Over-Abstraction: Advises preferring boring code when the current shape is already clear, local, and unlikely to grow. - Use Case: When adding a feature that extends an existing conditional chain or introduces a second lifecycle flag, apply this Skill to design a state machine or registry that encodes the domain rules once. ## Quick Start Apply the model-the-domain principle to refactor this module's scattered conditionals into a single domain structure.

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 if/else chains 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 lifecycle checks, discriminated unions or lookup tables for branching, and reducers for ad hoc state mutations.

What is a state machine and when should I use one in code?▼

A state machine encodes valid states and transitions explicitly instead of relying on scattered booleans or phase checks. Use it when multiple flags must stay in sync or when lifecycle rules are spread across files, since it makes invalid states unrepresentable.

When should I avoid adding an abstraction to my code?▼

Prefer boring code 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.

What are the signs that my code needs domain modeling?▼

Common tells include a new feature growing an existing if/else chain by one branch, a second boolean that must stay in sync with the first, and phase-named modules that repeat the same domain rules across sequential steps.

How do I organize modules around domain knowledge instead of execution order?▼

Group code by one body of domain knowledge rather than by sequence such as load, validate, transform, and save. Execution order is not ownership, and temporal decomposition causes domain rules to be repeated across steps.