Overview
ast-grep is an open-source workflow skill for Claude Code and compatible agents, published by code-yeongyu. Its author describes it as: “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, comment…”. The project has 69k stars on GitHub and ships custom license terms, so review them before reuse. Add it to your setup with `git clone https://github.com/code-yeongyu/oh-my-openagent ~/.claude/skills/ast-grep`.
What ast-grep does
`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.
What’s inside
The SKILL.md for ast-grep is organised into these sections:
- OmO native: the ast-grep MCP tools (fastest path, no CLI needed)
- When to use this skill
- Three things the agent must internalize
- 1. ast-grep is NOT regex
- 2. Patterns must be valid code
- 3. --update-all and --json are mutually exclusive (silently)
- The helper script — scripts/astgrephelper.py
- search — find all matches of a pattern
- replace — rewrite by pattern, dry-run by default
- scan — run YAML rules
- validate — offline pattern check (no sg call)
- langs / doctor / install
Installation
Add ast-grep to your agent with:
git clone https://github.com/code-yeongyu/oh-my-openagent ~/.claude/skills/ast-grep Review a skill’s source before installing it — skills can instruct your agent to run commands. This command comes from the skill’s public repository, which is the source of truth for setup steps. New to skills? Read how to install Claude Code skills.
Supported agents
- Codex — declared in the repository topics
- Cursor — declared in the repository topics
- OpenCode — declared in the repository topics
License
code-yeongyu has not declared a standard open-source license for this repository (Other). Confirm the terms with the author before reusing it.
Strengths
- Ships in code-yeongyu/oh-my-openagent, an established project with 69,248 GitHub stars
- Works with Codex, Cursor, OpenCode
- Actively maintained — repository updated in the last 30 days
- Its repository gained 2,357 GitHub stars over the last 52 days
Things to check
- No license declared — confirm terms with the author before reuse
Author
Topics
Frequently asked questions
- What does ast-grep do?
- 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.
- How do I install ast-grep?
- Run git clone https://github.com/code-yeongyu/oh-my-openagent ~/.claude/skills/ast-grep in your agent, then reload your skills. Review the source at https://github.com/code-yeongyu/oh-my-openagent before installing.
- Is ast-grep free to use?
- ast-grep is publicly available on GitHub, but code-yeongyu has not declared a standard open-source license (Other). Confirm the terms with the author before reusing it.
- Which agents does ast-grep work with?
- ast-grep lists Codex, Cursor, and OpenCode — named in its SKILL.md, its plugin marketplace or its repository topics. Skills use the portable SKILL.md format, so other agents that read that format may load it too.
- Where does ast-grep come from?
- ast-grep ships inside code-yeongyu/oh-my-openagent, a repository that contains 49 catalogued skills in total. The repository's 69,248 GitHub stars apply to that whole collection, not to this skill on its own.