apply_codemod
Apply bulk regex find-and-replace across files to automate mechanical code changes like updating imports, renaming patterns, or adding async/await. Preview changes first, then apply them.
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.
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) |