pattern

A guide to software design patterns in game development. A design pattern is a reusable way to structure code for a recurring problem, explained here with examples, pseudocode, trade-offs, and guidance on when to use it.

In plain words
What is it for?
Use it to learn or explain patterns such as state machines, entity-component systems, command handling, event systems, object pools, or flyweights in an engine-independent way.
Why use it?
It helps developers understand the shape and limits of a pattern before applying it. The game-focused examples make abstract code-organization ideas easier to relate to real gameplay systems.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/sponticelli/gamedev-claude-plugins/pattern
Clone the repo
git clone --depth 1 https://github.com/sponticelli/gamedev-claude-plugins
Per session 17 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 415 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00017 $0.00415
Opus 5 $0.00009 $0.00208
Sonnet 5 $0.00003 $0.00083
Haiku 4.5 $0.00002 $0.00042

Measured 2d ago against content hash b03eb1b40293, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

pattern scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/engineering/commands/pattern.md · 92 lines

What it actually says

Game Design Pattern Guide

Explain how to use a specific pattern for game development.

When the user asks about a pattern:

  1. Explain what the pattern is
  2. Show when to use it in games
  3. Provide engine-agnostic pseudocode
  4. Discuss trade-offs
  5. Give real game examples

Output Format

# Pattern: [Name]

## What It Is
[2-3 sentences explaining the core concept]

## When to Use in Games
- [Use case 1]
- [Use case 2]
- [Use case 3]

## When NOT to Use
- [Anti-pattern 1]
- [Anti-pattern 2]

## Implementation

### Core Structure
```pseudo
// Engine-agnostic pseudocode
class [PatternName] {
    // Key elements
}

Game Development Example

// Specific game example

Trade-offs

Pros

  • [Advantage 1]
  • [Advantage 2]

Cons

  • [Disadvantage 1]
  • [Disadvantage 2]

Real-World Examples

  • [Game] uses this for [feature]
  • [Game] uses this for [feature]

Common Mistakes

  • [Mistake 1]: [Why it's wrong]
  • [Mistake 2]: [Why it's wrong]
  • [Pattern A] - [Relationship]
  • [Pattern B] - [Relationship]

## Common Patterns to Cover

- State Machine
- Component/Entity-Component-System
- Command Pattern
- Observer/Event System
- Object Pool
- Flyweight
- Service Locator
- Factory
- Strategy
- Singleton (and why to avoid it)
- Double Buffer
- Game Loop
- Update Method
- Dirty Flag
- Spatial Partition

Explain the pattern the user asks about.
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 92 lines · 17 tokens per session scan A b03eb1b40293

Subscribe to this mod's changes

pattern is a command published in the GitHub repository sponticelli/gamedev-claude-plugins (14 stars, last pushed 7mo ago), licensed MIT. It adds 17 tokens to every session and 415 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.