- For people, in a terminal: it prints progress lines and asks before it does something you should approve (an
approval(...)step, a shell command, a coding agent, an HTTP request, writing to a repository with uncommitted changes). - For programs, in CI, scripts and coding agents: it never asks. It prints plain text or JSON lines, and its exit code says how the run ended.
--no-interactive, or run where there is no terminal: the CLI also turns prompts off when CI is set, when input or output is piped, and with --format jsonl.
Run in CI
- Approvals don’t block. A run that reaches an
approval(...)step stops there, saves itself and exits. The exit code is3. Pass--approveto give every approval up front. - Your own workflow runs its steps; a registry package’s need
--approve.shell(...),agent(...),http(...)andpullRequest(...)steps ask a person first. With nobody to ask, a workflow file or local directory you run yourself (workflow run -w <file>,codemod run ./dir) is trusted and goes ahead. A package from the registry is not: the step fails, naming itself and the flag. That also holds for a registry package your own workflow nests withcodemod(...). Read what the package runs (codemod workflow inspect, or its source), then pass--approve, or only the kinds it needs, such as--approve=shell,http: its commands run with the job’s permissions and environment, secrets included. - A target with uncommitted changes fails the run at its first write, before anything is written. Commit first, or pass
--allow-dirty. A run that only reads isn’t stopped. - Capabilities are not granted. A step that needs one the run wasn’t given fails. Grant them with
--allow-fsor--allow-child-process, or in the package’scodemod.yaml.
0 finished, 1 failed or stopped, 2 finished with failed files or fail(), 3 waiting at an approval.
A GitHub Actions job
.github/workflows/codemod.yml
Turn off telemetry
SetDISABLE_ANALYTICS=1, or DO_NOT_TRACK=1, in the job’s environment.
Read the output
Plain text is meant for logs. For a program, use--format jsonl: one JSON object per line on stdout.
run_finished, with status, output (what the workflow returned), error and question. After the run, read it again any time:
workflow status has the run’s status, output, exitCode, question and each step’s result. See Build a report that fails CI.
Continue a run that waits
A run stopped at an approval is saved. Approve it from the next CI job, a person’s terminal, or a script:--approve approval:1 gives that approval only; the run stops at the next one. --approve alone gives every approval left. Finished steps are not run again.
Drive a run from a program
A coding agent or a wrapper that wants to answer questions as they come, in the same process, uses--control stdio with --format jsonl. The run prints events on stdout, reads commands on stdin, and waits at each question for an answer:
Tips for agents
- Always pass
--no-interactive(or--control stdio). A run that asks with nobody to answer would wait. - Start with
--dry-run: it changes nothing and prints the diff it would apply. A dry run that reaches an approval exits1; add--approveto see past it. - Use
workflow inspect -w <workflow> --format jsonto see a workflow’s parameters, their types and defaults before you run it. - Pass parameters with
--param key=value. A parameter declared asstringstays a string. - Read results from
workflow status --format json, not from the text output.