ast-grep

Search code structure across Go, Python, Bash, and Terraform/HCL.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

AST-aware code search identifies code structure (functions, classes, patterns) across languages, enabling precise navigation and refactoring beyond text grep.

Core Features & Use Cases

  • Structure-aware searches: Find functions, classes, and patterns by AST structure instead of textual matches.
  • Cross-language support: Works with Go, Python, Bash, Terraform/HCL codebases.
  • Use Case: Quickly locate all usages of a function across multiple files and refactor safely.

Quick Start

Install and run ast-grep, then execute example sg commands to locate patterns in your codebase.

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 across Go, Python, and Terraform files without matching plain text?

AST-powered semantic code search matches code structure like functions and classes instead of plain text. It analyzes Go, Python, Bash, and Terraform/HCL codebases to locate structural patterns for navigation and refactoring.

What is the best way to find all usages of a function across a large codebase for a safe refactor?

Structure-aware code search is the best way to locate all function usages across multiple files. By matching AST structure instead of text, it identifies precise code locations to enable safe refactoring in large codebases.

Can I use ast-grep to detect anti-patterns in Bash and Terraform/HCL configurations?

Yes, ast-grep supports anti-pattern detection in Bash and Terraform/HCL configurations. It evaluates code structure using ast-grep patterns to identify problematic code shapes and outputs contextual or JSON results for workflow integration.

How do I get JSON output from code search results to integrate into my development workflow?

You can execute ast-grep commands to produce JSON outputs from code search results. This structural analysis output integrates directly into development workflows, allowing automated processing of matched code patterns across supported languages.

Does AST-based code search work for navigating cross-language monorepos containing Python and Go?

Yes, AST-based code search works for navigating cross-language monorepos containing Python and Go. It relies on ast-grep patterns to parse and match structural code elements across multiple languages simultaneously.

Why use structure-aware code search instead of text grep for refactoring large codebases?

Structure-aware code search identifies code structure like functions and classes beyond textual matches, enabling precise navigation. Unlike text grep, it understands AST structure to prevent false positives during large-scale refactoring.