Agent skill · software engineering · code-yeongyu

ast-grep

Searches and rewrites code by AST shape across 25 languages. Use when the target is a syntax pattern (every call/class/import shaped like X, a codemod, a YAML rule) rather than literal text; for plain strings, comments, or filenames, use rg.

Why this skill is useful

Adds a Python wrapper and install scripts for ast-grep, enabling AST-aware code search and rewrite capabilities that the AI cannot generate on its own.

What it needs

Requires python3 installed locally. About 8k tokens when loaded. Last updated 2026-08-07. 67,387 stars on the source repository.

What this skill does

ast-grep sg (also installed as ast-grep) is an AST-aware search and rewrite tool across 25 languages. It treats your pattern as code, parses it the same way it parses your project, and matches structurally. It is the right tool whenever your question depends on code shape rather than text bytes. This skill ships a Python wrapper at scripts/astgrephelper.py and platform install scripts at install.sh (POSIX) and install.ps1 (Windows). The helper adds offline pattern validation, the two-pass write trick, and binary auto-resolution. Use it as your default entry point. --- OmO native: the ast-grep MCP tools (fastest path, no CLI needed) OmO native also registers a bundled ast-grep MCP server. Its three tools are deferred: they are absent from the resident tool list and activate automatically the first time you call them by name — no toolsearch round trip needed. mcpastgrepsearch({ pattern, language, paths }) — AST-shape search, the MCP equivalent of sg run -p. Prefer this over shelling out to sg for one-off lookups: no install, no PATH issues. mcpastgreprewrite({ pattern, rewrite, language, paths, apply }) — preview matches (apply: false, the default) or apply the rewrite (apply: true). Same two-pass discipline as sg run -r: preview first, then apply. mcpastgrepscan({ ruleFile inlineRules, paths, apply }) — run exactly one explicit YAML rule source (a rule file or inline rules), the MCP equivalent of sg scan --rule / --inline-rules. It never discovers sgconfig.yml; to run a project's whole rule set, use sg scan (or the helper's scan) from the shell. Same pattern language as the CLI: $VAR matches one AST node, $$VAR matches zero or more, and the pattern is code, not regex. paths accepts a file or directory list; language is always required by mcpastgrepsearch and mcpastgreprewrite. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills code-yeongyu/ast-grep

View the source on GitHub

Browse the @skills marketplace