moai-tool-ast-grep

Automate structural code search and transformation using AST patterns.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/globalmsq/solo-relayer-service --skill moai-tool-ast-grep-globalmsq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: moai-tool-ast-grep
Source: https://github.com/globalmsq/solo-relayer-service/tree/main/.claude/skills/moai-tool-ast-grep
Command: npx skills add https://github.com/globalmsq/solo-relayer-service --skill moai-tool-ast-grep-globalmsq

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

AST-Grep driven tooling enables developers to locate complex code patterns, detect security risks, and apply automated transformations across large multilingual codebases.

Core Features & Use Cases

  • Pattern-based search across 40+ languages using AST structures for precise results.
  • Codemods and automated code transformations to migrate APIs and modernize code.
  • Security scanning templates and MoAI-ADK integration for automated checks after edits.
  • Contextual documentation and language-specific patterns to guide refactoring.

Quick Start

Install SG (AST-Grep) via Homebrew (macOS/Linux), npm, or cargo, then verify installation. For example:

  • macOS/Linux: brew install ast-grep
  • Cross-platform: npm install -g @ast-grep/cli
  • Rust: cargo install ast-grep Then run a simple search: sg run --pattern 'console.log($$$ARGS)' --lang javascript -r src/ To scan rules: sg scan --config sgconfig.yml

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 complex code patterns across multiple programming languages?

AST-based code search finds complex patterns across 40+ languages by matching abstract syntax tree structures instead of plain text. This enables precise structural queries for locating specific APIs, function calls, or syntax constructs in multilingual codebases.

Can I automate API migrations and refactoring using codemods?

Codemods automate code transformations to migrate APIs and modernize codebases. By defining structural rules, you can apply bulk automated refactoring across large projects, replacing outdated function calls or modifying syntax patterns safely without manual text edits.

Does ast-grep work for security scanning in my codebase?

Security scanning templates in ast-grep detect security risks by locating vulnerable code patterns. You can run rule-driven checks using configuration files to automatically identify dangerous syntax structures and enforce security rules across your codebase.

What do I need to install before running structural code search?

You need to install the ast-grep CLI via Homebrew, npm, or cargo. After installation, verify the setup and execute pattern searches by specifying the target language, pattern syntax, and source directory in your terminal command.

How do I configure custom rules for code transformation checks?

You configure custom rules by creating an sgconfig.yml file that defines structural patterns and transformation logic. Running a scan with this configuration applies rule-driven checks to enforce coding standards and execute automated refactoring.

What is the difference between AST search and regular text search for refactoring?

AST search matches abstract syntax tree structures for precise structural results, unlike regular text search which relies on string matching. This ensures accurate pattern identification across different formatting styles, making it reliable for large-scale refactoring.