Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

generate-machine

БесплатноБез исполняемых скриптовНе проверен

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…

statelyaiот statelyai★ 86 звёзд на GitHub

Об этом скилле

Generate an agent machine

Targets @statelyai/agent 2.0 alpha, as on the next branch. APIs change between alphas: when a call here does not match the installed package, check node_modules/@statelyai/agent/CHANGELOG.md.

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.

split environment/policy → author (description = goal) → verifyAgentConfig → repair (≤ 3) → persist traces → hand back

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 / explorePaths from @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 AgentWorkflowConfig you 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:

import { describeMachine } from "@statelyai/agent";
const text = describeMachine(machine); // "Machine <id>", then "Goal: …", states, transitions, events

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/agent repo: 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":

"description": "Resolve each support ticket in one session. Success: escalations only for tickets that need a human; every reply approved before sending; at most 2 model calls per ticket."

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 on input, context, or event. No JavaScript.
  • Guard expressions are truthy-only: no comparisons, operators, or negation.
  • A model call is either a named requests entry invoked with src: "<requestName>", or an inline invoke with src: "agent.decide" plus an allowedEvents list. A requests entry's templates read only its own input ("{{ input.ticket }}"); the invoke's input maps context into it.
  • A state invoking agent.decide MUST handle every allowed event in its on.
  • An agent.decide invoke has no onDone (a decision produces no output). Use onError for the retries-exhausted path.
  • A request invoke resolves with { result, messages }, so onDone.assign reads its result from "{{ event.output.result.<field> }}" ("{{ event.output.result }}" for a plain-text request). A non-request actors invoke reads "{{ event.output.<field> }}" directly.
  • Every path must reach a "type": "final" state, and each final state needs an output when schemas.output is declared.
  • Do not invent guard or action names. Only "{{ }}" guards, assign, and emit exist 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 payloads to the agent.decide input: one payload list per event type, without type ("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.interaction for the host to render with getInteraction: a label, events (one button per event type), choices (one button per full event, `{ "label": "Refund $20", "even
Полный SKILL.md на GitHub

Установить generate-machine в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл generate-machine?

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.

Как установить скилл generate-machine?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл generate-machine запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить generate-machine с