moai-tool-ast-grep

Automate AST-based code search, refactoring, and security scanning with sg.

Updated Jan 16, 2026
One-click install
npx skills add https://github.com/yarang/fastapi-error-code --skill moai-tool-ast-grep-yarang
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: moai-tool-ast-grep
Source: https://github.com/yarang/fastapi-error-code/tree/main/.claude/skills/moai-tool-ast-grep
Command: npx skills add https://github.com/yarang/fastapi-error-code --skill moai-tool-ast-grep-yarang

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill enables fast, pattern-driven search, refactoring, and security scanning across large multi-language codebases using AST-Grep.

Core Features & Use Cases

  • Pattern-driven search across languages (Python, JavaScript/TypeScript, Go, Rust, and more) using sg.
  • Code transformation (codemods) to migrate APIs and modernize code across repositories.
  • Security scanning with reusable rules to identify vulnerabilities and enforce best practices.
  • MoAI-ADK integration for automated security scans after edits or commits.
  • Use Case: Migrate a monorepo from legacy APIs to modern equivalents with minimal manual effort.

Quick Start

Install the AST-Grep CLI and ensure it is on your PATH. Then run a basic search like sg run --pattern 'console.log($$$ARGS)' --lang javascript src/

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 run AST-based code search across multiple programming languages?

AST-based code search across multiple languages is executed using the SG CLI, which requires a proper sgconfig.yml file and a supported language set to output structured pattern-matching results.

What is the best way to automate API migrations and code refactoring in a large monorepo?

Automating API migrations and refactoring in a large monorepo is handled through AST-based code transformations, applying codemods to modernize legacy APIs across multiple files with minimal manual effort.

Can I use ast-grep for security scanning and vulnerability detection in CI/CD workflows?

Ast-grep can be used for security scanning in CI/CD workflows by applying reusable pattern rules to identify vulnerabilities, enforce best practices, and output structured results suitable for automated pipelines.

Do I need to install the SG CLI before using AST-based codemods?

You need the AST-Grep CLI installed and accessible on your PATH to execute pattern-driven searches and codemods, as the Skill automates SG commands rather than replacing the underlying engine.

How does AST-based pattern matching differ from standard regex code search?

AST-based pattern matching differs from standard regex by analyzing the abstract syntax tree, allowing accurate structural code search and refactor across languages without false positives from text-level string matching.