moai-tool-ast-grep

Search, scan, and refactor code across 40+ languages using ast-grep CLI.

67|27|Updated Dec 24, 2025
One-click install
npx skills add https://github.com/modu-ai/cc-plugins --skill moai-tool-ast-grep-modu-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: moai-tool-ast-grep
Source: https://github.com/modu-ai/cc-plugins/tree/main/.claude/skills/moai-tool-ast-grep
Command: npx skills add https://github.com/modu-ai/cc-plugins --skill moai-tool-ast-grep-modu-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides advanced, AST-based code analysis for precise structural searching, automated refactoring, and security scanning across numerous programming languages, going beyond simple text-based tools.

Core Features & Use Cases

  • Structural Code Search: Find code patterns based on syntax, not just text.
  • Automated Refactoring: Perform complex code transformations and codemods semantically.
  • Security Scanning: Detect vulnerabilities using AST-aware rules.
  • Use Case: Automatically refactor all instances of a deprecated API call across your entire codebase, ensuring semantic correctness and minimizing errors.

Quick Start

Use the moai-tool-ast-grep skill to find all instances of console.log in JavaScript files within the src directory.

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 find and replace a deprecated API call across my entire codebase?

Automated refactoring uses AST-based structural code search to find and replace deprecated API calls across your codebase. By matching syntax patterns instead of text, it performs complex codemod operations to ensure semantic correctness and minimize errors during transformation.

What is AST-based structural code search and how does it differ from text search?

AST-based structural code search finds code patterns based on syntax rather than exact text matching. It analyzes the abstract syntax tree to identify structural relationships, allowing precise pattern matching across 40+ languages and enabling syntax-aware code transformations.

Can I use ast-grep for security scanning in multiple programming languages?

Yes, ast-grep performs security scanning across 40+ languages using AST-aware rules. It detects vulnerabilities by analyzing syntax patterns, allowing you to scan codebases for insecure code structures and apply rule-based scanning to identify potential security issues.

Does structural code search require any special installation or dependencies?

Yes, AST-based structural code search requires the ast-grep CLI installation to function. Once the CLI dependency is installed, you can perform pattern matching, code transformation, and rule-based scanning across supported programming languages.

What's the best way to find all console.log statements in a JavaScript project?

The best way to find console.log statements is using structural code search with ast-grep to locate syntax patterns in JavaScript files. By targeting the specific directory like src, it matches the exact syntax structure of the console.log call for precise code search results.

Why use AST-based codemods instead of simple find and replace for refactoring?

AST-based codemods perform complex code transformations semantically, unlike simple find and replace. By understanding syntax structure, ast-grep ensures automated refactoring maintains semantic correctness across 40+ languages, minimizing errors when transforming code patterns like deprecated API calls.