Craft Model State

Crafting model states. Explicit state machines.

attac-t 4fada3c 2 files · 3.6 KB Updated

File contents

Skill: Craft Model State

"States are not strings. They are behavior."

The Standard

  1. Abstract Base: One per entity. Defines config() with transitions.
  2. Concrete States: One class per state. Behavior lives here.
  3. Custom Transitions: Side effects in transition classes, not models.
  4. Co-location: Domain/Entity/States/, not App/States/.

The Anti-Patterns

❌ Don't ✅ Do Why
Enum for stateful behavior State classes Behavior belongs with state
Transitions in model Custom transition classes Single responsibility
Fat abstract state Thin base, behavior in concrete Each state is unique

Real-World Examples

See examples.md.

attac-t/the-foundry/tree/main/plugins/laravel-ddd/skills/craft-model-state commit 4fada3ce0d

Frequently asked questions

npx skillmds@latest add attac-t/craft-model-state