# Principle model the domain

> Principle model the domain is an open-source agent skill for developer tools. Guides the agent to encode domain logic in data structures instead of branching. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/michael-denyer/pstack-claude/tree/main/plugins/pstack/skills/principle-model-the-domain
- **Repository:** https://github.com/michael-denyer/pstack-claude
- **GitHub stars:** 5,057
- **License:** MIT
- **Skill name:** principle-model-the-domain
- **Collection:** https://github.com/michael-denyer/pstack-claude
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-01

## About

This skill tells the agent to model a problem's domain in data structures rather than spreading it across conditionals. It names several patterns to reach for: a state machine in place of scattered booleans or phase checks, a typed model in place of loose parameters, a map, registry or discriminated union when branching spans files, a reducer in place of ad hoc mutation, and an index, queue or normalized collection when the access pattern calls for one.

The skill also warns against overusing the approach. Clear, local code that is unlikely to grow should stay simple, and an abstraction that adds indirection without removing branches or invalid states is treated as a mistake. It flags a feature that keeps adding if/else branches, or a second boolean that must stay in sync with another, as signs the approach was skipped.

The skill is a plain instruction file with no scripts. It is written for coding agents working in any language and is marked as not user-invocable, so it loads when a task matches its description.

## When your agent uses it

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

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/michael-denyer/pstack-claude/tree/HEAD/plugins/pstack/skills/principle-model-the-domain)
- [License: MIT](https://github.com/michael-denyer/pstack-claude/tree/HEAD/plugins/pstack/skills/principle-model-the-domain)

## Features

- **State machine modeling:** Replaces scattered booleans and phase checks with explicit states and transitions.
- **Typed domain models:** Favors typed structures over loose parameters to make invalid states unrepresentable.
- **Discriminated unions and registries:** Moves branching spread across files into maps, registries or tagged unions.
- **Reducer-based updates:** Suggests reducers over ad hoc mutations for changing state.
- **Indexes and normalized collections:** Recommends indexes, queues or normalized data where access patterns call for them.
- **Restraint against over-abstraction:** Warns against indirection that removes no branches or invalid states.

## Good for

- Refactor a feature that has grown a long if/else chain
- Replace several booleans that must stay in sync with a state machine
- Consolidate branching logic spread across multiple files into one structure
- Review code for repeated shape assumptions that should become a typed model

## Install

### Claude Code

This skill ships in the `pstack` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add michael-denyer/pstack-claude
/plugin install pstack@pstack-claude
```

Or copy only this skill to `~/.claude/skills/principle-model-the-domain`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/principle-model-the-domain &&
cp -R "$tmp/plugins/pstack/skills/principle-model-the-domain" ~/.claude/skills/principle-model-the-domain &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/principle-model-the-domain` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/principle-model-the-domain` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/principle-model-the-domain &&
cp -R "$tmp/plugins/pstack/skills/principle-model-the-domain" ~/.agents/skills/principle-model-the-domain &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/principle-model-the-domain` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/principle-model-the-domain` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/principle-model-the-domain &&
cp -R "$tmp/plugins/pstack/skills/principle-model-the-domain" ~/.cursor/skills/principle-model-the-domain &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/principle-model-the-domain` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/michael-denyer/pstack-claude.git --path plugins/pstack/skills/principle-model-the-domain
```

Or copy the folder to `~/.gemini/skills/principle-model-the-domain` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/principle-model-the-domain`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/principle-model-the-domain &&
cp -R "$tmp/plugins/pstack/skills/principle-model-the-domain" ~/.copilot/skills/principle-model-the-domain &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/principle-model-the-domain` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git
```

Then copy `pstack-claude/plugins/pstack/skills/principle-model-the-domain` into your agent's skills folder as `principle-model-the-domain`. Agents that support SKILL.md read one folder per skill.

## FAQ

### When does Principle model the domain trigger?

It applies when the agent is writing stateful logic, or when code branches a lot or repeats a shape assumption across files.

### Does Principle model the domain require any scripts or tools?

No. It has no scripts and does not set allowed tools; it is an instruction file only.

### Does Principle model the domain force a particular pattern?

No. The skill says to keep simple code when the shape is clear and local, and to avoid abstractions that add indirection without removing branches or invalid states.

### How do I install Principle model the domain in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/principle-model-the-domain to use it in all your projects, or to .claude/skills/principle-model-the-domain in one project. Or install the pstack plugin, which includes it: /plugin marketplace add michael-denyer/pstack-claude, then /plugin install pstack@pstack-claude.

### Does Principle model the domain run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Principle model the domain?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

### What are the best alternatives to Principle model the domain?

The closest alternatives to Principle model the domain are Domain modeling, Principle type system discipline, Principle foundational thinking, TypeScript best practices and Domain modeling.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Domain modeling](https://ai-powered.com/skills/domain-modeling-xd4o): Domain modeling is an open-source agent skill for developer tools.
- [Principle type system discipline](https://ai-powered.com/skills/principle-type-system-discipline): Principle type system discipline is an open-source agent skill for developer tools.
- [Principle foundational thinking](https://ai-powered.com/skills/principle-foundational-thinking): Principle foundational thinking is an open-source agent skill for developer tools.
- [TypeScript best practices](https://ai-powered.com/skills/typescript-best-practices): TypeScript best practices is an open-source agent skill for developer tools.
- [Domain modeling](https://ai-powered.com/skills/domain-modeling): Domain modeling is an open-source agent skill for developer tools.
- [Patterns](https://ai-powered.com/skills/patterns-xiaolai): Patterns is an open-source agent skill for developer tools.
- [Refactor](https://ai-powered.com/skills/refactor): Refactor is an open-source agent skill for developer tools.
- [Principle boundary discipline](https://ai-powered.com/skills/principle-boundary-discipline): Principle boundary discipline is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/principle-model-the-domain
