workflow.yaml specification for Codemod Workflows.
Complete Example
This example demonstrates all five step types working together in a migration workflow:workflow.yaml
Workflow Structure
A workflow has four top-level keys:workflow.yaml
Nodes
Nodes are execution units in your workflow. They can be automatic or manual, depend on other nodes, and may define strategy (matrix), trigger, runtime, env, and an ordered list of steps.Unique identifier within the workflow.
Display name shown in logs and UI.
automatic or manual.Upstream node IDs that must complete before this node runs. See Cyclic Dependencies.
{ type: manual } creates an approval gate. See Manual Triggers.Matrix configuration for parallel fan-out. See Matrix Strategy.
Environment variables for all steps in this node.
Steps
Steps are atomic actions inside a node. They run sequentially and each step performs one transformation or action.JSSG Step
Executes a JavaScript/TypeScript codemod using ast-grep for pattern matching and AST manipulation.Step label.
Conditional expression to gate step execution. Supports
params.x, state.x, and matrix value keys. Operators: ==, !=, >, <, &&, ||. See Variable Resolution.Path to the JS/TS file that implements the codemod.
Target language (e.g.,
typescript, tsx, javascript, jsx).Include glob patterns.
Exclude glob patterns.
Base path for resolving globs.
Maximum concurrent threads.
Perform a dry run without applying changes.
JSSG Documentation
Learn how to write JavaScript/TypeScript codemods.
AI Step
Calls an AI agent with a prompt for LLM-powered transformations.Step label.
Conditional expression to gate step execution. See Variable Resolution.
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. Defaults to the provider’s standard endpoint.
API key for LLM access.
Environment variables for AI steps
YAML ast-grep Step
Executes ast-grep using declarative YAML rules for simple, fast pattern matching.Step label.
Conditional expression to gate step execution. See Variable Resolution.
Path to the ast-grep configuration file (.yaml).
Include glob patterns.
Exclude glob patterns.
Base path for resolving globs.
Maximum concurrent threads.
Codemod Registry Step
Runs another codemod by package name or local path.Step label.
Conditional expression to gate step execution. See Variable Resolution.
Codemod source (registry package or local path). Supports version pinning:
@scope/[email protected].CLI arguments passed to the codemod.
Environment variables used during execution.
Working directory for execution.
You can aggregate multiple codemods by adding multiple
codemod steps in the same node. Steps run sequentially from top to bottom.Shell Command Step
Runs shell commands on the host for setup, cleanup, or external tools.Step label.
Conditional expression to gate step execution. See Variable Resolution.
Inline shell command to execute.
Step-level environment variables applied to the process environment.
Matrix Strategy
Matrix strategies fan out a node into multiple parallel tasks. Use them to shard work by team, directory, or configuration.from_state field references an array in your workflow’s state schema. Each array item spawns a parallel task.
Accessing Matrix Values:
In JSSG transforms via options.matrixValues:
from_state changes:
- New tasks are created for new items
- Tasks are marked
WontDoif their item is removed - Existing tasks remain untouched if their item persists
Manual Triggers
Add approval gates to pause execution until manual intervention:Shared State
State enables workflows to persist data across runs and coordinate work:State Updates
| Syntax | Meaning | Example |
|---|---|---|
KEY=VAL | Set state key to value | count=10 |
KEY@=VAL | Append value to array | shards@={"team":"core","shardId":"1"} |
| Dot notation | Set nested fields | config.retries=5 |
| JSON values | Use valid JSON | user={"name":"Alice","id":123} |
State updates must be valid JSON if not primitive. Updates are applied only if the task exits successfully.
Parameters
Parameters make workflows configurable and reusable:Accessing Parameters
In JSSG transforms viaoptions.params:
PARAM_ prefixed environment variables:
env_ prefix:
Advanced Parameter Usage
Complete parameter patterns and examples in JSSG.
Variable Resolution
Variables can be interpolated in step configurations:| Syntax | Source | Example |
|---|---|---|
${{ params.x }} | Runtime parameters | ${{ params.branch }} |
${{ env.x }} | Host environment | ${{ env.CI }} |
${{ state.x }} | Shared state | ${{ state.counter }} |
if conditions: ==, !=, >, <, &&, ||
Task Statuses
| Status | Description |
|---|---|
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 |
Cyclic Dependencies
Workflows cannot have circular dependencies:Templates
Templates define reusable step blocks (planned feature):Roadmap
Container runtime support
Support for
runtime: docker and other container runtimes.Nested matrix strategies
Matrix strategies within matrix strategies for complex fan-out.