/harness-claude:xstate-machine-definitionfrom harness-claude
Defines XState statecharts with createMachine for explicit states, transitions, context, and events. Useful for modeling complex UI flows and replacing boolean flag soup.
Claude never picks this skill on its own
Its frontmatter has no description. Without a description, Claude Code leaves it out of the list Claude chooses from. Typing /harness-claude:xstate-machine-definition still runs it.
What the skill costs in Claude's context, stage by stage
No description Claude Code can read, so Claude's list leaves it out: only you can start it.
SKILL.md joins the conversation and stays.
Define statecharts with createMachine for explicit states, transitions, context, and events
isLoading && !isError && isSubmitted) with named states.machine.ts file. Keep it separate from UI components.Context (extended state data) and Events (a discriminated union of all possible events).createMachine with id, initial, context, and states. Each state has on for transitions.idle, loading, error), not verbs.SUBMITTED, LOADED, ERRORED) or imperative commands (SUBMIT, RETRY).target for the destination state. Omit target for self-transitions that only run actions.// auth.machine.ts
import { createMachine, assign } from 'xstate';
interface AuthContext {
user: { id: string; name: string } | null;
error: string | null;
retries: number;
}
type AuthEvent =
| { type: 'LOGIN'; email: string; password: string }
| { type: 'LOGOUT' }
| { type: 'RETRY' }
| { type: 'done.invoke.authenticate'; data: { id: string; name: string } }
| { type: 'error.platform.authenticate'; data: Error };
const authMachine = createMachine<AuthContext, AuthEvent>({
id: 'auth',
initial: 'idle',
context: {
user: null,
error: null,
retries: 0,
},
states: {
idle: {
on: {
LOGIN: 'authenticating',
},
},
authenticating: {
invoke: {
id: 'authenticate',
src: 'authenticateUser',
onDone: {
target: 'authenticated',
actions: assign({ user: (_, event) => event.data, error: null }),
},
onError: {
target: 'error',
actions: assign({
error: (_, event) => event.data.message,
retries: (ctx) => ctx.retries + 1,
}),
},
},
},
authenticated: {
on: {
LOGOUT: {
target: 'idle',
actions: assign({ user: null }),
},
},
},
error: {
on: {
RETRY: {
target: 'authenticating',
guard: 'canRetry',
},
LOGIN: 'authenticating',
},
},
},
});
export { authMachine };
Context vs state: "State" in XState means the finite state node (idle, loading, error). "Context" is the extended state — arbitrary data that travels with the machine. Use finite states for mode/phase, context for data.
XState v5 changes: If using XState v5, the API shifts to setup().createMachine() with a different structure:
import { setup, assign } from 'xstate';
const machine = setup({
types: {} as {
context: AuthContext;
events: AuthEvent;
},
guards: { canRetry: ({ context }) => context.retries < 3 },
actions: { clearUser: assign({ user: null }) },
}).createMachine({
id: 'auth',
initial: 'idle',
context: { user: null, error: null, retries: 0 },
states: {
/* ... */
},
});
State node types:
atomic — leaf node, no child states (default)compound — has child states (nested)parallel — all child states active simultaneouslyfinal — terminal state, triggers onDone in the parenthistory — remembers the last active child stateDesign principles:
https://stately.ai/docs/machines
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeRead when SKILL.md points to them.
793 skills in this plugin
/a11y-aria-patternsARIA Patterns> Apply ARIA roles, states, and properties correctly to enhance assistive technology support for custom widgets/a11y-color-contrastColor Contrast and Color Independence> Ensure sufficient color contrast ratios and never use color as the sole means of conveying information/a11y-form-patternsAccessible Form Patterns> Build accessible forms with proper labeling, grouped controls, inline validation, and clear error communicationOther plugins' skills for the same job