Search and Replace
search_and_replacePerform bulk search-and-replace across files using glob patterns. Replace all occurrences with literal text or regex (RE2 with capture groups). Preview changes via dry run that returns a unified diff before committing modifications.
Instructions
Bulk search-and-replace across files matching a glob. Replaces ALL occurrences per file (unlike edit: first only). Always dryRun:true first — returns a unified diff. Literal matching by default; isRegex:true enables RE2 with capture groups ($1, $2).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Base directory (default: root). Absolute path required if multiple roots. | |
| filePattern | No | Glob to filter files. Default: **/* | **/* |
| searchPattern | Yes | Text to search for. Literal by default; RE2 regex when `isRegex=true`. | |
| replacement | Yes | Replacement text | |
| isRegex | No | Treat searchPattern as RE2 regex. Supports capture groups ($1, $2) in replacement. | |
| caseSensitive | No | Case-sensitive matching. Default: true. | |
| dryRun | No | Preview matches without writing. Check changedFiles and matches in the response before committing. | |
| includeHidden | No | Include hidden files/directories (starting with .). Default: false. | |
| includeIgnored | No | Include .gitignore-ignored files (node_modules, dist). Default: false. | |
| returnDiff | No | Return unified diff of changes even if dryRun is false. Default: false. | |
| maxFiles | No | Max files to process before stopping |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | ||
| matches | No | Total matches found | |
| filesChanged | No | Files modified | |
| processedFiles | No | Files processed | |
| failedFiles | No | Files skipped due to errors | |
| failures | No | Sample of per-file errors | |
| changedFiles | No | Sample of changed files | |
| changedFilesTruncated | No | Changed file list truncated | |
| diff | No | Unified diff of changes when `dryRun` or `returnDiff` is enabled | |
| diffTruncated | No | Diff was truncated to fit size limit | |
| stoppedReason | No | Why processing stopped early |