workflow.yaml. The registry resolver uses the entry in codemod.yaml, or discovers a supported default such as src/workflow.ts.
Directory Layout
Scaffold a new package with:my-codemod-package
codemod.yaml
package.json
tsconfig.json
src
workflow.ts
scripts
setup.sh
rules
config.yml
tests
basic-transform
input.tsx
expected.tsx
The
src/scripts/ and src/rules/ folders are conventional, not required. Paths in the workflow are relative to the workflow file, and import.meta.dirname is its directory, so keep the files it uses next to it. A workflow.ts at the package root also works.Detection-only mining packages still use this layout. The JSSG step returns { edit: null, data } (returning data) and proves behavior with data.json fixtures next to input/expected. Insights discovers data names from each selected step’s js-ast-grep script in the published package (not from a separate package-entry file).Package Behavior
Codemod packages use a workflow-first model and can be:- Workflow-only: the workflow has executable steps and no
install-skillsteps. - Skill-only: a
workflow.yamlwithinstall-skillsteps and no executable steps, with authored skill files underagents/skill/<skill-name>/. - Workflow + skill: executable steps and
install-skillsteps, with authored skill files underagents/skill/<skill-name>/. Theinstall-skillsteps are in aworkflow.yaml, one of the package’s workflows next to itsworkflow.ts.
install-skill is a workflow.yaml step: workflow.ts has no function for it. A workflow.ts that imports installSkill from codemod/workflow doesn’t build, and the error says to keep the step in a workflow.yaml.
Package skills
Usecodemod init to scaffold a workflow package or codemod init --skill for a skill package. --skill writes a workflow.yaml with an install-skill step. To ship both, add such a workflow.yaml and the skill files to a workflow package yourself, as a second entry under workflows. Skill-only scaffolds cannot also set --project-type.
codemod publish and codemod workflow validate -w <package-root> validate the package shape automatically: workflow packages run workflow checks, skill packages run skill structure/frontmatter/reference checks, and combined packages run both.
install-skill is a workflow.yaml step type. Interactive runs can trigger it like any other awaiting step. Non-interactive runs skip it by default unless --install-skill is passed.
Skill-capable packages should keep authored skill content under:
npx codemod@next <package-id> and accept the skill-install prompt.
Package Metadata (codemod.yaml)
Thecodemod.yaml file defines your package’s metadata and configuration.
codemod.yaml
workflow: "workflow.yaml", with the install-skill step in that workflow; authored skill content lives under agents/skill/<skill-name>/.
Multiple workflows per package
A single package can ship multiple named workflow variants — for example a plain run and a sharded variant for large monorepos. Use theworkflows array instead of workflow:
codemod.yaml
- CLI:
npx codemod@next <package-id> --workflow <name>selects a variant for a published package. Without--workflow, the entry markeddefault: trueruns (or the first entry if none is flagged). When stdin is interactive and no flag is given, the CLI shows a picker. - Local directory runs:
codemod workflow run -w ./pkg --workflow-name <name>mirrors the same selection. - Codemod campaigns: the campaign creation flow allows the user to pick the preferred workflow variant.
- Exactly one of
workfloworworkflowsmay be set. - Each
namematches alphanumeric and is unique within the package. - Each
pathis package-relative — absolute paths and..segments are rejected — and unique within the package. - At most one entry may set
default: true. If none is flagged, the first entry is treated as the default.
install-skill must include a SKILL.md with:
- YAML frontmatter containing at least
name,description, andallowed-tools codemod-compatibility: skill-package-v1codemod-skill-version: <version>
mcs-v1 compatibility marker is used by the built-in Codemod core skill and other agent-facing resources, not by authored package skills installed via install-skill.
Available fields:
Codemod package name (unique within scope).Naming rules:
^(@[A-Za-z0-9\-_.]+/)?[A-Za-z0-9\-_]+$ — optional @scope/ (scope may include dots), then letters, numbers, hyphens, or underscores only.Not allowed in the name segment: dots, commas, spaces, or other special characters. Version bumps in the package id must use hyphens (react-18-to-19, temporal-ts-sdk-1-24-to-1-25), not semver dots (…-1.24-to-1.25 fails publish).Valid examples:-
remove-console-logs -
temporal-ts-sdk-1-24-to-1-25 @scope/remove-console-logs(using@organization-or-project-scope/nameprovides better discoverability in the Codemod Registry)
Semantic version of the package. Keep this in sync with
package.json. Bump it (and republish) after any material package change — do not reuse a published version with different contents.Relative path to your workflow file (
workflow.ts, or a legacy workflow.yaml). codemod init and codemod workflow upgrade set it for you. Use this for single-workflow packages. Mutually exclusive with workflows. Required for workflow-only, skill-only, and workflow + skill packages unless workflows is set.Path must be package-relative; absolute paths and .. segments are rejected at publish time.List of named workflow variants this package ships. Mutually exclusive with
workflow. Each entry has:name(required) — package-local identifier matching^[A-Za-z0-9_-]+$. Used bynpx codemod@next <package-id> --workflow <name>and the cloud campaign picker.path(required) — package-relative path to the workflow YAML. Absolute paths and..segments are rejected.description(optional) — short blurb shown in the picker UI.default(optional) — at most one entry may setdefault: true. If none is flagged, the first entry is the default.
Keyword tags are an optional feature helping developers quickly identify the purpose, scope, and relevance of a codemod. They also enable better search, filtering, and reporting when managing many codemods across frameworks and projects.Example:
1. Transformation Type TagsConsider these categories when describing why the codemod exists:
2. Target Version TagsUse these to indicate the framework/library version the codemod prepares for.
3. Framework / Library / SDK TagsAlways add the ecosystem name to improve discoverability.
4. Example Tag SetsHere are some examples to illustrate how tags combine:
keywords: ["react", "v18-to-v19", "migration"]Best practices and conventions
Best practices and conventions
- Keep tags concise (1–2 words).
- Use lowercase for consistency.
- Don’t overload with tags — 2–4 per codemod is ideal.
- Prioritize transformation type + framework/library + version (if relevant).
1. Transformation Type TagsConsider these categories when describing why the codemod exists:
upgrade– helps upgrade code to newer versions (encompasses both breaking changes and feature adoption). You may also consider adding one of the following tags:breaking-change– adapts code to framework/library breaking API changes.feature-adoption– helps adoption of new optional or incremental features.
security– addresses known vulnerabilities or unsafe patterns.cross-migration– replaces one library/framework with another.i18n– internationalization migrations or improvements.a11y– accessibility improvements and compliance.standardization– unifies patterns, conventions, or APIs across a codebase.code-mining– identifies, flags, or extracts patterns without transforming. Use if the codemod is detection-only. Return{ edit: null, data }from each Insights-bound step script, and follow Performant codemods.
breaking-change and feature-adoption in the same codemod.2. Target Version TagsUse these to indicate the framework/library version the codemod prepares for.
- Format:
vXorvX-to-vY(for upgrades). - Examples:
v17-to-v18(React 17 → 18)v5-to-v6(React Router 5 → 6)v16(Angular 16 breaking changes)
3. Framework / Library / SDK TagsAlways add the ecosystem name to improve discoverability.
- Examples:
reactnextjsnodejsangularmswi18next
4. Example Tag SetsHere are some examples to illustrate how tags combine:
- React Root API Upgrade (17 → 18)
- Tags:
upgrade,breaking-change,v17-to-v18,react
- Tags:
- Adopt React Hooks
- Tags:
upgrade,feature-adoption,react
- Tags:
- Migrate from Moment.js to Day.js
- Tags:
cross-migration,momentjs,dayjs
- Tags:
- Remove Hardcoded Strings for i18n
- Tags:
i18n,i18next
- Tags:
- Add ARIA labels for accessibility
- Tags:
a11y,react
- Tags:
- Detect Insecure crypto API usage
- Tags:
security,nodejs,crypto
- Tags:
Access controls who can run/use the codemod (once they can see it).
- public: Anyone can run the codemod.
- private: Only the owner can run the codemod.
- pro: Only Pro plan users can run the codemod.
Visibility controls who can see the package in the Registry (search, listings, and UI).
- public: Everyone can see the package in the Registry.
- private: Only the owner can see the package.
- org: Members of the package’s organization scope can see the package.
- user: Visible only to the publishing user (user-scoped visibility).
During scaffolding, the CLI sets
public/private based on —private. You can change to any supported value above when publishing.Array of capabilities required by this codemod’s jssg transforms when they run with
codemod jssg run. Workflows ignore it: their callbacks are pure, and reach the network and run commands through http() and shell() steps (see Callbacks are pure).Available capabilities:fs- File system access (fs,fs/promises)fetch- Network requests (globalfetch)child_process- Process spawning (child_process)
Next Steps
Workflows
Get started with building Codemod Workflows.
JSSG
Write JavaScript/TypeScript transformations.