xstate-v5
Design, implement, review, and migrate XState v5 state machines and statecharts in TypeScript using modern v5 patterns. Use this whenever the user mentions XState, actors, state machines, statecharts, guards, transitions, workflows, or Stately, or is modeling non-trivial UI/app/process logic in a codebase that uses XState. Prefer a short machine sketch before code when requirements are fuzzy. If the problem is too simple for a state machine, say so and recommend @xstate/store instead.
What this skill does
# XState v5
Use this skill for **state machine and statechart engineering first** and API correctness second.
This skill is **v5-only**. When examples, blog posts, answers, or local code smell v4-ish, translate them rather than mixing versions. Prefer local repo code and official v5 docs over generic memory.
Your job:
- choose between `xstate` and `@xstate/store`
- design a sound machine or actor system from messy requirements
- write modern XState v5 **TypeScript** code in a consistent style
- review, repair, or improve existing XState code
- migrate legacy v4-ish patterns when they appear
- choose the right actor kind and action shape when the problem is not just `assign(...)` plus `fromPromise(...)`
- connect machines and actors to `@xstate/react`, `@xstate/vue`, `@xstate/svelte`, or `@xstate/solid` when needed
## First pass
In an existing codebase:
1. Inspect local `package.json` files and imports.
2. Read nearby machines, stores, actors, and adapter usage.
3. Distinguish between new code, local edits, and migration work before choosing how opinionated to be.
4. Preserve surrounding style by default.
## Task mode
Choose a mode before writing code:
- **New code**: prefer the modern v5 patterns in this skill.
- **Local edit**: preserve local structure and naming unless the current code is mixed, broken, or cleanup was requested.
- **Migration**: prefer the **smallest safe translation** to v5. Preserve structure and semantics unless broader normalization was requested.
For migration and local edits, do not introduce `setup(...)`, named implementations, object-form guards/actions, tags, or actor decomposition unless they are required for correctness, significantly reduce local complexity, or were explicitly requested.
## Choose the tool
Prefer `@xstate/store` when the domain is simple event-based state management:
- no meaningful finite modes that need coordination, orchestration, or explicit lifecycle modeling
- no invoked async processes
- no actor communication
- no need for state machine or statechart concepts such as guarded transitions, delayed transitions, parallel states, or history
Simple fetching or mutation logic can still fit `@xstate/store` if it does not need machine-level orchestration.
Prefer XState when the domain has one or more of these:
- finite modes that matter to behavior or UI
- async workflows, retries, cancellation, or background processes
- multiple interacting processes or child actors
- explicit guards, delays, tags, or transition rules
- a need to model business process flow, not just update state
If the problem is too simple for a machine, say so plainly and recommend `@xstate/store`.
## Workflow
When requirements are fuzzy:
1. Sketch the machine shape first.
2. Name the important states, events, context, actors, and tags.
3. Call out uncertainty or tradeoffs briefly.
4. Then write the code.
When requirements are already clear, keep the sketch short or implicit and move to code.
Do not over-refactor existing code for conceptual purity. Improve the model where it matters, but preserve working structure when a larger rewrite is not justified.
## Modeling questions
Use these questions before writing or revising code:
- What are the finite states? Put **modes** in states, not in context.
- What belongs in context? Keep only durable data, not derivable booleans or duplicated mode.
- What are the domain events? Prefer meaningful names, often dot-separated, such as `form.submitted` or `order.confirmed`.
- What should be a guard versus a separate branch state?
- What side effects should be invoked actors versus transition actions?
- Can an event carry the needed data instead of stashing temporary relay data in context for a later state?
- Is `fromPromise(...)` actually the right actor, or is this a callback/subscription protocol that should send events back over time?
- Should the machine emit events to the surrounding system instead of forcing consumers to infer everything from context?
- Should a child concern be a spawned/invoked actor instead of more parent complexity?
- Does the parent really need these extra intermediate states, or should a child actor own that internal detail?
- Which states need tags for UI semantics such as `'loading'`, `'error'`, or `'dirty'`?
- Can the UI use `snapshot.matches(...)`, tags, or `snapshot.can(...)` instead of extra booleans?
## Preferred v5 patterns
For **new code**, prefer these patterns unless the local codebase has a strong reason not to:
- TypeScript only.
- Prefer `setup({...}).createMachine({...})`.
- Define named `actions`, `guards`, `actors`, and `delays` in `setup(...)`.
- Prefer transition objects like `{ target: 'next' }` over shorthand when it improves consistency.
- Prefer arrays for `actions`, even for a single action, when that keeps the shape consistent.
- Prefer action and guard objects such as `{ type: 'track' }` or `{ type: 'isValid', params: ... }` when the intent is reusable or named.
- Prefer `tags: []` for UI semantics and cross-cutting state meaning.
- Prefer domain-oriented event names; preserve local naming conventions if they are already established.
- In parallel states, keep transitions local to the region or substate whose lifecycle should change. Avoid region-root transitions that target sibling regions or use `reenter: true` unless resetting that whole source region is intentional.
- Prefer plain functions for derived values instead of storing derivable data in context.
- Prefer event payloads over temporary context relay when one state only needs to pass data to the next step.
- Prefer passing data into named actions and guards via `params` instead of reaching into `event` directly.
- Do not treat `assign(...)` as the only action pattern. For typed reusable logic beyond simple context updates, consider setup-scoped helpers from a `const machineSetup = setup(...)` object, such as `machineSetup.createAction(...)`, `machineSetup.enqueueActions(...)`, and `machineSetup.emit(...)`, or named action objects when they fit the behavior better.
- When a named `assign(...)` action updates multiple context properties, every property updater shares the same `params` type. Use one coherent params object for all updated fields, or split the work into separate named actions. Do not mix incompatible params shapes inside one assigner.
- When an implementation must inspect `event` and the type is not obvious, prefer `assertEvent(...)` for narrowing.
- Avoid `as any` and other loose casts in examples and final code unless there is no cleaner local option.
- Choose actor logic intentionally: prefer `fromPromise(...)` for one request/one result, and prefer `fromCallback(...)` for subscriptions, timers, external callbacks, and multi-event protocols that send events back over time.
- Consider `emit(...)` when the machine should notify the surrounding system directly.
- Keep parent states coarse when possible. If extra intermediate states mainly model an implementation detail, prefer letting a child actor own that internal behavior.
- If you show multiple files, wire them completely. Include real imports/exports for referenced modules and components, or keep the example smaller.
Keep event naming consistent. The `.` in event names is useful and meaningful, including for partial event descriptors and clearer domain grouping. See the official docs on [events and transitions](https://stately.ai/docs/transitions) and [TypeScript narrowing with `assertEvent(...)`](https://stately.ai/docs/typescript).
See `references/examples.md` for canonical code shapes, `references/advanced-patterns.md` when the task involves typed actions beyond `assign(...)`, callback actors, emitted events, or persistence/hydration, and `references/observables-and-inspection.md` for `fromObservable(...)`, inspection, and browser inspector patterns.
## UI integration
Prefer letting the machine drive UI behavior:
- use `snapshot.matches(...)` for finite mode checks
- use tags fRelated in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.