Skip to content
Development
Skill

/domain-modeling

Use when introducing, reviewing, or renaming a top-level type, table, or domain concept; or choosing where state lives (in-memory vs persistent)

From plugin
97
2512 skills1 hook

Claude Code

$ npx -y skills add oribarilan/97 --skill domain-modeling --agent claude-code

SKILL.md

domain-modeling.SKILL.md
name: domain-modeling
description: Use when introducing, reviewing, or renaming a top-level type, table, or domain concept; or choosing where state lives (in-memory vs persistent)

Domain Modeling

Overview

The names and shapes you give the concepts in your code *are* the design. **When you introduce a new domain concept, name it for what it means in the user's world, give it a real type, and decide where its state lives — before you write the methods that act on it.**

This is a **rigid** skill. Run the decisions in order. If you can't satisfy one, stop and tell the user what's blocking you. When the concept is exposed across a module/package/service boundary, also invoke `api-design` (overlap on type design and value-vs-identity).

When to invoke

Invoke when you're about to:

  • Introduce a new top-level type, class, struct, record, or table that represents a *thing in the domain* (Trader, Portfolio, Booking, Invoice, Reservation)
  • Rename an existing domain concept across files
  • Add a new database table or persistent collection
  • Decide whether a chunk of state should live in memory, in a file, in a key-value store, or in a relational database
  • Replace primitive-typed data (`int`, `string`, `Map<int, Map<int, int>>`) with named domain types
  • Sketch the data model for a new feature, area, or service
  • Evaluate whether an existing domain model is well-structured, or review naming and type choices

If you're not sure whether a change introduces a *new domain concept* (vs. a local helper), **invoke anyway** — the decisions are cheap, mismodeled domain concepts are not.

Non-triggers — do NOT invoke for

  • Renaming a single local variable inside one function (`x` → `count`)
  • Renaming a private helper function or internal-only struct that doesn't represent a domain concept
  • Adding a new field to an existing type when the field is not itself a new domain concept (a new `lastModified` timestamp on `Booking` — no; a new `CancellationPolicy` type referenced from `Booking` — yes)
  • Adjusting an existing type's representation without changing its meaning (switching `int` user IDs to `long`)
  • Adding a method to an existing domain type (use `clean-code` instead)
  • Defining a DTO that mirrors an existing domain type one-to-one for transport (use `api-design`)

Language guard

The typed-domain principles below (`Wlaschin/InvalidStatesUnrepresentable`, `Wlaschin/SmartConstructors`, `Wlaschin/TypesForEffects`, `Fowler/PrimitiveObsession`) fire hardest in languages with sum types and pattern matching (TypeScript, Rust, F#, Haskell, Scala, Kotlin, modern C#). They degrade gracefully in dynamic languages (Python, JavaScript, Ruby) where the agent reaches for frozen dataclasses, `pydantic`, `attrs`, `TypedDict`, or NewType where they help. **Do not be type-system-evangelical** — in a small Python script, a `dict` is the right answer.

The domain-modeling decisions

Run every decision in order. Do not write the type's methods until decision 5 is settled.

1. **Name the concept the way the domain expert names it.** If the user says "trader", "portfolio", "booking", "policy" — that's the type name. Avoid invented programmer terms (`UserDataObject`, `BookingManager`, `PolicyHelper`) when a domain term exists. If the domain expert wouldn't recognize the name, you're inventing a secret vocabulary the next programmer will have to decode. *(North, 97/11.)* 2. **Make implicit relationships explicit as types or methods.** If the rule is "some traders cannot view some portfolios," prefer `trader.canView(portfolio)` over `portfolioIdsByTraderId.get(...)containsKey(...)`. Replace primitive obsession (raw ints, strings, nested maps standing in for relationships) with named types and operations. *(North, 97/11.)* 3. **Treat this as design, not typing.** The shape you pick now will outlive most of the code that uses it. Sketch two or three alternatives before committing. Validate the chosen shape against at least two realistic scenarios — if it forces awkward workarounds in either, it's the wrong shape. Code is design; design needs validation. *(Brush, 97/12.)* 4. **Default to immutable value types and pure transformations.** Unless the concept *intrinsically* has identity and lifetime (a `User`, a `Booking`), prefer value types you construct fresh rather than mutate. Operations that produce new domain objects from old ones are easier to test, reason about, and reuse than methods that secretly mutate shared state. *(Garson, 97/2.)* 5. **Decide where the state lives — before sketching methods.** Ask: Is this data **large** (won't fit in RAM), **persistent** (survives process restart), or **interconnected** (entities reference each other with consistency rules)? If yes to any two: it belongs in a database (embedded like SQLite is fine for small needs). If no to all three: an in-memory structure is fine. Hand-rolled `Map<int, Map<int, int>>` for what is really a relational dataset is a cost you pay forever. *(Spinellis, 97/48.)* 6. **Consider whether this concept needs its own little language.** When users keep describing the concept with a constrained vocabulary — rules, validations, query expressions, configuration — and several places in the code re-encode that vocabulary by hand, you are recreating a DSL the slow way. An internal DSL (a fluent API in the host language) lets domain experts read and sometimes write the rules directly. Don't *start* here, but recognize the smell. *(Hunger, 97/23.)* 7. **Place the concept in one canonical location.** One file, one module, one table — not three competing definitions. If you find a parallel concept already exists under a different name, stop and unify before adding a third. The next programmer should be able to find this concept by searching for the domain term and finding exactly one definition.

Red Flags

These thoughts mean STOP — restart the decisions:

| Thought | Reality | |---|---| | "I'll use a `Map<int, Map<int, ...>>` — it's just

Read more
@oribarilan
Ships with97

Agent skills distilled from the hard-won lessons of world-renowned programmers, in the spirit of "97 Things Every Programmer Should Know"

Stars on GitHub

Momentum

stars in total
25
Star history of oribarilan/97 on GitHub, a chart by star-history.com

Other skills on 97.

api-design

api-design

Use when designing or reviewing a public API, exported function signature, module boundary, exported type/interface, or any…

@oribarilan@oribarilanInstall Skill
before-you-refactor

before-you-refactor

Use when considering, evaluating, or performing a refactor, restructure, cross-file rename, or cleanup

@oribarilan@oribarilanInstall Skill
build-deploy-and-tooling

build-deploy-and-tooli…

Use when writing, reviewing, or changing build scripts, CI workflows, deploy pipelines, repo setup, or evaluating a new…

@oribarilan@oribarilanInstall Skill
clean-code

clean-code

Use when writing or reviewing functions, classes, naming, or non-trivial logic (≥3 lines)

@oribarilan@oribarilanInstall Skill
correctness-traps

correctness-traps

Use when writing or reviewing error handling, floating-point math, concurrent code, remote calls, singletons/globals, hot-path…

@oribarilan@oribarilanInstall Skill
observability

observability

Use when writing or reviewing request handlers, RPCs, or background jobs for production; adding tracing, metrics, or…

@oribarilan@oribarilanInstall Skill

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills10d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc11d293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react1d252k
@facebook@facebookInstall Skill

Questions about domain-modeling.

Which coding agents can use domain-modeling?
domain-modeling installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.