ast-grep

Search codebases using AST-based patterns for structural matches.

18|3|Updated Jan 8, 2026
One-click install
npx skills add https://github.com/Dwsy/agent --skill ast-grep-dwsy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ast-grep
Source: https://github.com/Dwsy/agent/tree/main/skills/ast-grep
Command: npx skills add https://github.com/Dwsy/agent --skill ast-grep-dwsy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

AST-Grep addresses the need for precise code search, automated linting, and bulk code rewriting by understanding code structure rather than plain text, enabling reliable refactors across large codebases.

Core Features & Use Cases

  • Semantic search across languages using AST patterns for accurate matches.
  • AST-based linting and code transformation to enforce coding standards.
  • Bulk code rewrite and refactor workflows with rule-based configurations.
  • Use Case: Migrate legacy functions to new APIs across a TS/JS codebase without breaking behavior.

Quick Start

Search for a specific function pattern across your codebase using AST-based rules.

Frequently Asked Questions about ast-grep

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

FAQPage Schema
How do I search for code patterns structurally instead of plain text?

Structural code search uses AST-based patterns to find semantic matches in your codebase. This approach understands code structure rather than plain text, enabling precise structural matches across multiple programming languages.

What is the best way to migrate legacy functions to new APIs across a large codebase?

Migrating legacy functions requires AST-based code rewriting to apply bulk transformations safely. By using rule-based configurations, you can refactor across large multi-language codebases without breaking existing behavior.

Can I use AST-based linting to enforce coding standards across multi-language projects?

AST-based linting enforces coding standards across multi-language projects by parsing code structure into abstract syntax trees. It applies configurable rules to detect structural pattern violations that plain text linters miss.

How do I set up rule-based configurations for bulk code refactoring?

Bulk code refactoring uses configurable rules to define AST patterns for batch transformations. You specify structural match criteria and rewrite actions, enabling automated code changes across large codebases.

Does ast-grep work for semantic search across different programming languages?

ast-grep performs semantic search across multiple languages using AST patterns. It parses code into abstract syntax trees, enabling accurate structural matches regardless of the target language syntax.

Why does plain text search fail to find specific function call patterns?

Plain text search fails because it ignores code structure and semantics. AST-based code search overcomes this by parsing syntax trees, ensuring you find function call patterns reliably without false positives.