state-machine

state-machine is a skill for Claude Code from jame581/GodotPrompter. It costs 26 tokens per session (3,496 once invoked), scanned A, original, MIT.

A guide to state machines, which organise an object's behaviour into named modes such as idle, walking, attacking, or stunned. It explains enum-based, node-based, and resource-based approaches in Godot.

In plain words
What is it for?
Use it to build character behaviour, enemy AI, dialogue flows, animation states, or ability restrictions in Godot.
Why use it?
It helps prevent behaviour code from becoming a tangled set of conditions. You can choose a structure that matches the number and complexity of your states.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the godot-prompter plugin — 61 skills, 9 agents, 2 hooks shipped together

Good fit Use it to build character behaviour, enemy AI, dialogue flows, animation states, or ability restrictions in Godot.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/jame581/godotprompter/state-machine
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.

Any agent
npx skills add jame581/GodotPrompter --skill state-machine
Clone the repo
git clone --depth 1 https://github.com/jame581/GodotPrompter

Made for: Claude Code.

Or install godot-prompter, the plugin that ships this one along with the rest of its 61 skills, 9 agents, 2 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for state-machine

README.md
[![agentmods](https://agentmods.dev/badge/skills/jame581/godotprompter/state-machine/github.svg)](https://agentmods.dev/skills/jame581/godotprompter/state-machine)
Your own site
<a href="https://agentmods.dev/skills/jame581/godotprompter/state-machine"><img src="https://agentmods.dev/badge/skills/jame581/godotprompter/state-machine/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for state-machine

Your own site · 80×15
<a href="https://agentmods.dev/skills/jame581/godotprompter/state-machine"><img src="https://agentmods.dev/badge/skills/jame581/godotprompter/state-machine.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 26 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,496 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.1 $0.00026 $0.03496
Opus 5.5 $0.00010 $0.01398
Sonnet 5.5 $0.00005 $0.00699
Haiku 4.5 $0.00003 $0.00350

Measured 15d ago against content hash f3c618914328, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

state-machine 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 15d 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.

skills/state-machine/SKILL.md · 495 lines

How it starts

The opening of the file, as written. The whole thing — 495 lines — stays where its author put it; the contents beside it link to each section on GitHub.

State Machines in Godot 4.3+

Choose the right FSM pattern for your complexity level. All examples target Godot 4.3+ with no deprecated APIs.

Related skills: player-controller for movement state integration, ai-navigation for AI state patterns, resource-pattern for resource-based state configuration, animation-system for AnimationTree states driven by FSM, dialogue-system for dialogue flow as a state machine, ability-system for caster state gating (casting/stunned), limboai for the LimboAI addon's HSM (BTState) if you need a behavior tree alongside your FSM, beehave for a GDScript-only BT alternative.

When to reach for an addon: This skill covers the built-in FSM patterns (enum, node-based, resource-based). If your agent needs a full behavior tree, see limboai (C++ + HSM, Godot 4.6+) or beehave (pure GDScript, Godot 4.1+) instead.


1. Approach Comparison

Approach Complexity Best For
Enum-Based Low Simple objects, fewer than 5 states
Node-Based Medium Characters with complex behavior
Resource-Based High Data-driven or editor-configurable AI

When you recommend one, name the approach you rejected and the factor that decided it (state count, independent concerns, designer editing) — "node-based, not an enum with match, because seven states with their own enter/exit logic outgrow one script". A pick with no named alternative cannot be overruled.


2. Approach 1: Enum-Based (Simplest)

Use when you have a small number of states and no significant enter/exit logic.

GDScript

extends CharacterBody2D

enum State { IDLE, PATROL, CHASE, ATTACK }

@export var patrol_range: float = 200.0
@export var chase_range: float = 300.0
@export var attack_range: float = 50.0
@export var speed: float = 80.0

var current_state: State = State.IDLE
var patrol_target: Vector2 = Vector2.ZERO

@onready var player: Node2D = get_tree().get_first_node_in_group("player")


func _physics_process(delta: float) -> void:
	match current_state:
		State.IDLE:
			_state_idle()
		State.PATROL:
			_state_patrol()
		State.CHASE:
			_state_chase()
		State.ATTACK:
			_state_attack()

	move_and_slide()


func _state_idle() -> void:
	velocity = Vector2.ZERO
	if _player_in_range(chase_range):
		current_state = State.CHASE
	elif randf() < 0.005:
		patrol_target = global_position + Vector2(randf_range(-patrol_range, patrol_range), 0.0)
		current_state = State.PATROL


func _state_patrol() -> void:
	var direction := (patrol_target - global_position)
	if direction.length() < 4.0:
		current_state = State.IDLE
		return
	velocity = direction.normalized() * speed
	if _player_in_range(chase_range):
		current_state = State.CHASE


func _state_chase() -> void:
	if not is_instance_valid(player):
		current_state = State.IDLE
		return
	if _player_in_range(attack_range):
		current_state = State.ATTACK
		return
	if not _player_in_range(chase_range):
		current_state = State.PATROL
		return
	velocity = (player.global_position - global_position).normalized() * speed


func _state_attack() -> void:
	velocity = Vector2.ZERO
	if not _player_in_range(attack_range):
		current_state = State.CHASE


func _player_in_range(range: float) -> bool:
	if not is_instance_valid(player):
		return false
	return global_position.distance_to(player.global_position) <= range

Read the full file on GitHub · 495 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 15d ago Changed · +3 lines f3c618914328
  2. 1mo ago First seen · 492 lines · 26 tokens per session scan A 2aa1e3eacd63

Subscribe to this mod's changes

state-machine is a skill published in the GitHub repository jame581/GodotPrompter (882 stars, last pushed 4d ago), licensed MIT. It adds 26 tokens to every session and 3,496 once invoked, about $0.0001 per session on Opus 5.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-09-03.

Related

Other skills, from other repositories

godot-csharp

Use C#/.NET in Godot 4.7: partial classes extending nodes, the PascalCase lifecycle (Ready/Process/PhysicsProcess), [Export] fields, [Signal] delegates as C# events, type-safe node lookup, and calling between C# and GDScript. Use when writing Godot game code in C# (.cs files, .csproj), needing the Godot .NET build…

gamedev-skills/awesome-gamedev-agent-skills · 108 tokens

unity-csharp-scripting

Write Unity 6.3 LTS C# gameplay scripts: the MonoBehaviour lifecycle (Awake/OnEnable/Start/Update/FixedUpdate/LateUpdate), GameObject and component access, coroutines, and Inspector serialization. Use when creating or editing .cs scripts in a Unity project, or when the user mentions MonoBehaviour, Start/Update…

gamedev-skills/awesome-gamedev-agent-skills · 92 tokens

unity-pipeline

Drive a running Unity Editor or development Player from the command line via the unity-pipeline package — install the package, keep the editor ticking while unfocused, run the edit→recompile→runtests loop, evaluate C#, and hot-reload files at runtime. Use when an agent needs to control a live Unity instance, automate…

Alex-Rachel/TEngine · 97 tokens

html-to-ugui

A pipeline for turning HTML interface prototypes into Unity UGUI Prefabs, which are reusable Unity interface objects. It uses browser-rendered layout data to preserve positions, images, text, controls, and device-adaptation intentions.

Alex-Rachel/TEngine · 75 tokens

luban-dev

A guide for Luban, a game-configuration tool that turns spreadsheets and schemas into C# code and binary data for a TEngine project.

Alex-Rachel/TEngine · 62 tokens

tengine-dev

A development guide for TEngine, a framework used to build Unity games. It covers the framework’s modules, user interfaces, events, asset loading, hot updates, configuration, and related tools.

Alex-Rachel/TEngine · 76 tokens