replace_pattern
Replaces all occurrences of a detected code pattern across project files; use dry-run first to preview affected files and roll back changes when needed.
Instructions
DESTRUCTIVE BATCH OPERATION: Replaces ALL occurrences of a pattern across the project.
What it does: Creates new token + replaces usages. Can be rolled back via rollback_pattern(pattern_id).
When to use: When replacing a recurring conditional or hardcoded pattern across all files.
When NOT to use: USE dry_run=True FIRST to preview affected files. pattern_id must come from detect_conditional_variants.
Side effects: DESTRUCTIVE: Modifies multiple .kt files simultaneously. Records changes in journal.
Parameters:
- pattern_id: Unique pattern identifier from detect_conditional_variants.
- dry_run: If True (recommended first), previews changes without writing to disk.
Returns:
JSON string with replacements made, modified files, and created token name.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"pattern_id": "<pattern_id>"
},
"name": "replace_pattern"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dry_run | No | ||
| pattern_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |