# godot-state-machine-advanced

A Godot skill for hierarchical finite state machines and pushdown automata: ready scripts for sub-states, state stacks and transition validation.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 486 installs · ★ 893
- Author: thedivergentai
- License: LGPL-3.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/thedivergentai/Game-Dev-Agentic-Skills/tree/HEAD/skills/godot-state-machine-advanced/SKILL.md
- Updated: 2026-10-16
- HTML: https://affpapa.org/en/nevibecode/skills/godot-state-machine-advanced

## What it does

The skill ships a set of GDScript files for complex character and AI behavior in Godot. You get a hierarchical base that forwards physics and input down to sub-states, a pushdown stack for interrupt overlays like pause or menus, a context object for passing data between states, a guard that blocks illegal transitions, an AnimationTree syncer, concurrent state machines, a loader that reads state definitions from `.tres` resources, a history logger and an auto-transition timer.

A decision tree maps the need to the machine: flat FSM, HSM, pushdown, concurrent or utility cost polling. The scripts are declared the source of truth, and copying inline samples is discouraged because an earlier body called `exit()` twice and dropped resume messages. For hierarchy, pushdown and guards you are told to read `hsm_hierarchical_base.gd`, `hsm_pushdown_stack.gd` and `hsm_transition_guard.gd`.

Depth is the hard limit. Nesting beyond three levels is called state spaghetti, and the skill points you toward a behavior tree or utility AI instead. Every `push_state` needs a matching `pop_state` or the stack overflows. The license is LGPL-3.0, so if you ship a closed-source game, check what that means before the code goes into a release build.

## Requirements
- Works with: Godot

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill godot-state-machine-advanced -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/godot-state-machine-advanced/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/godot-state-machine-advanced/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill godot-state-machine-advanced -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/godot-state-machine-advanced/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill godot-state-machine-advanced -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/godot-state-machine-advanced/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install thedivergentai/Game-Dev-Agentic-Skills godot-state-machine-advanced
```

2. **Manually: put the files in place**
- File: `.github/skills/godot-state-machine-advanced/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill godot-state-machine-advanced -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/thedivergentai/Game-Dev-Agentic-Skills --path skills/godot-state-machine-advanced
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/godot-state-machine-advanced/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill godot-state-machine-advanced -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/thedivergentai/Game-Dev-Agentic-Skills/tree/HEAD/skills/godot-state-machine-advanced/SKILL.md

## When to use it
- split character movement into nested Move, Air and Attack states
- stack a pause or dialogue overlay on top of combat and resume it later
- block a transition that would break animation or timer logic
- pass health and parameters between states without global singletons
- keep state logic in sync with AnimationTree

## Example prompts
- Build an HSM for the player: a base state with Move, Air and Attack children, forwarding physics to them
- Add a pushdown stack so the menu pauses combat and resumes with the is_resume flag
- Set up a guard that blocks the Dash transition while Stun is active

## Similar
- [godot-nodes-scenes](https://affpapa.org/en/nevibecode/skills/godot-nodes-scenes.md) — skill · 6400 installs
- [cli-anything-godot](https://affpapa.org/en/nevibecode/skills/cli-anything-godot.md) — skill · 548 installs
- [godot-ui-control](https://affpapa.org/en/nevibecode/skills/godot-ui-control.md) — skill · 6700 installs
- [godot-best-practices](https://affpapa.org/en/nevibecode/skills/godot-best-practices.md) — skill · 2100 installs
- [godot-prompter](https://affpapa.org/en/nevibecode/plugins/godot-prompter.md) — plugin · ★ 867
- [godot](https://affpapa.org/en/nevibecode/rules/godot.md) — rule · ★ 3579

From the same set: [thedivergentai/game-dev-agentic-skills](https://affpapa.org/en/nevibecode/by/thedivergentai/game-dev-agentic-skills.md) — 51 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
