ast-grep

ast-grep is a skill for Claude Code, Codex from nobodyohm-web/Thot. It costs 16 tokens per session (3,452 once invoked), scanned A, a copy of ast-grep, MIT.

A code search and rewrite tool that understands a program’s structure instead of matching only text. AST means the parsed tree that represents code elements and their relationships.

In plain words
What is it for?
Use it for structural searches, large-scale code migrations, codemods, replacing patterns, finding risky constructs, and applying YAML lint rules.
Why use it?
It can find or change code patterns more accurately across multiple files and languages, even when the same structure is written with different spacing or names.

Skill for Claude CodeCodex

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

Good fit Use it for structural searches, large-scale code migrations, codemods, replacing patterns, finding risky constructs, and applying YAML lint rules.

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

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/nobodyohm-web/thot/ast-grep.svg)](https://agentmods.dev/skills/nobodyohm-web/thot/ast-grep)
Your own site
<a href="https://agentmods.dev/skills/nobodyohm-web/thot/ast-grep"><img src="https://agentmods.dev/badge/skills/nobodyohm-web/thot/ast-grep.svg" alt="Measured on agentmods" height="20"></a>
Per session 16 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,452 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 100% 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.00016 $0.03452
Opus 5 $0.00008 $0.01726
Sonnet 5 $0.00003 $0.00690
Haiku 4.5 $0.00002 $0.00345

Measured 4d ago against content hash e5404b443ee1, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-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 4d 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

100% identical to ast-grep — 0 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.

hermes/optional-skills/software-development/ast-grep/SKILL.md · 289 lines

How it starts

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

ast-grep

ast-grep (binary also named sg) 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.

Upstream source: vendored from code-yeongyu/ast-grep-skill (MIT), as shipped in oh-my-openagent's shared-skills bundle.


When to use this skill

Use it whenever the 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 search_files (or plain 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, search_files.

Hermes integration notes:

  • Run the helper and sg through the terminal tool. Single-quote every pattern so the shell never expands $VAR.
  • For find→read chains around matches, use --json-out and process with execute_code rather than piping through interpreters.
  • This complements (does not replace) Hermes's patch tool: patch is for targeted edits you author; ast-grep is for pattern-driven bulk rewrites across many sites.

Read the full file on GitHub · 289 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. 4d ago First seen · 289 lines · 16 tokens per session scan A e5404b443ee1

Subscribe to this mod's changes

ast-grep is a skill published in the GitHub repository nobodyohm-web/Thot (0 stars, last pushed 13d ago), licensed MIT. It adds 16 tokens to every session and 3,452 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to ast-grep, differing in 0 lines, and is treated as a copy.