Codemod CLI is currently released under the @next tag while in alpha. Core commands and schema may change as we gather feedback. Check the CLI reference for updates until we publish a stable @latest.
1
Initialize a new codemod project
Copy
npx codemod@next init my-codemod
This scaffolds a new codemod project in the my-codemod directory.
2
Publish your codemod
Copy
npx codemod@next publish my-codemod
This publishes your codemod to the registry (you may need to login first).
3
Run your codemod
Copy
npx codemod@next workflow run -w my-codemod/workflow.yaml
This runs your local codemod workflow on your codebase.
# Run a local workflow filenpx codemod@next workflow run -w ./my-workflow.yaml# Run a workflow from a local directorynpx codemod@next workflow run -w ./my-codemod# Run with parametersnpx codemod@next workflow run -w ./my-codemod --param version=latest --param target=src
Running a workflow from the registry:
Copy
# Run a workflow package from the registrynpx codemod@next @codemod-com/my-test-pkg# Run with parametersnpx codemod@next @codemod-com/my-test-pkg --param version=latest --param target=src
jssg is a toolkit for running JavaScript/TypeScript codemods using the high-performance ast-grep engine. It enables fast, large-scale code transformations with a familiar API and robust language support.codemod@next jssg lets you run ast-grep codemods directly from the CLI, without needing to define a workflow. It’s built for speed and simplicity, making ast-grep codemods a first-class experience.
When should I use jssg?
When you want to quickly run or test an ast-grep codemod on your codebase.
For for more complex transformations that require granular AST access and manipulation than a YAML rule can provide. Read more about when to define workflows.
1
Write your codemod
Create a JS/TS file that exports your codemod logic.
2
Run your codemod
Copy
npx codemod@next jssg run my-codemod.js ./src --language javascript
Enable watch mode to automatically re-run tests when files change.
When should I define a workflow instead?
When you need to chain multiple codemods or scripts.
When you want manual review, approval steps, or CI/CD integration.
When you want to use engines other than ast-grep (e.g., jscodeshift, YAML, or custom scripts).
Why ast-grep?
ast-grep is extremely fast and robust for syntax-aware code transformations. We made it first-class in the CLI for the most common use case, but you can still use any engine via workflows.jssg replicates the ast-grep NAPI, but with a few key differences:
It’s built into the CLI, so you can run it directly without needing to install it separately.
It’s built for speed and simplicity, making ast-grep codemods a first-class experience.
It’s built for speed and simplicity, making ast-grep codemods a first-class experience.
Advanced Usage & Best Practices
Use --dry-run to preview changes.
Use --max-threads to control concurrency.
For large codebases, filter files with --extensions and --include-hidden.
Use --update-snapshots to automatically update your expected outputs when your codemod changes.
See the Testing Framework Details accordion for more.
Publishing from CI or on behalf of an organization? Install the Codemod GitHub App on the target repos.
Publishing from CI (w/ GitHub App)
Use this method when your organization has installed the Codemod GitHub App. The app injects CODEMOD_TOKEN automatically—no separate login step needed.
Use this flow when the GitHub App isn’t installed. Requires login --api-key; works for publishing new versions of existing codemods (the first publish must be interactive).
Show what would be removed without actually unpublishing.
The CLI always prompts for confirmation when --version or --force is used. This interactive step cannot be bypassed programmatically.
Examples
Copy
# Preview removal of a single versionnpx codemod@next unpublish my-codemod --version 0.1.0 --dry-run# Remove a single version (will prompt)npx codemod@next unpublish my-codemod --version 0.1.0# Remove all versions (will prompt)npx codemod@next unpublish my-codemod --force# Unpublish from a custom registrynpx codemod@next unpublish my-codemod --force --registry https://registry.example.com