ast-grep-search

Search code patterns and plan rewrites using ast-grep AST matching.

6|1|Updated Jan 21, 2026
One-click install
npx skills add https://github.com/Ven0m0/claude-config --skill ast-grep-search
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ast-grep-search
Source: https://github.com/Ven0m0/claude-config/tree/main/claude/skills/ast-grep-search
Command: npx skills add https://github.com/Ven0m0/claude-config --skill ast-grep-search

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and rules (resource) components.

What problem does it solve?

This Skill addresses the limitations of plain text search (like regex) by enabling precise code pattern matching and safe, automated refactoring based on Abstract Syntax Tree (AST) structures.

Core Features & Use Cases

  • AST-based Search: Find code patterns that respect language syntax, not just text.
  • Safe Rewrites: Preview and apply code transformations with confidence, using capture variables.
  • Use Case: Refactor all instances of a specific API call across a TypeScript codebase, ensuring that only syntactically correct changes are made.

Quick Start

Use ast-grep to search for all console.log statements in the src/ directory and interactively remove them.

Frequently Asked Questions about ast-grep-search

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

FAQPage Schema
How do I perform structural code search instead of plain text matching?

Structural code search uses Abstract Syntax Tree (AST) analysis to find code patterns that respect language syntax. Unlike regex, it matches syntactically valid structures and uses capture variables for precise variable matching.

How do I safely refactor API calls across a codebase without breaking syntax?

Safe refactoring uses ast-grep to preview and apply deterministic code transformations. It leverages AST-based pattern matching to ensure only syntactically correct changes are made during API call replacements.

When do I need AST-based pattern matching for code transformation?

AST-based pattern matching is needed when plain text searches are too fragile for code manipulation. It is required for robust refactoring tasks that demand language-aware analysis and deterministic transformations.

Does ast-grep support interactive code rewriting for specific statements?

Yes, ast-grep supports interactive code rewriting to search for statements like console.log in a directory and interactively remove them. It applies language-aware rules for deterministic transformations.

What is the best way to find and replace code patterns in a TypeScript codebase?

The best way to find and replace code patterns is using AST-based structural search. It respects TypeScript syntax and uses placeholder captures to ensure refactoring only targets syntactically correct instances.

Why does structural code search outperform regex for refactoring?

Structural code search outperforms regex by matching AST structures rather than raw text. It understands language syntax, preventing false positives and ensuring safe, deterministic code transformations during refactoring.