Skip to content
Agentmart
Submit a tool

game-design-patterns

Use this skill when implementing game programming patterns - state machines for character/AI behavior, object pooling for performance-critical spawning, event…

Skill by mkurman

IndexedMIT★ 325
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/mkurman-game-design-patterns

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Use this skill when implementing game programming patterns - state machines for character/AI behavior, object pooling for performance-critical spawning, event systems for decoupled game communication, or the command pattern for input handling, undo/redo, and replays. Triggers on game architecture, game loop design, entity management, finite state machines, object pools, observer/event bus, command queues, and gameplay programming patterns.

Use cases: design

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/game-design-patterns

What's inside

Skill name
game-design-patterns
Description
Use this skill when implementing game programming patterns - state machines for character/AI behavior, object pooling for performance-critical spawning, event systems for decoupled game communication, or the command pattern for input handling, undo/redo, and replays. Triggers on game architecture, game loop design, entity management, finite state machines, object pools, observer/event bus, command queues, and gameplay programming patterns.
License
MIT
Instructions
340 lines in SKILL.md · view on GitHub

Files (7)

  • README.md
  • SKILL.md
  • evals.json
  • command-pattern.md · references/
  • event-systems.md · references/
  • object-pooling.md · references/
  • state-machines.md · references/

SKILL.md (first lines)

## Key principles

1. **Frame budget is law** - Every pattern choice must respect the ~16ms frame budget.
   Allocations during gameplay cause GC spikes. Indirection has cache costs. Always
   profile before adding abstraction.

2. **Decouple, but not infinitely** - Game systems should communicate through events
   and commands rather than direct references, but over-decoupling creates debugging
   nightmares. One level of indirection is usually enough.

3. **State is explicit** - Implicit state (nested boolean flags, mode integers) leads
   to impossible combinations and subtle bugs. Make every valid state a first-class
   object with defined transitions.

4. **Pool what you spawn** - Any entity created and destroyed more than once per
   second should be pooled. The cost of allocation is not the constructor - it is the
   garbage collector pause 3 seconds later.

5. **Commands are data** - When input actions are objects rather than direct method
   calls, you get undo, replay, networking, and AI "for free." The command pattern
   is the single highest-leverage pattern in gameplay code.

---

## Core concepts

**State machines** model entities that have distinct behavioral modes. A character
can be Idle, Running, Jumping, or Attacking - but never Jumping and Idle at the same
time. Each state encapsulates its own update logic, entry/exit behavior, and valid
transitions. Hierarchical state machines (HFSM) add nested sub-states for complex AI.

**Object pooling** pre-allocates a fixed set of objects and recycles them instead of
creating and destroying instances at runtime. The pool maintains an "available" list
and hands out pre-initialized objects on request, reclaiming them when they are
"killed." This eliminates allocation pressure during gameplay.

**Event systems** (also called observer, pub/sub, or message bus) let game systems
communicate without direct references. When a player takes damage, the health system
fires a `DamageTaken` event. The UI, audio, camera shake, and analytics systems each
subscribe independently. Adding a new reaction requires zero changes to the damage code.

**The command pattern** encapsulates an action as an object with `execute()` and
optionally `undo()`. Player input becomes a stream of command objects. This enables
input rebinding, replay recording, undo/redo in editors, and sending commands over
the network for multiplayer.

---

## Common tasks

### Implement a finite state machine for character behavior

Each state is a class with `enter()`, `update()`, `exit()`, and a transition check.
The machine holds the current state and delegates to it.

```typescript
interface State {
  enter(): void;
  update(dt: number): void;
  exit(): void;
}

class IdleState implements State {
  constructor(private character: Character) {}
  enter() { this.character.playAnimation("idle"); }
  update(dt: number) {
    if (this.character.input.jump) {
      this.character.fsm.transition(new JumpState(this.character));
    }
  }
  exit() {}
}

class StateMachine {
  private current: State;

  transition(next: State) {
    this.current.exit();
    this.current = next;
    this.current.enter();
  }

  update(dt: number) {
    this.current.update(dt);
  }
}
```

> Avoid string-based state names. Use typed state classes so the compiler catches
> invalid transitions.

### Build an object pool

Pre-allocate objects at startup. `acquire()` returns a recycled instance; `release()`
returns it to the pool. Never allocate during gameplay.

```typescript
class ObjectPool<T> {
  private available: T[] = [];
  private active: Set<T> = new Set();

  constructor(
    private factory: () => T,
    private reset: (obj: T) => void,
    initialSize: number
  ) {
    for (let i = 0; i < initialSize; i++) {
      this.available.push(this.factory());
    }
  }

  acquire(): T | null {
    if (this.available.length === 0) return null;
    const obj = this.available.pop()!;
    this.active.add(obj);
    return obj;
  }

  release(obj: T): void {

From mkurman/zorai, MIT.

More from mkurman/zorai

Signals

Stars
325
Forks
24
Open issues
0
Last commit (this folder)
May 5, 2026 (5 months ago)
Last release
Oct 23, 2026 (6 days ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
Website
zorai.app/
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from mkurman

Cite this page

game-design-patterns skill. Agent Mart. https://agentmart.dev/skills/mkurman-game-design-patterns (last updated 2026-10-24)