Skip to main content
Use stable APIs when a workflow or tool needs to keep working across Codemod 2.x releases. Experimental APIs are available now, but their contracts may change. Look for @experimental in TypeScript, an Experimental badge or callout in the docs, and (experimental) in CLI help. The first time a CLI run uses an experimental API, it emits a notice on stderr in text mode or an experimental event on the JSONL event stream.

Stable in 2.0

  • Workflow APIs: step, fail, StepError, WorkflowFailure, WorkflowContext and parameters, forEachFile and its reducer, astGrep (from codemod/ast-grep), approval and question IDs, shell, and nested codemod().
  • Target file access: codemod/files (read, exists, list, and create) in workflow callbacks and JSSG transforms.
  • JSSG: codemod/ast-grep parsing, SgRoot and SgNode (apart from the semantic APIs), and codemod/runtime helpers.
  • CLI: run, workflow run/resume/status/list/cancel/validate/upgrade, resume --approve/--rerun-step/--skip-step, jssg run/test, publish, search, login/logout/whoami, telemetry on/off/status, and init --no-interactive for workflow packages.
  • Automation: --control stdio, the codemod/protocol v1 JSONL protocol, status and list with --format json, and exit codes 0, 1, 2, and 3, including fail({ exitCode }).
  • Compatibility: YAML shard behavior, install-skill steps in workflow.yaml (workflow.ts has no equivalent), and on-the-fly upgrades when running 1.x packages. The TypeScript emitted by the translator is not a stable API.

Experimental in 2.0

  • Workflow APIs: http(), sleep, waitForEvent, and the TypeScript shard(...) signature.
  • Semantic APIs: definition() and references().
  • Package APIs: codemod/ai (agent, and ask with its question builders), codemod/llm, codemod/deps, codemod/git, codemod/testing, codemod/host, codemod/vite, and codemod/register.
  • CLI: workflow attach, inspect (including its JSON output), send, ai, mcp, package skills, --managed-git, and the launcher.

1.x compatibility

These APIs exist so code written for codemod 1.x keeps running. They are not part of the 2.0 API: don’t use them in new code. They keep working in 2.x for the code they were made for, and get no new features.
  • codemod/compat (jssgFile and jssgWouldChange), which codemod workflow upgrade writes for transforms a plain callback cannot call.
  • jssgTransform, inside a 1.x jssg transform only: under codemod jssg run, in a workflow.yaml js-ast-grep step, or in a transform called with jssgFile. Elsewhere in a workflow it throws. Its type is declared by codemod/compat.
See 1.x compatibility APIs for where each works.

Internal

Translation helpers (apart from codemod/compat) and the layout of run-store files are internal. Codemod can read its run store across releases in the same major version; use the CLI and its JSON output rather than reading the files directly.