gof-state

Installation
SKILL.md

One-line summary

Allow an object to alter its behavior when its internal state changes — making the object appear to change its class. Each state is encapsulated in its own class; the context delegates behavior to whichever state it currently holds.

When to use this skill

  • An object has multiple, well-defined states and its behavior depends meaningfully on which state it is in (gumball machine, order lifecycle, network connection, parser).
  • The current implementation has a large switch or if-else over a status enum where each branch does substantially different work.
  • The set of states is bounded and known; transitions between them are limited and rule-bound.

When NOT to use this skill

  • Only two states with trivially different behavior — a single boolean flag and a small if is simpler.
  • The "state" is actually data, not behavior — that's a value object, not a state machine.
  • The states are not mutually exclusive (multiple flags can be true simultaneously) — that's not a state machine; it's a feature flag matrix.

Core content

The pattern has three parts:

Installs
20
GitHub Stars
1
First Seen
Jul 13, 2026
gof-state — yonatankarp/software-design-skills