# xstate

This skill covers XState v5 machines, actors, stores, and TanStack Query integration. Use it when application logic needs explicit state flows.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 247 installs · ★ 655 repo stars
- Author: pedronauck
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/pedronauck/skills/tree/HEAD/skills/curated/xstate/SKILL.md
- Updated: 2026-10-20
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/pedronauck-xstate

## What it does

The skill guides XState v5 work with state machines and actors. It covers explicit states, events, transitions, and statechart patterns for avoiding invalid combinations. React examples use `useMachine()` and `.provide()` to adapt machine actions.

For smaller state models, it covers `@xstate/store`, event-driven updates, selectors, reactive atoms, and undo/redo. It also describes connecting XState actors with TanStack Query through `QueryObserver` and `fromCallback`. The allowed tools are `Read`, `Grep`, and `Glob`, so the skill is focused on inspecting and searching project files.

## Install

### Claude Code (native platform)

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

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

### Codex

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

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

### Cursor

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

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

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install pedronauck/skills skills/curated/xstate
```

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

### Gemini CLI

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

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

### Windsurf (Devin Desktop)

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

### OpenCode

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

## When to use it
- model a complex application flow as a state machine
- define typed XState v5 states and events
- manage lightweight client state with `@xstate/store`
- add undo and redo to a store
- coordinate TanStack Query data through XState actors

## Example prompts
- Design an XState v5 machine for an authentication flow, including its states, events, and transitions.
- Review this React component and show how to connect it with `useMachine()` and `.provide()`.
- Explain how to connect a TanStack Query subscription to an XState actor with `QueryObserver`.

## Similar
- [xstate-v5](https://affpapa.org/en/nevibecode/skills/xstate-v5.md) — skill · 546 installs
- [Orca MCP Server](https://affpapa.org/en/nevibecode/mcp/orca-mcp-server.md) — MCP server · ★ 15 repo stars
- [react-query](https://affpapa.org/en/nevibecode/skills/react-query.md) — skill · 1500 installs
- [tanstack-query](https://affpapa.org/en/nevibecode/skills/mindrally-tanstack-query.md) — skill · 766 installs
- [react-frontend-expert](https://affpapa.org/en/nevibecode/skills/react-frontend-expert.md) — skill · 208 installs
- [tanstack-query-v5-cursorrules-prompt-file](https://affpapa.org/en/nevibecode/rules/tanstack-query-v5-cursorrules-prompt-file.md) — rule · ★ 41178 repo stars

## Other versions with the same name
- [xstate · vercel-labs](https://affpapa.org/en/nevibecode/skills/xstate.md) — 1100 installs

From the same set: [pedronauck/skills](https://affpapa.org/en/nevibecode/by/pedronauck/skills.md) — 52 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
