AST-based code search and refactoring via ast-grep MCP
The 'ast-grep-find' skill enables developers to perform structural code searches and refactorings based on Abstract Syntax Tree (AST) patterns, making it highly effective for tasks that require understanding of code syntax rather than mere text matching. Unlike traditional search tools that rely on string matching, this skill allows users to search for patterns like function calls, class definitions, and imports in a codebase, enabling precise, syntax-aware search results. It eliminates false positives that may arise from searching within strings or comments, making it more accurate and reliable for complex code refactoring and analysis tasks.
You can search for a specific pattern by using the `--pattern` parameter, specifying the desired AST pattern along with the language you are working with. For example, to search for the pattern 'import asyncio' in Python, you would use `--pattern 'import asyncio' --language python`.
Yes, you can limit the search to a specific directory by using the `--path` parameter. For example, `--path ./src` will restrict the search to the `src` directory.
Yes, you can perform a dry run to preview changes without applying them by using the `--dry-run` parameter. This allows you to see the changes that would be made without actually modifying the code.
The tool supports multiple languages including Python, JavaScript, TypeScript, and Go. You specify the language with the `--language` parameter.
This tool requires the `ast-grep` server to be set up and available, which is configured through the `mcp_config.json` file.
Quick Setup:
.claude/skills/Repository
parcadei/Continuous-Claude-v2