ast-grep-find — Claude Code skill: what it does, how to install
Runs AST-based code search and refactoring using language syntax trees. Helps locate and replace function calls, imports, and variables without matching text inside strings or comments.
npx skills add parcadei/Continuous-Claude-v3 --skill ast-grep-find -a claude-codeWhat ast-grep-find does
The skill executes structural code queries through scripts/ast_grep_find.py using uv. Unlike standard grep, it parses language syntax trees. It locates function signatures, class definitions, and imports across languages like python, javascript, typescript, or go. Comments and string literals are ignored.
Pattern matching relies on dedicated wildcards: $NAME targets a single node, $$$ captures multiple statements, and $_ matches any single node. Refactoring tasks use the --replace argument. The --dry-run flag previews diffs before writing. Searching defaults to the current directory ., with 2 context lines by default.
A configured ast-grep server inside mcp_config.json is mandatory. Missing server configurations break the tool.
What it helps with
- locate function calls and classes by syntax structure
- refactor code patterns without touching matching words in comments
- rename variables and arguments across files using AST patterns
- preview code replacements before applying them with
--dry-run
Example prompts for the agent
- Find all
console.log($$$)calls in JavaScript files using ast-grep-find - Replace
print($X)withlogger.info($X)across Python files using ast-grep-find with--dry-run - Search for
async def $FUNC($$$)declarations inside./srcwith ast-grep-find
How to install ast-grep-find
1Skills CLI (Vercel)
npx skills add parcadei/Continuous-Claude-v3 --skill ast-grep-find -a claude-code2Manually: put the files in place
~/.claude/skills/ast-grep-find/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/ast-grep-find/
1Skills CLI (Vercel)
npx skills add parcadei/Continuous-Claude-v3 --skill ast-grep-find -a codex2Manually: put the files in place
.agents/skills/ast-grep-find/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add parcadei/Continuous-Claude-v3 --skill ast-grep-find -a cursor2Manually: put the files in place
.cursor/skills/ast-grep-find/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install parcadei/Continuous-Claude-v3 ast-grep-find2Manually: put the files in place
.github/skills/ast-grep-find/SKILL.md1Skills CLI (Vercel)
npx skills add parcadei/Continuous-Claude-v3 --skill ast-grep-find -a gemini-cli2Platform CLI
gemini skills install https://github.com/parcadei/Continuous-Claude-v3 --path .claude/skills/ast-grep-findManually: put the files in place
.devin/skills/ast-grep-find/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add parcadei/Continuous-Claude-v3 --skill ast-grep-find -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about ast-grep-find
How do I install ast-grep-find in Claude Code?
Run npx skills add parcadei/Continuous-Claude-v3 --skill ast-grep-find -a claude-code in your terminal.
What does ast-grep-find do?
It provides syntax-aware code search and refactoring through abstract syntax trees. It parses programming language grammar so searches ignore plain strings and comments.
How does ast-grep-find differ from warpgrep?
Warpgrep focuses on raw speed when matching regular expressions and plain text. In contrast, ast-grep-find parses code syntax trees to match structural nodes with AST precision.
Source text
SKILL.md · MIT
---
name: ast-grep-find
description: AST-based code search and refactoring via ast-grep MCP
allowed-tools: [Bash, Read]
---
# AST-Grep Find
Structural code search that understands syntax. Find patterns like function calls, imports, class definitions - not just text.
## When to Use
- Find code patterns (ignores strings/comments)
- Search for function calls, class definitions, imports
- Refactor code with AST precision
- Rename variables/functions across codebase
## Usage
### Search for a pattern
```bash
uv run python -m runtime.harness scripts/ast_grep_find.py \
--pattern "import asyncio" --language python
```
### Search in specific directory
```bash
uv run python -m runtime.harness scripts/ast_grep_find.py \
--pattern "async def \$FUNC(\$\$\$)" --language python --path "./src"
```
### Refactor/replace pattern
```bash
uv run python -m runtime.harness scripts/ast_grep_find.py \
--pattern "console.log(\$MSG)" --replace "logger.info(\$MSG)" \
--language javascript
```
### Dry run (preview changes)
```bash
uv run python -m runtime.harness scripts/ast_grep_find.py \
--pattern "print(\$X)" --replace "logger.info(\$X)" \
--language python --dry-run
```
## Parameters
| Parameter | Description |
|-----------|-------------|
| `--pattern` | AST pattern to search (required) |
| `--language` | Language: `python`, `javascript`, `typescript`, `go`, etc. |
| `--path` | Directory to search (default: `.`) |
| `--glob` | File glob pattern (e.g., `**/*.py`) |
| `--replace` | Replacement pattern for refactoring |
| `--dry-run` | Preview changes without applying |
| `--context` | Lines of context (default: 2) |
## Pattern Syntax
| Syntax | Meaning |
|--------|---------|
| `$NAME` | Match single node (variable, expression) |
| `$$$` | Match multiple nodes (arguments, statements) |
| `$_` | Match any single node (wildcard) |
## Examples
```bash
# Find all function definitions
uv run python -m runtime.harness scripts/ast_grep_find.py \
--pattern "def \$FUNC(\$\$\$):" --language python
# Find console.log calls
uv run python -m runtime.harness scripts/ast_grep_find.py \
--pattern "console.log(\$\$\$)" --language javascript
# Replace print with logging
uv run python -m runtime.harness scripts/ast_grep_find.py \
--pattern "print(\$X)" --replace "logging.info(\$X)" \
--language python --dry-run
```
## vs morph/warpgrep
| Tool | Best For |
|------|----------|
| **ast-grep** | Structural patterns (understands code syntax) |
| **warpgrep** | Fast text/regex search (20x faster grep) |
Use ast-grep when you need syntax-aware matching. Use warpgrep for raw speed.
## MCP Server Required
Requires `ast-grep` server in mcp_config.json.
© parcadei · MIT · parcadei/Continuous-Claude-v3