Codemod Workflows are self-hostable automations designed for running large-scale code transformation jobs.
Install
Create a minimal workflow
Validate & run
Registry identifiers such as my-registry/react-mods:latest
are on the roadmap.
The folder—called a workflow bundle—is the root when you run codemod@next run ./my-workflow/
. $CODEMOD_PATH
points here inside every task.
Workflow Bundle & Loading Workflows
A workflow bundle is a directory containing your workflow.yaml
and any scripts, rules, or assets referenced by your workflow.
codemod@next run ./my-workflow/
, the directory is used as the root for all relative paths.codemod@next run -w workflow.yaml
Registry support (run workflows from remote sources) is planned for the future.
A workflow has four top-level keys:
Key | Required | Purpose |
---|---|---|
version | ✓ | Declare workflow schema version (default: "1" ). |
state | Declares shared-state schema. | |
templates | Re-usable blocks. | |
nodes | ✓ | Executable DAG. |
Template Inputs & Usage:
Templates can define required or optional inputs, which are referenced in their steps.
To use a template in a node step:
Unique within the workflow.
Display name.
automatic
(default) or manual
.
Upstream node IDs.
{ type: manual }
→ approval gate.
Matrix configuration.
Ordered list of steps.
Step label.
Inline shell command to execute.
run
or uses
, not both.Template call(s).
run
or uses
, not both.Dynamic Matrix Task Recompilation
When the array referenced by from_state
changes, Codemod CLI:
WontDo
if their item is removed.Matrix nodes have a master task that tracks the status of all generated tasks.
Task UUIDs & Resume
Manual tasks are assigned unique UUIDs. You can resume:
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
You can specify how a node or template runs:
Supported types: docker
, podman
, direct
(host shell).
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
For matrix nodes, a master task aggregates the status of all generated tasks.
If all child tasks complete, the master is Completed
. If any fail, the master is Failed
.
Cyclic Dependency Example
If your workflow has a cycle:
You’ll see:
Queued; waiting for runner.
Currently executing.
Succeeded; diff applied.
Script exited non-zero; diff discarded.
Waiting for manual approval.
Dependencies not finished.
Matrix item removed; task skipped.
${{params.branch}}
— Supplied at runtime${{env.CI}}
— Host env var${{state.counter}}
— Live JSON valueIn matrix tasks, each object key becomes an environment variable (e.g., $team
, $shardId
, …).
Codemod CLI is accessible using the codemod@next
command. Please note that once the legacy Codemod CLI is deprecated, using the @next
specifier will no longer be required.
codemod@next init
Initialize a new Codemod workflow project with interactive setup. Scaffolds rules, scripts, and tests for AST-grep or blank workflows.
Set the project name (defaults to directory name).
Overwrite existing files if they exist.
Target directory path (defaults to current directory).
codemod@next run
Execute a workflow from a file, bundle directory, or registry.
Path to the workflow definition file.
Path to workflow file, bundle directory, or registry identifier.
codemod@next resume
Resume a paused workflow or trigger manual tasks.
Workflow run ID to resume.
Specific task UUID to trigger.
Trigger all tasks in AwaitingTrigger state.
codemod@next validate
Validate a workflow definition or bundle without executing it. Checks for schema errors, cyclic dependencies, and more.
Path to the workflow definition file.
Path to workflow bundle directory.
codemod@next validate
catches issues before execution:
Check | Ensures |
---|---|
Schema validation | YAML matches spec |
Unique IDs | Node & template IDs unique |
Dependency validation | Every depends_on exists |
Cyclic dependency detection | DAG has no cycles |
Template references | All template: IDs exist |
Matrix validation | from_state matches schema |
State schema validation | state.schema is valid |
Variable syntax | ${{…}} uses params , env , state |
codemod@next login
Authenticate with a Codemod registry to publish and manage codemods.
Registry URL (defaults to official registry).
Authentication token (for non-interactive login, e.g., CI/CD).
Username for interactive login.
Organization or user scope for publishing.
codemod@next publish
Publish a codemod to a registry for sharing and reuse.
Explicit version (overrides manifest version).
Target registry URL.
Tag for the release (e.g., beta
, latest
).
Access level (public
or private
).
Validate and pack without uploading.
Override existing version (use with caution).
Path to the codemod directory to publish (defaults to current directory).
codemod@next graph
Render DAG image.
Path to the workflow file.
Output PNG file for the DAG image.
Support for runtime: docker
and other container runtimes, allowing tasks to run in isolated environments.
Ability to pass parameters to workflows via —param key=value
flags.
Support for matrix strategies within matrix strategies, enabling more complex task fan-out.