ast-grep

ast-grep is a skill for Codex from code-yeongyu/lazycodex. It costs 61 tokens per session (3,698 once invoked), scanned A, original, MIT.

A skill for ast-grep, a tool that searches and rewrites code based on its structure rather than matching plain text. It works across 25 programming languages.

In plain words
What is it for?
Use it to find code with a particular shape or apply codemods, such as changing logging calls, replacing imports, removing unsafe casts, finding empty error handlers, or detecting missing await expressions.
Why use it?
Text search can match code in the wrong context, while structure-aware matching can target specific functions, calls, classes, imports, or other code patterns. This makes broad, repeatable code changes safer.

Skill for Codex

Written for Codex: agents/openai.yaml present.

Good fit Use it to find code with a particular shape or apply codemods, such as changing logging calls, replacing imports, removing unsafe casts, finding empty error handlers, or detecting missing await expressions.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/code-yeongyu/lazycodex/ast-grep
About the project

LazyCodex is an agent harness for working on complex codebases, combining project memory, planning, execution, and completion checks inside Codex. It is for developers who want structured, repeatable assistance when handling substantial software projects. The catalogue contains the skills, hook, and MCP integration that provide its workflow inside Codex.

code-yeongyu/lazycodex · 3,960 stars · on GitHub · lazycodex.ai

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add code-yeongyu/lazycodex --skill ast-grep
Clone the repo
git clone --depth 1 https://github.com/code-yeongyu/lazycodex

Made for: Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ast-grep

README.md
[![agentmods](https://agentmods.dev/badge/skills/code-yeongyu/lazycodex/ast-grep/github.svg)](https://agentmods.dev/skills/code-yeongyu/lazycodex/ast-grep)
Your own site
<a href="https://agentmods.dev/skills/code-yeongyu/lazycodex/ast-grep"><img src="https://agentmods.dev/badge/skills/code-yeongyu/lazycodex/ast-grep/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for ast-grep

Your own site · 80×15
<a href="https://agentmods.dev/skills/code-yeongyu/lazycodex/ast-grep"><img src="https://agentmods.dev/badge/skills/code-yeongyu/lazycodex/ast-grep.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 61 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,698 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00061 $0.03698
Opus 5.5 $0.00024 $0.01479
Sonnet 5.5 $0.00012 $0.00740
Haiku 4.5 $0.00006 $0.00370

Measured 20d ago against content hash f9525b1d9a02, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

ast-grep scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 20d ago.

The scan reads SKILL.md. This mod also ships 5 executable files (install.ps1, install.sh, scripts/ast_grep_helper.py, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

plugins/omo/skills/ast-grep/SKILL.md · 287 lines

How it starts

The opening of the file, as written. The whole thing — 287 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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/ast_grep_helper.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 tool_search round trip needed.

  • mcp__ast_grep_search({ 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.
  • mcp__ast_grep_rewrite({ 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.
  • mcp__ast_grep_scan({ 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 mcp__ast_grep_search and mcp__ast_grep_rewrite.


When to use this skill

Use it whenever the user's question is about code structure, not bytes:

Read the full file on GitHub · 287 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 20d ago Changed · +2 lines f9525b1d9a02
  2. 2mo ago Changed · +12 lines 2be8973cc11d
  3. 2mo ago Changed · -49 tokens per session 3ed9e11e7979
  4. 3mo ago First seen · 273 lines · 110 tokens per session scan A c5512fb49494

Subscribe to this mod's changes

ast-grep is a skill published in the GitHub repository code-yeongyu/lazycodex (3,960 stars, last pushed yesterday), licensed MIT. It adds 61 tokens to every session and 3,698 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

ast-grep compared with skills from other repositories

ast-grep next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
ast-grepcode-yeongyu/lazycodexSkill4.0kyesterdayMITA61Codex
feishuHmbown/CodeWhaleSkill41kyesterdayMITA33Claude Code, Codex
interviewHmbown/CodeWhaleSkill41kyesterdayMITA40Claude Code, Codex
refocusingmvschwarz/openrigSkill9.0ktodayApache-2.0A59Claude Code
recipe-create-meet-spacegoogleworkspace/cliSkill33k5d agoApache-2.0A18Claude Code, Codex
printing-press-importmvanhorn/cli-printing-pressSkill5.1ktodayMITA104Claude Code
atmos-validationcloudposse/atmosSkill1.4ktodayApache-2.0A31Claude Code