apply_codemod
Perform bulk regex find-and-replace across files. Preview changes with a dry run before applying to avoid accidental modifications.
Instructions
Bulk regex find-and-replace across files. Dry-run by default — first call shows preview, second call with dry_run=false applies. Use for mechanical changes like adding async/await, renaming patterns, updating imports across many files. Potentially destructive — can modify or delete code. Always preview with dry_run=true first. Returns JSON: { success, matchedFiles, changes: [{ file, matches }], applied }.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | Yes | Regex pattern to match (JavaScript regex syntax) | |
| replacement | Yes | Replacement string ($1, $2 for capture groups) | |
| file_pattern | Yes | Glob pattern for files to scan (e.g. "tests/**/*.test.ts", "src/**/*.py") | |
| dry_run | No | Preview changes without writing (default: true). Set to false to apply. | |
| confirm_large | No | Required when >20 files affected. Acknowledges large-scale change. | |
| filter_content | No | Only process files containing this substring (narrows scope) | |
| multiline | No | Enable multiline mode (dot matches newlines, patterns span lines) |