moai-tool-ast-grep

Search, scan, and refactor code using AST patterns across 40+ languages.

Updated Nov 28, 2024
One-click install
npx skills add https://github.com/desafin/Resource-Monitor-pyQT --skill moai-tool-ast-grep-desafin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: moai-tool-ast-grep
Source: https://github.com/desafin/Resource-Monitor-pyQT/tree/main/.claude/skills/moai-tool-ast-grep
Command: npx skills add https://github.com/desafin/Resource-Monitor-pyQT --skill moai-tool-ast-grep-desafin

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill automates complex code analysis, refactoring, and security scanning by understanding code structure (AST) rather than just text patterns, enabling precise and safe code transformations across many languages.

Core Features & Use Cases

  • Structural Code Search: Find code patterns that are impossible with regex, like nested function calls or specific API usages.
  • Automated Refactoring: Safely rename functions, update APIs, or migrate code across your entire codebase.
  • Security Scanning: Detect vulnerabilities like SQL injection or XSS by matching malicious code patterns.
  • Use Case: Automatically refactor all instances of a deprecated function call across a large Python project, ensuring all arguments and contexts are handled correctly.

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 perform structural code search instead of just matching text patterns?

Structural code search analyzes the abstract syntax tree (AST) to find code patterns based on syntax and semantic structure, enabling precise matches for nested functions or specific API usages that regex cannot handle.

Can I use ast-grep to refactor deprecated function calls across a large codebase?

Yes, ast-grep supports automated refactoring and codemod operations, allowing you to safely rename functions, update APIs, or migrate code across an entire project by matching syntax-aware patterns.

Does ast-grep support security scanning for vulnerabilities like SQL injection?

Yes, ast-grep performs security scanning by matching malicious code patterns structurally, detecting vulnerabilities like SQL injection or XSS across supported languages.

What programming languages can I analyze with ast-grep?

Ast-grep provides structural code search, security scanning, and refactoring capabilities across 40+ programming languages using semantic code understanding.

How do I find all instances of console.log in JavaScript files using ast-grep?

You can find specific API usages like console.log in JavaScript files by running ast-grep with a structural pattern against the target directory, leveraging AST matching for precise results.