ast-grep-find

Search and refactor code by AST structural pattern matching across multi-language codebases.

3.9k|296|Updated Dec 23, 2025
One-click install
npx skills add https://github.com/parcadei/Continuous-Claude --skill ast-grep-find
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ast-grep-find
Source: https://github.com/parcadei/Continuous-Claude/tree/main/.claude/skills/ast-grep-find
Command: npx skills add https://github.com/parcadei/Continuous-Claude --skill ast-grep-find

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Structural code search that understands syntax, enabling precise searches and refactors.

Core Features & Use Cases

  • Pattern-based search: Find function definitions, imports, classes by AST.
  • Refactoring: Safe replacements across codebase.
  • Use Case: Rename a function across modules with correct scope.

Quick Start

uv run python -m runtime.harness scripts/ast_grep_find.py --pattern "def $FUNC($$$):" --language python

Frequently Asked Questions about ast-grep-find

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I search for code patterns across a codebase without matching strings or comments?

AST-based code search uses abstract syntax tree matching to find structural patterns like function definitions, imports, and class declarations while ignoring string literals and comments. This ensures precise results by understanding code semantics rather than text matching.

Can I refactor function names safely across multiple files?

Yes, AST-grep enables cross-file variable and function renaming with correct scope awareness. It uses syntax patterns to identify all references and replaces them safely, respecting language semantics across your entire codebase.

What languages does AST-based pattern matching support?

AST-grep supports multiple languages including Python, JavaScript, and others through language-specific syntax tree analysis. You specify the target language with the --language parameter to ensure accurate structural matching for that language's grammar.

How do I preview refactoring changes before applying them?

Use the --dry-run parameter to preview all proposed replacements without modifying files. This lets you review matches and refactoring results safely before committing changes to your codebase.

Can I search for code patterns in specific directories or file types?

Yes, use --path to target specific directories and --glob to filter by file patterns. These parameters let you narrow searches to relevant portions of your codebase before running syntax-aware pattern matches.