jscodeshift
$ jscodeshift Official Med RiskMeta's jscodeshift executes JS/TS AST transformation scripts in parallel across worker processes using recast and Babel/TypeScript parsers. Passing -d (--dry) and -p (--print) enables safe diff inspection before applying in-place edits.
npm install -g jscodeshift jscodeshift spawns local Node worker pools directly against source trees; MCP cannot efficiently proxy arbitrary Recast AST transforms.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Non-interactive CLI with -d (--dry) dry-run, -p stdout print, and --silent, though it emits text summaries rather than --json.
- Supports
-d(--dry),-p(--print), and--run-in-band - Outputs plain-text worker stats; no
--jsonflag
-d guarantees zero disk writes; omits -d writes matched files in-place and runs user-authored transform JS.
- Dedicated
-d(--dry) flag prevents file modification - Requires running transform files via Node.js
Universally installable via npm install -g jscodeshift or npx jscodeshift wherever Node.js is present.
- Cross-platform npm/npx package
Industry-standard parallel AST codemod runner preserving formatting and comments via recast.
- Multi-worker JS/TS/Flow AST transforms with formatting preservation
Official Meta open-source project (meta/jscodeshift) under MIT with mature ecosystem adoption.
- Official Meta repository under MIT
Clear CLI flag list and transform API examples in the README and --help.
- Documented CLI flags and transform examples on GitHub
Security, Auth & Guardrails
None required; executes local JS/TS transform modules on local source files.
100% free, offline, and open-source (MIT).
# jscodeshift Agent Rules - ALWAYS pass `-d` (`--dry`) first (with `-p` on a sample file) before omitting `-d` to write changes. - Specify `--parser=tsx` and `--extensions=ts,tsx` explicitly when targeting TypeScript codebases.
Agent-Ready Command Recipes
Safe Read-Only Queries
jscodeshift -t transform.js --extensions=ts,tsx --parser=tsx -d -p src/
Simulates the codemod with -d (--dry) and prints transformed files (-p) without writing to disk.
Controlled Writes & Previews
jscodeshift -t transform.js --extensions=ts,tsx --parser=tsx src/
Runs the verified transform in parallel across src/ and writes formatted AST edits in-place.
Strengths for Agents
- + Preserves untouched formatting and comments during complex JS/TS AST rewrites via
recast. - +
-d(--dry) +-pprovides safe verification before in-place writes.
Caveats & Pitfalls
- ! No
--jsonoutput; defaults to modifying files in-place if-dis forgotten. - ! Default parser is
babel(JS), so TypeScript files fail unless--parser=tsor--parser=tsxis specified.