Inspect Syntax Tree
dump_treeInspect Tree-sitter syntax trees for short code snippets or ast-grep patterns before writing AST rules, and debug why patterns fail to match.
Instructions
Inspect the Tree-sitter syntax tree of a short code snippet or pattern via ast-grep. Call this BEFORE writing 'ast_rule' YAML queries (use format='ast' to discover exact node 'kind' names) or when debugging why an 'ast' pattern didn't match (use format='pattern').
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": {
"code": "<code>",
"language": "<language>"
},
"name": "dump_tree"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Short representative code snippet (2-5 lines) or an ast-grep pattern (when format='pattern') to inspect. | |
| format | No | Tree format: 'ast' (default, named AST nodes only—best for finding 'kind:' names for ast_rule), 'cst' (full concrete syntax tree with punctuation), 'pattern' (shows how ast-grep parses your pattern with $VAR/$$$). | ast |
| language | Yes | Tree-sitter language name, e.g. 'typescript', 'tsx', 'javascript', 'python', 'rust', 'go', 'java'. |