astgrep_replace
Transform code by matching and replacing AST patterns in specified files. Supports multiple languages, preview mode, and interactive confirmation for secure and precise modifications.
Instructions
Code transformation using ast-grep rewrite patterns
Input Schema
Name | Required | Description | Default |
---|---|---|---|
dryRun | No | Preview changes without applying them | |
interactive | No | Interactive mode for confirmation | |
language | No | Programming language | |
paths | No | Specific paths to transform | |
pattern | Yes | AST pattern to match | |
replacement | Yes | Replacement pattern | |
workingDirectory | No | Optional working directory for the operation (defaults to server working directory) |
Input Schema (JSON Schema)
{
"properties": {
"dryRun": {
"description": "Preview changes without applying them",
"type": "boolean"
},
"interactive": {
"description": "Interactive mode for confirmation",
"type": "boolean"
},
"language": {
"description": "Programming language",
"type": "string"
},
"paths": {
"description": "Specific paths to transform",
"items": {
"type": "string"
},
"type": "array"
},
"pattern": {
"description": "AST pattern to match",
"type": "string"
},
"replacement": {
"description": "Replacement pattern",
"type": "string"
},
"workingDirectory": {
"description": "Optional working directory for the operation (defaults to server working directory)",
"type": "string"
}
},
"required": [
"pattern",
"replacement"
],
"type": "object"
}