statelyai/agent/generate-machine
Claude Code and agent skill by statelyai/agent
- community
Checking that the SKILL.md file is still in the repository.
Author a @statelyai/agent workflow as JSON and check it before it runs. Use when asked to generate or author an agent machine, create a workflow config, write an AgentWorkflowConfig, or produce an LLM-authored state machine for an agent — and when a generated config fails verifyAgentConfig, Ajv validation, or agent lint and needs repair.
Install
npx vskill@latest install statelyai/agent/generate-machineSKILL.md
Generate an agent machine
An agent machine is data. You author a JSON AgentWorkflowConfig, then run it through verifyAgentConfig, whose gates all work with no API key: validate → vocabulary → lower → lint → explore. Do not hand back a config that has not passed every gate.
To improve an existing policy from its traces, use the improve-machine skill instead.
0. Split environment and policy
Decide what is fixed before you write any JSON.
- Environment (TypeScript, fixed): the rules of the world and the business invariants, as states and guards. People author it and verify it with
canReach/explorePathsfrom@statelyai/agent/testing. You never generate it, and no generated config may change it. - Policy (JSON, generated): how the agent works toward the goal: which step next, which tool, when to ask a person, cheap judgment vs model call. This is the
AgentWorkflowConfigyou author. - The policy plugs into the environment at its decision points and outputs one event; the environment's guards decide whether to accept it.
- No split needed for a single judgment inside a fixed workflow, or for a workflow where every step is dictated by rules. Author one machine.
If the request asks you to generate a business rule (an approval threshold, a payout limit), stop: that belongs in the environment, in TypeScript, reviewed by a person. Say so.
Before editing an existing machine, read it as text:
Pass { snapshot } to mark the active states with *. Concept page: Environment and policy.
1. Read the schema
The config shape is fixed by a shipped JSON Schema. Read it first; it is the contract.
- Consuming the package:
node_modules/@statelyai/agent/schemas/agent-workflow.json(importable as@statelyai/agent/agent-workflow.json) - In the
statelyai/agentrepo:schemas/agent-workflow.json
2. Author the config
Start with the root description: it is the machine's goal, the overall objective plus measurable success criteria. describeMachine renders it first as Goal: …, and an improver later climbs toward it. Write criteria a scorer can compute from outcomes (terminal states, effects in the world, cost), not "be helpful":
Rules the runtime enforces. Each one maps to a build error or a lint diagnostic:
- Every value is a JSON literal or a whole-string
"{{ }}"expression reading a dot path oninput,context, orevent. No JavaScript. - Guard expressions are truthy-only: no comparisons, operators, or negation.
- A model call is either a named
requestsentry invoked withsrc: "<requestName>", or an inline invoke withsrc: "agent.decide"plus anallowedEventslist. Arequestsentry's templates read only its owninput("{{ input.ticket }}"); the invoke'sinputmaps context into it. - A state invoking
agent.decideMUST handle every allowed event in itson. - An
agent.decideinvoke has noonDone(a decision produces no output). UseonErrorfor the retries-exhausted path. - A request invoke resolves with
{ result, messages }, soonDone.assignreads its result from"{{ event.output.result.<field> }}"("{{ event.output.result }}"for a plain-text request). A non-requestactorsinvoke reads"{{ event.output.<field> }}"directly. - Every path must reach a
"type": "final"state, and each final state needs anoutputwhenschemas.outputis declared. - Do not invent guard or action names. Only
"{{ }}"guards,assign, andemitexist unless the host tells you which named guards/actions it implements. - Model refs are strings (
"openai/gpt-6-luna"); the host resolves them. - To make a decision a closed choice, add
payloadsto theagent.decideinput: one payload list per event type, withouttype("payloads": { "REFUND": [{ "amount": 20 }, { "amount": 50 }], "ESCALATE": [] }). The model then picks one listed event instead of writing a payload. A type with no key is offered as{ type };[]withholds it. - An idle human step can carry
meta.interactionfor the host to render withgetInteraction: alabel,events(one button per event type),choices(one button per full event,{ "label": "Refund $20", "event": { "type": "REFUND", "amount": 20 } }, or a context path string holding such a list), andtextEventfor free text. A bare"textEvent": "REJECT"puts the text in atextfield;{ "type": "REJECT", "field": "reason" }names the field.metais not template-evaluated.
Reference config — decision, text request, idle human step, one final state:
3. Verify with verifyAgentConfig
verifyAgentConfig(config, options) from @statelyai/agent/validate runs every pre-run gate and stops at the first failure. It never throws on a bad config; each gate is a record { name, ok, detail? }. It needs ajv installed (an optional peer of the package).
| Gate | Checks with | Fails on | |
|---|---|---|---|
validate | validateAgentConfig (shipped schema) | malformed config shape | |
vocabulary | allow lists | an invoke src, named guard, named action, agent.decide event, or model ref not listed | |
lower | setupAgent.fromConfig | unresolved named guard/action, onDone on an agent.decide invoke | |
lint | lintAgentMachine | error findings (warnings too with lint: { warnings: true }) | |
explore | explorePaths, once per input | a path ending outside explore.terminals (default ['done']), a loop past maxDepth, a maxPaths/maxNodes cap, untried payloads (unexpandedEvents) |
compileSchema turns the JSON Schemas _inside_ the config into Standard Schema validators for fromConfig. The library bundles no JSON Schema engine:
Run the gates. List the host's real names in allow; an omitted key is unrestricted:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/generate-machine/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/statelyai/agent/generate-machine)