ast-grep

Translate natural language queries into ast-grep rules for structural code search.

9|Updated Sep 24, 2022
One-click install
npx skills add https://github.com/not-matthias/dotfiles-nix --skill ast-grep-not-matthias
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ast-grep
Source: https://github.com/not-matthias/dotfiles-nix/tree/main/modules/home/programs/cli-agents/shared/skills/ast-grep
Command: npx skills add https://github.com/not-matthias/dotfiles-nix --skill ast-grep-not-matthias

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Translate natural language queries into ast-grep rules for structural code search and analysis.

Core Features & Use Cases

  • Translate natural language queries into ast-grep rules for precise structural matching across codebases.
  • Test rules against sample code and iterate with CLI feedback.
  • Debug and refine patterns using CST/AST views and built-in rule tooling.

Quick Start

Provide a short code sample description and target language to generate and test an ast-grep rule.

Frequently Asked Questions about ast-grep

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

FAQPage Schema
How do I find specific code patterns using structural search instead of regex?

Structural code search uses AST patterns to match code structure rather than text, enabling precise queries across multi-language codebases for refactoring and analysis without false positives from regex.

Can I generate ast-grep rules from natural language for JavaScript and Python codebases?

Yes, you can translate natural language queries into ast-grep rules for structural code search, applying them to JavaScript and Python codebases to locate patterns based on syntax structure.

What is the best way to test and debug structural code search rules?

Debug structural code search rules using CST and AST views to inspect matches, test against sample code with inline or file-based testing, and iterate with CLI feedback for accurate refactoring.

How do I compose complex relational rules for static analysis queries?

Compose complex relational rules for static analysis by step-by-step constructing ast-grep patterns, allowing you to match code structures relationally and locate precise targets across multi-language codebases.

Does ast-grep work for large-scale refactoring across multiple programming languages?

ast-grep applies structural code search to multi-language codebases, supporting large-scale refactoring by locating precise syntax patterns based on code structure for consistent code modifications.