agentleFS
nick-vasnick-vas/hyperdot/.agents/skills/patterns/SKILL.md

patterns

Skill1 starsChanged yesterdayApache-2.0View on GitHub

Use when structuring a new Godot game or system, separating gameplay rules and state from visuals, or when a design question names a pattern such as state machine, object pool, event bus, singleton or component.

17 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use setup.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • VercelSkill

    setup

    Set up Vercel CLI and project configuration. Use when the user says "set up Vercel", "configure Vercel", "link to Vercel", or "vercel init".

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 13 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep gameplay deterministic, testable without a renderer and easy for an agent to verify: run it in the simplest space that works, and …

    line 14
  2. Very specific:

    Run state (RunState, the map, encounters) as plain C# classes owned by one autoload, not spread over nodes.

    line 26
  3. Very specific:

    Singleton: put the run's state in plain C# classes owned by one autoload (State in plain C#, above), so it is testable without Godot.

    line 68

“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Game programming patterns in Godot 4

Robert Nystrom's Game Programming Patterns (gameprogrammingpatterns.com) names the problems games keep solving. Godot already solves many of them; reach for the engine first, add a pattern when the problem actually shows up, and never for its own sake. Each row links the book's chapter; the summaries are ours.

Simulate simple, present rich

Keep gameplay deterministic, testable without a renderer and easy for an agent to verify: run it in the simplest space that works, and mirror it onto the visuals every frame.

  • Physics and rules in 2D (CharacterBody2D with MoveAndCollide, one-way platforms), presentation in 3D: a view node copies positions with a fixed scale (40 px = 1 m). Visual styles become swappable, and gameplay stays deterministic and testable headless.
  • A Visual wrapper owns flash, tint and squash for every actor, so effects are added in one place.
  • Style definitions (stage, actors, colour grade) as data classes, so a level's look is a value, not a scene fork.
  • Visuals mirror state; nothing in a visual decides gameplay.

State in plain C#

Run state (RunState, the map, encounters) as plain C# classes owned by one autoload, not spread over nodes. Plain classes are testable with xUnit in milliseconds (godot-test-loop), can be saved by serialising one object, and survive scene changes. Nodes read state and send intents; they do not own the rules. Every random decision comes from a seeded, per-decision generator (procgen).

What Godot gives you, and when to add your own

PatternGodot already hasAdd it yourself whenNot when
CommandInputMap actions; UndoRedoyou need replays, undo, AI and player sharing one action type, or input recorded for a bota button just calls a method
Flyweightshared Resources (a .tres loads once); MultiMeshthousands of instances share data (tiles, foliage, bullets)local_to_scene or Duplicate() on resources that never change
Observersignals; C# eventsa child reports up, or many systems react to one eventthe caller needs a result back: call a method
PrototypePackedScene.Instantiate(); Resource.Duplicate()you spawn variants of a configured template-
Singletonautoloadsstate must outlive scene changes (the run, settings, save)as a shortcut to reach any node; keep autoloads few (too-many-autoloads)
StateAnimationTree state machine (animation only)behaviour depends on mode: an enum and match/switch for a few states, a class per state for manytwo booleans would do
Double Bufferthe rendererevery entity must read last tick's state while writing this tick's (cellular automata, simultaneous moves)updates are naturally sequential
Game Loopthe engine; _PhysicsProcess at a fixed ratenever; tune physics_ticks_per_second, and --fixed-fps for bots-
Update Method_Process per nodethousands of similar entities: one manager loops plain data insteada node is idle: SetProcess(false)
BytecodeGDScript; the Expression classdesigners or mods script behaviour safely at runtimedata in Resources is enough
Subclass Sandboxinheritance in C# and GDScriptmany similar behaviours (abilities, power-ups) share helpers in one base classcomposition fits better: Component
Type Objectcustom Resource types with [Export] fieldscontent types (enemy kinds, items) should be data, not classesthere are two kinds
Componentnode composition; scenesan entity mixes reusable behaviours (health, hitbox, loot) as child nodesone script stays small and clear
Event QueueCallDeferred; deferred signal connectionsa sender must not wait for, or be re-entered by, the handler (audio requests, achievements)the reaction must happen now
Service Locatorautoloadstests or modes swap an implementation (audio, saves) behind an interfacethe dependency can be passed in
Data LocalityMultiMesh; the servers (RenderingServer, PhysicsServer2D)thousands of objects per frame: arrays of C# structs, no node eacha few hundred nodes are fine
Dirty Flagglobal transforms are cached this waya derived value is costly (UI text, paths, layout): recompute only when its input changedthe value is cheap
Object Poolnonemany short-lived objects (bullets, particles, damage numbers) and creating them hitchescreating them does not show in bench
Spatial Partitionthe physics broadphase; Area2D/Area3D; space-state queriesmany non-physics proximity queries per frame: a uniform gridphysics queries answer it

Turns as named phases

A turn-based game (cards, tactics, board games, a battle menu) writes its turn as named phases in a plain class: an enum such as Draw, Main, Combat, End and one method that moves to the next, rather than booleans scattered over nodes. Each transition is a rule (Combat only after Main; End discards and passes play; a phase with nothing to do is skipped), and each gets a test: start in one phase, act, assert the next phase and what it changed. Log every transition ([Turn] 3 Main -> Combat), so a replay or a bug report shows where a turn went wrong, and let nodes animate a phase change, never decide one.

Godot-specific consequences

  • Observer: C# events and lambdas on an autoload outlive the node that subscribed: unsubscribe in _ExitTree (event-not-unsubscribed). In GDScript, a signal connected to a lambda is not dropped when its node is freed either.
  • Singleton: put the run's state in plain C# classes owned by one autoload (State in plain C#, above), so it is testable without Godot; UI sends intents to it rather than writing its fields (ui-mutates-state).
  • Component: reach siblings through exported NodePaths or %UniqueName, not ../.. (parent-path).
  • Object Pool: pooled nodes kept off the tree are orphans; free the pool in _ExitTree, or the orphan count climbs and every scene change leaks. Pre-warm the pool before gameplay so the first use does not hitch (performance).
  • Update Method / Data Locality: find nodes once in _Ready, never in _Process (per-frame-lookup); allocate nothing per frame in C# (per-frame-alloc). Far from the player, run the simulation as plain data at a lower rate and give actors nodes only near the player (A-Life's offline mode); every AI system that runs this way gets a debug view, pause and time scale.

The names in brackets are the architecture runner's rules, which warn when the code drifts from these. A change that adds a system, an autoload or a dependency between scenes goes to the godot-architect subagent first, which records the decision.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.