Skip to content

vinhnx/codemods

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codemods

A set of my Codemod that help Rust projects adopt new library versions and handle breaking changes with less manual work.

Available codemods

Open Codemod registry and search for:

Codemod Migration Registry
axum-0-7-to-0-8 axum v0.7 → v0.8 route path syntax (/:param/{param}) registry
clap-v3-to-v4 clap v3 → v4 (derive, builder API, error-kind renames) registry
hyper-0-14-to-1-0 hyper v0.14 → v1.x (legacy client import/path rewrites) registry
rand-0-8-to-0-9 rand v0.8 → v0.9 (thread_rngrng, gen*random*) registry
tree-sitter-0-24-to-0-25 tree-sitter v0.24 → v0.25 (child_containing_descendant renames) registry
ratatui-0-24-to-0-30 ratatui v0.24–v0.30 (Frame::sizearea, SpansLine, etc.) registry

Run from registry

bunx codemod <codemod-name> --target /path/to/rust/project

Run from source

bunx codemod workflow run -w codemods/<slug>/workflow.yaml

By default, codemods run in the current folder. Add --target /path/to/repo to run elsewhere.

Caution

Codemods modify code. Run them only on Git-tracked files, and commit or stash changes first.

Case studies

Repository layout

codemods/<slug>/
  workflow.yaml
  codemod.yaml
  package.json
  tsconfig.json
  scripts/
  tests/
  rules/
  agents/skill/<slug>/
    SKILL.md
    references/
  README.md
types/
  codemod-ast-grep.d.ts
case-studies/
.github/
  ISSUE_TEMPLATE/
  workflows/

Each codemod is self-contained so maintainers can validate and publish packages independently.

Creating codemods

  1. Scaffold: bunx codemod init
  2. Implement Rust rewrites as AST-targeted js-ast-grep transforms; avoid whole-file string replacement for source migrations
  3. Use Codemod MCP when symbol definitions or cross-file references matter
  4. Validate: bunx codemod workflow validate -w codemods/<slug>/workflow.yaml
  5. Test: bunx codemod jssg test -l rust ./scripts/codemod.ts -v --strictness loose

Maintainer

Vinh Nguyen

Contributing

Contributions are welcome. See CONTRIBUTING.md for how to add a new codemod, validate it, and prepare it for release. Open a tracking issue with the quality gate template when you are ready.

License

MIT. See LICENSE.

About

Codemods

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors