ast-grep

Search and refactor code using AST patterns across JavaScript, TypeScript, Python, and Go.

68|1|Updated Jan 14, 2026
One-click install
npx skills add https://github.com/knoopx/pi --skill ast-grep-knoopx
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ast-grep
Source: https://github.com/knoopx/pi/tree/main/agent/skills/ast-grep
Command: npx skills add https://github.com/knoopx/pi --skill ast-grep-knoopx

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers locate and rewrite code using AST patterns, replacing brittle regex-based approaches with safe, structural transformations.

Core Features & Use Cases

  • AST-based search: identify function calls, patterns, and control structures across files.
  • Safe refactoring: perform structural changes with reduced risk and improved maintainability.
  • Use Case: When upgrading a codebase to a new API or modernizing legacy patterns across a large repository.

Quick Start

Use the ast-grep skill to search for a deprecated function and rewrite it to the new API across your project.

Frequently Asked Questions about ast-grep

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

FAQPage Schema
How do I refactor deprecated function calls across a large codebase?

You can refactor deprecated function calls across a large codebase by using AST pattern matching to precisely identify and rewrite the structural constructs to the new API safely.

What is the best way to search for code patterns without using regex?

AST-based search is the best alternative to regex for locating code patterns, as it analyzes the abstract syntax tree to identify function calls and control structures structurally rather than textually.

Can I use AST pattern matching for JavaScript and TypeScript code modernization?

Yes, AST pattern matching supports JavaScript and TypeScript code modernization, alongside Python and Go, by applying structural search and safe rewrite rules for deterministic transformations.

How does structural AST refactoring ensure safe code transformations?

Structural AST refactoring ensures safe code transformations by using an AST matching engine with deterministic rewrite rules to perform structural changes, reducing risk and improving maintainability.

What are the limitations of using AST patterns for large-scale code search?

Large-scale AST pattern code search requires an AST matching engine and safe rewrite rules to guarantee deterministic transformations, limiting its use to supported languages like JavaScript, TypeScript, Python, and Go.