ast-grep

ast-grep is a skill for Claude Code, Codex from daeryundf2-prog/LAZYANTIGRAVITY. It costs 61 tokens per session (3,436 once invoked), scanned A, a copy of ast-grep, MIT.

A code-search and rewrite tool that matches the structure of code rather than just its words. It can find or change patterns such as particular function calls, classes, imports, or YAML rules across many programming languages.

In plain words
What is it for?
Use it for syntax-aware searches, codemods, bulk refactoring, and checking or rewriting repeated code shapes. Use ordinary text search for comments, strings, and filenames.
Why use it?
Plain text search can miss equivalent code or match irrelevant text; structural matching focuses on the syntax pattern you actually mean.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it for syntax-aware searches, codemods, bulk refactoring, and checking or rewriting repeated code shapes. Use ordinary text search for comments, strings, and filenames.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/daeryundf2-prog/lazyantigravity/ast-grep
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 daeryundf2-prog/LAZYANTIGRAVITY --skill ast-grep
Clone the repo
git clone --depth 1 https://github.com/daeryundf2-prog/LAZYANTIGRAVITY

Made for: Claude Code, 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/daeryundf2-prog/lazyantigravity/ast-grep/github.svg)](https://agentmods.dev/skills/daeryundf2-prog/lazyantigravity/ast-grep)
Your own site
<a href="https://agentmods.dev/skills/daeryundf2-prog/lazyantigravity/ast-grep"><img src="https://agentmods.dev/badge/skills/daeryundf2-prog/lazyantigravity/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/daeryundf2-prog/lazyantigravity/ast-grep"><img src="https://agentmods.dev/badge/skills/daeryundf2-prog/lazyantigravity/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,436 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.
Origin 89% copy Near-identical to another mod 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.03436
Opus 5.5 $0.00024 $0.01374
Sonnet 5.5 $0.00012 $0.00687
Haiku 4.5 $0.00006 $0.00344

Measured 19d ago against content hash 515f7117c49f, 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 19d 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

This is a copy

89% identical to ast-grep — 8 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

shared-skills/skills/ast-grep/SKILL.md · 281 lines

How it starts

The opening of the file, as written. The whole thing — 281 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.


Runtime note (Antigravity)

The upstream version of this skill references mcp__ast_grep_* MCP tools bundled with OmO native. Those tools are NOT registered in Antigravity — do not attempt to call them. In this environment the path is the sg CLI (or ast-grep) resolved via command -v sg; when absent, run install.sh/install.ps1 or the helper's install command, and if installation is not possible, fall back to rg and say the AST-shape search was not performed.

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 required for patterns that are ambiguous across languages.


When to use this skill

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

  • "Find every function that takes a Request parameter."
  • "Rewrite every console.log(x) to logger.info(x)."
  • "Strip every as any cast."
  • "Replace require(...) with import across the repo."
  • "Find empty catch blocks."
  • "Migrate Optional[X] to X | None."
  • "Apply this codemod across these 200 files."
  • "Run our YAML lint rules and surface violations."

Switch to plain grep / rg when the question is text-shaped (string literal contents, comments, license headers, file names, cross-language regex). When in doubt, ask: "does the answer depend on the language's syntax tree, or just on the file's bytes?" If the former, ast-grep. If the latter, grep.

Read the full file on GitHub · 281 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. 19d ago First seen · 281 lines · 61 tokens per session scan A 515f7117c49f

Subscribe to this mod's changes

ast-grep is a skill published in the GitHub repository daeryundf2-prog/LAZYANTIGRAVITY (14 stars, last pushed 3d ago), licensed MIT. It adds 61 tokens to every session and 3,436 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 89% identical to ast-grep, differing in 8 lines, and is treated as a copy.