# xstate-v5

Guides an agent through building, reviewing and porting XState v5 machines and statecharts in TypeScript. Useful once screen or process logic outgrows a couple of booleans.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 494 installs · ★ 48
- Author: statelyai
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/statelyai/skills/tree/HEAD/skills/xstate-v5/SKILL.md
- Updated: 2026-05-22
- HTML: https://affpapa.org/en/nevibecode/skills/xstate-v5

## What it does

The skill puts machine engineering first and API correctness second. The agent picks between `xstate` and `@xstate/store`, turns messy requirements into a model, writes v5-style code, and works over what already exists. Old examples and v4-flavoured code get translated instead of copied.

What sits inside is a set of rules, not a code generator. The agent starts from `package.json` and imports, reads nearby machines and adapters, then decides how opinionated to be. New code gets `setup({...}).createMachine({...})` with named `actions`, `guards`, `actors` and `delays`. Edits to an existing file keep the local structure. Migration is the smallest safe translation to v5, without dragging `setup(...)` and tags into places that do not need them.

This is v5 only. The agent will not mix versions in one file, so a codebase with machines still on v4 means a gradual port rather than one large commit. When a problem is too small for a machine, the agent says so and points to `@xstate/store`.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add statelyai/skills --skill xstate-v5 -a claude-code
```

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

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add statelyai/skills --skill xstate-v5 -a codex
```

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

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add statelyai/skills --skill xstate-v5 -a cursor
```

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

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install statelyai/skills xstate-v5
```

2. **Manually: put the files in place**
- File: `.github/skills/xstate-v5/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add statelyai/skills --skill xstate-v5 -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/statelyai/skills --path skills/xstate-v5
```

### Windsurf (Devin Desktop)

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

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add statelyai/skills --skill xstate-v5 -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/statelyai/skills/tree/HEAD/skills/xstate-v5/SKILL.md

## When to use it
- turn vague requirements into a state machine design
- port a v4 machine to v5 without changing semantics
- split an async workflow into actors with cancellation
- replace redundant context booleans with tags
- wire a machine into `@xstate/react` or `@xstate/vue`

## Example prompts
- Design a checkout state machine: states, events, actors
- Port this machine to XState v5 and keep the structure
- Review `checkoutMachine.ts` — should some context move into tags?

## Similar
- [frontend-design](https://affpapa.org/en/nevibecode/skills/frontend-design.md) — skill · 1025790 installs
- [design-taste-frontend](https://affpapa.org/en/nevibecode/skills/design-taste-frontend.md) — skill · 678700 installs
- [prototype](https://affpapa.org/en/nevibecode/skills/prototype.md) — skill · 986201 installs
- [hyperframes](https://affpapa.org/en/nevibecode/skills/heygen-com-hyperframes.md) — skill · 1200000 installs
- [hyperframes-cli](https://affpapa.org/en/nevibecode/skills/heygen-com-hyperframes-cli.md) — skill · 1300000 installs
- [webapp-testing](https://affpapa.org/en/nevibecode/skills/webapp-testing.md) — skill · 186758 installs

---
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
