ast-grep

Match Rust code structures with tree-sitter to locate implementations and call sites.

8|1|Updated Jun 7, 2026
One-click install
npx skills add https://github.com/sparq-org/sparq --skill ast-grep-sparq-org
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ast-grep
Source: https://github.com/sparq-org/sparq/tree/main/.claude/skills/ast-grep
Command: npx skills add https://github.com/sparq-org/sparq --skill ast-grep-sparq-org

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill allows you to quickly understand the structure of large codebases without reading through the entire files, by extracting only the necessary signatures, impls, and call sites.

Core Features & Use Cases

  • Code Structure Extraction: Outline the structure of large code files, including function signatures, struct definitions, and trait implementations.
  • Function Call Sites Identification: Locate every occurrence of a specific function or method in the codebase.
  • Use Case: When you need to understand how a trait is implemented across your entire codebase, rather than opening multiple files to look for individual implementations.

Quick Start

Run the 'ast-grep' command to outline the structure of a specific Rust file and locate implementations of a trait across the entire codebase.

Frequently Asked Questions about ast-grep

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

FAQPage Schema
How do I find all implementations of a trait across a Rust codebase?

To find trait implementations in Rust, you can use tree-sitter based structural matching to locate every occurrence of specific code structures without reading entire files. This approach extracts only the necessary signatures and impls across your project.

Can I extract Rust function signatures and struct definitions without reading the whole file?

Yes, you can extract function signatures and struct definitions by performing structural code analysis. This method outlines the structure of large Rust files, allowing you to understand the code layout without reading through the entire file contents.

What is the best way to locate function call sites in Rust?

The best way to locate function call sites is by using structural matching to search the file system. This identifies every occurrence of a specific function or method invocation across your codebase quickly.

Do I need a Rust environment to use tree-sitter for code structure extraction?

Yes, performing structural code analysis with tree-sitter requires a Rust environment and the ast-grep tool installed. These dependencies are necessary to execute the structural matching queries on your codebase.

How does structural code analysis differ from regular text search?

Structural code analysis differs from regular text search by matching the abstract syntax tree instead of raw strings. This means it understands code structure like function signatures and trait implementations, avoiding false positives from comments or string literals.