moai-tool-ast-grep

Automates AST-based code search, security scanning, and codemod transformations across multi-language codebases using sg CLI and MoAI-ADK integration.

1|Updated Jan 10, 2026
One-click install
npx skills add https://github.com/GoosLab/moai-rank --skill moai-tool-ast-grep-gooslab
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: moai-tool-ast-grep
Source: https://github.com/GoosLab/moai-rank/tree/main/.claude/skills/moai-tool-ast-grep
Command: npx skills add https://github.com/GoosLab/moai-rank --skill moai-tool-ast-grep-gooslab

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

AST-based structural code search, security scanning, and codemods for multi-language codebases.

Core Features & Use Cases

  • Pattern-based multi-language search: Find code patterns across Python, JavaScript, TypeScript, Go, Java, and more using AST structure rather than regex.
  • Security scanning and quality checks: Identify potential vulnerabilities and enforce coding standards with configurable rules.
  • Codemods and refactors: Apply large-scale transformations safely across projects with declarative rules.
  • Use Case: Analyze a monorepo to locate deprecated API usages, refactor them, and generate a security assessment report.

Quick Start

Run sg to scan your repository, identify patterns across languages, and apply safe transformations with codemods.

Frequently Asked Questions about moai-tool-ast-grep

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

FAQPage Schema
How do I search for code patterns across multiple programming languages without using regex?

AST-based code search finds structural patterns across Python, JavaScript, TypeScript, Go, and Java using abstract syntax trees. It uses YAML-based rule definitions to match code structures safely rather than relying on fragile regular expressions.

Can I automate large-scale refactoring across a multi-language monorepo?

Yes, automated codemod transformations apply large-scale refactors safely across multi-language projects. You define declarative YAML rules and use the sg CLI to execute structural searches and apply consistent code transformations end-to-end.

How does AST structural search compare to standard text-based code search?

AST structural search matches code syntax trees instead of raw text, preventing false positives from variable names or string literals. This approach accurately detects deprecated API usages and enforces coding standards across diverse languages where regex fails.

Do I need YAML rule definitions to perform security scanning on my codebase?

Yes, security scanning and quality checks require configurable YAML rules to identify potential vulnerabilities. These declarative rule definitions guide the sg CLI to detect specific insecure patterns and generate a security assessment report.

What is the best way to locate and refactor deprecated API usages in a large codebase?

The best way is using AST-based codemods to locate deprecated API usages and apply automated refactors. By defining structural patterns in YAML, you can safely transform outdated calls across multiple languages and generate a comprehensive analysis report.