Workflow File
workflow.yaml
Key | Required | Purpose |
---|---|---|
version | ✓ | Declare workflow schema version (default: "1" ). |
state | Declares shared-state schema. | |
templates | Re-usable blocks. | |
nodes | ✓ | Executable DAG. |
Shared State
Nodes & Steps
Nodes
Nodes are execution units in your workflow. They can be automatic or manual, depend on other nodes, and may define strategy (e.g., matrix), trigger, runtime, env, and an ordered list of steps.Unique within the workflow.
Display name.
automatic
(default) or manual
.Upstream node IDs.
{ type: manual }
→ approval gate.Matrix configuration.
Ordered list of steps.
Container/runtime configuration (e.g., Docker).
Environment variables for the node or step.
Step
Steps are the atomic actions inside a node; they run sequentially and each step performs one action All step types support the following field:Conditional expression to gate the step.
if
is evaluated before executing any step type.Expression evaluation supports referencing params.x
and state.x
, and any matrix value keys (injected as-is). Supported operators include ==
, !=
, >
, <
, &&
, and ||
.Example: params.autoAIReview
.See Variable resolution for the full expression and interpolation grammar.Shell command step
Shell command step
YAML ast-grep step
YAML ast-grep step
Executes ast-grep using a YAML config. Use for fast, declarative pattern matching and structured find/replace.
Path to the ast-grep configuration file (.yaml).
Include glob patterns.
Exclude glob patterns.
Base path for resolving globs.
Maximum concurrent threads.
JS ast-grep (jssg) step
JS ast-grep (jssg) step
Runs a TypeScript/JavaScript codemod powered by ast-grep. Use when you need programmatic logic beyond YAML rules.
Path to the JS/TS file that implements the codemod.
Target language (e.g.,
typescript
, javascript
, etc.).Include glob patterns.
Exclude glob patterns.
Base path for resolving globs.
Maximum concurrent threads.
Perform a dry run without applying changes.
Codemod Registry step
Codemod Registry step
Runs another codemod by package name (or local path). Use to compose larger migrations by chaining codemods.
Codemod source (registry package or local path).
CLI arguments passed to the codemod.
Environment variables used during execution.
Working directory for execution.
Step-level environment variables. For
codemod
steps, these are forwarded to the invoked workflow as parameters with an env_
prefix (e.g., FOO
→ env_FOO
). They are not applied to the OS environment of the nested workflow.AI step
AI step
Calls an AI agent with a prompt. Use for generating change plans or reviews; validate outputs and prefer dry runs in critical paths.
Prompt to send to the AI agent.
Model identifier. Overrides
LLM_MODEL
if set.System prompt to scope the AI agent’s behavior.
Maximum number of agent steps before stopping.
LLM provider/protocol. Supported:
openai
, anthropic
, azure_openai
.LLM base URL. If omitted, defaults to the provider’s standard endpoint for the selected protocol. You can override with a custom endpoint.
API key to access the LLM.The AI step requires valid LLM credentials. Provide them via environment variables:
LLM_BASE_URL is optional. If omitted, defaults to the provider’s standard endpoint for the selected protocol. You can override with a custom endpoint.
Matrix Strategy
Dynamic Matrix Task Recompilation
Dynamic Matrix Task Recompilation
When the array referenced by
from_state
changes, Codemod CLI:- Creates new tasks for new items.
- Marks tasks as
WontDo
if their item is removed. - Leaves existing tasks untouched if their item remains.
Matrix nodes have a master task that tracks the status of all generated tasks.
Manual Trigger
Task UUIDs & Resume
Task UUIDs & Resume
Manual tasks are assigned unique UUIDs. You can resume:
-
All paused tasks:
-
A specific task:
State Updates
Syntax | Meaning | Example |
---|---|---|
KEY=VAL | Set state key to value | count=10 |
KEY@=VAL | Append value to array at state key | shards@={"team":"core","shardId":"1"} |
Dot notation | Set nested state fields | config.retries=5 |
JSON values | Use valid JSON for objects/arrays | user={"name":"Alice","id":123} |
All state updates must be valid JSON if not a primitive. Updates are applied only if the task exits successfully.
Container Runtimes
Container Runtimes
Planned feature: containerized execution (e.g., Docker/Podman). Currently, workflows run in the host shell. When available, you’ll be able to specify a runtime per node or template.
State Management & Persistence
State Management & Persistence
Workflow state is persisted after every task. If interrupted, you can resume from the last saved state—no work is lost.
Matrix Master Task
Matrix Master Task
For matrix nodes, a master task aggregates the status of all generated tasks.
If all child tasks complete, the master is
If all child tasks complete, the master is
Completed
. If any fail, the master is Failed
.Cyclic Dependency Example
Cyclic Dependency Example
If your workflow has a cycle:You’ll see:
This error is shown when you run
npx codemod workflow validate
or npx codemod workflow run
on a workflow with a cyclic dependency.Task Statuses
Pending
Queued; waiting for runner.
Running
Currently executing.
Completed
Succeeded; diff applied.
Failed
Script exited non-zero; diff discarded.
AwaitingTrigger
Waiting for manual approval.
Blocked
Dependencies not finished.
WontDo
Matrix item removed; task skipped.
Variable Resolution
- Parameter:
${{params.branch}}
— Supplied at runtime - Environment:
${{env.CI}}
— Host env var - Shared State:
${{state.counter}}
— Live JSON value
-
In matrix tasks, each object key becomes an environment variable (e.g.,
$team
,$shardId
, …). Inside steps, variables are unprefixed. -
Operators (
==
,!=
,>
,<
,&&
,||
) are supported inside string interpolations like${{ ... }}
for resolving parameters, state, and matrix values.
Roadmap
Container runtime support
Support for
runtime: docker
and other container runtimes, allowing tasks to run in isolated environments.Nested matrix strategies
Support for matrix strategies within matrix strategies, enabling more complex task fan-out.