Thanks for your interest in contributing to this codemod monorepo. This guide covers how to add a new codemod, validate it, and prepare it for release.
-
Bun — primary runtime for this project
curl -fsSL https://bun.sh/install | bash -
Codemod CLI:
bunx codemod@latest -
npm/npx works as a fallback — replace
bunxwithnpxin any command
Install workspace dependencies from the repo root:
bun installcodemods/<slug>/
workflow.yaml # Codemod workflow definition
codemod.yaml # Registry metadata (name, version, description, keywords)
package.json # Package config and scripts
tsconfig.json # TypeScript config
scripts/ # Codemod implementation (codemod.ts)
tests/ # Fixture tests (expected/ pairs)
rules/ # AST-grep rule files (if applicable)
agents/skill/<slug>/ # Skill definition for Codemod MCP
SKILL.md
references/
README.md # Codemod-specific documentation
types/
codemod-ast-grep.d.ts # Type definitions for ast-grep module
case-studies/ # Real-world migration case studies
.github/
ISSUE_TEMPLATE/ # Quality gate issue template
workflows/ # CI/CD (publish.yml)
bunx codemod initThis creates the directory under codemods/<slug>/ with the standard layout.
Edit workflow.yaml to describe the migration steps. Each codemod is self-contained so it can be validated and published independently.
Write the transformation logic in scripts/codemod.ts. Prefer AST-targeted js-ast-grep edits for source rewrites instead of whole-file string replacement. Use Codemod MCP when symbol definitions or cross-file references matter.
Place test fixtures in tests/. Each test case should have:
<name>.rs— input file<name>.expected.rs— expected output after transformation
Include:
- No-op fixtures: code already migrated (should produce no changes)
- Non-target fixtures: code that looks similar but uses unrelated types (should not be rewritten)
- Edge-case fixtures: aliases, grouped imports, multiline patterns
cd codemods/<slug>
bunx codemod@latest workflow validate -w workflow.yaml
bunx codemod@latest jssg test -l rust ./scripts/codemod.ts -v --strictness looseYour README.md should cover:
- What the codemod automates and what it does not
- Before/after examples
- Run commands (from source and from registry)
- Manual follow-up checklist for remaining edge cases
- References to upstream migration guides
When adding a new codemod, also update:
- README.md — add to "Available codemods" and run commands
Before opening a release PR, open a tracking issue using the quality gate template and confirm these requirements:
- Automates at least 80% of common deterministic migration patterns
- No-op and non-target fixtures included
- Rewrites are idempotent
- Workflow validation and fixture tests pass
- Real-repo dry-run baseline recorded
- Update the version in
codemod.yamlandpackage.json. - Run tests and validate the workflow for your codemod:
cd codemods/<slug>
bunx codemod@latest jssg test -l rust ./scripts/codemod.ts -v --strictness loose
bunx codemod@latest workflow validate -w workflow.yaml- Create and push a git tag from the repo root:
git tag <codemod-slug>@v<version>
git push origin <codemod-slug>@v<version>- Verify the package appears in the Codemod Registry.
If you use a codemod to migrate a real project, consider adding a case study under case-studies/. A good case study covers:
- The project and its migration context
- What the codemod automated vs what needed manual follow-up
- Metrics (files changed, coverage, false positives)
- A suggested reproduction workflow
- Codemod docs
- Codemod MCP
- Open an issue using the quality gate template
By contributing, you agree that your contributions will be licensed under the MIT License.