ast-grep-search

ast-grep-search is a skill for Claude Code from laurigates/claude-plugins. It costs 40 tokens per session (2,725 once invoked), scanned A, original, MIT.

A structural code search and replacement tool matches code by its shape, such as a function signature or call pattern, rather than by exact text.

In plain words
What is it for?
Use it to find specific kinds of functions or calls, detect structural anti-patterns, and update API call sites across many files.
Why use it?
It finds code patterns that ordinary text search or regular expressions can miss and makes larger refactors safer.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: reads .claude/ paths.

Part of the code-quality-plugin plugin — 17 skills shipped together

Good fit Use it to find specific kinds of functions or calls, detect structural anti-patterns, and update API call sites across many files.

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

Made for: Claude Code.

Or install code-quality-plugin, the plugin that ships this one along with the rest of its 17 skills.

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-search

README.md
[![agentmods](https://agentmods.dev/badge/skills/laurigates/claude-plugins/ast-grep-search/github.svg)](https://agentmods.dev/skills/laurigates/claude-plugins/ast-grep-search)
Your own site
<a href="https://agentmods.dev/skills/laurigates/claude-plugins/ast-grep-search"><img src="https://agentmods.dev/badge/skills/laurigates/claude-plugins/ast-grep-search/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-search

Your own site · 80×15
<a href="https://agentmods.dev/skills/laurigates/claude-plugins/ast-grep-search"><img src="https://agentmods.dev/badge/skills/laurigates/claude-plugins/ast-grep-search.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 40 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,725 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Excessive Agency · line 9
    Skill selects an external model or provider that may use a different account or billing plan than the operator expects. Undisclosed model switches can cause unexpected cost or quota consumption.
    Fix: Remove the model/provider override or disclose it prominently and require explicit operator approval before invoking an external coding CLI or billed model.
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.00040 $0.02725
Opus 5.5 $0.00016 $0.01090
Sonnet 5.5 $0.00008 $0.00545
Haiku 4.5 $0.00004 $0.00272

Measured 1mo ago against content hash 922347cc7d71, 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-search scanned grade A with 1 finding 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 1mo ago.

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.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

ast-grep -p 'os.system($$$)' --lang py
code-quality-plugin/skills/ast-grep-search/SKILL.md · 290 lines

How it starts

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

ast-grep Structural Code Search & Refactoring

Structural code search and refactoring using ast-grep — matches code by its AST (abstract syntax tree) rather than text patterns.

When to Use This Skill

Use this skill when... Use something else instead when...
The pattern depends on AST structure (function shape, call form, argument count) Searching plain text or regex matches → tools-plugin:rg-code-search
Refactoring API call sites across many files while preserving captured variables Running a one-shot anti-pattern scan with a report → code-antipatterns
Hand-written structural search/replace for an ad-hoc migration Functional refactors of a known file/directory → code-refactor
Building a new ast-grep rule for a codebase-specific smell Looking up agentic flags for an existing linter → code-lint

When to Use ast-grep vs Grep/ripgrep

Use ast-grep when... Use grep/rg when...
Pattern depends on code structure Simple text or regex match
Need to match any number of arguments Searching logs, docs, config
Refactoring across many files One-off literal string search
Finding anti-patterns (empty catch, etc.) Language doesn't matter
Replacing while preserving variables Quick filename/line check

Decision rule: If your search pattern contains wildcards for "any expression," "any arguments," or "any function name," use ast-grep.

Find References With the Sharpest Instrument

Promoted from ~/.claude/rules/tool-use-patterns.md. Edit refuses on a file unread this session, so "read it first" is already a harness invariant. The uncovered half is checking what else depends on what you're changing, and the reflex there is grep, which cannot tell a call from a comment, a definition from a mention, or foo() from "foo" in a string. Measured across 282 local sessions: ~2,400 code-symbol searches went through grep/rg, against 6 ast-grep calls and 6 LSP calls.

Read the full file on GitHub · 290 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 1mo ago Changed 922347cc7d71
  2. 1mo ago Changed · +31 lines 18958ca12278
  3. 1mo ago First seen · 259 lines · 40 tokens per session scan A 826a223947fb

Subscribe to this mod's changes

ast-grep-search is a skill published in the GitHub repository laurigates/claude-plugins (59 stars, last pushed today), licensed MIT. It adds 40 tokens to every session and 2,725 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

review-feedback

Address code review/PR comments: verify each, then fix.

42-evey/hermes-plugins · 16 tokens

phpunit-test-team-reviewing

Use this skill when the user asks for a team-based, consensus, multi-reviewer, or red-team review of Shopware PHPUnit tests — trigger phrases like "team review these tests", "consensus review the tests in PR.

shopwareLabs/ai-coding-tools · 52 tokens

phpunit-test-reconciling

Internal sub-skill. Do not auto-activate. Use only when explicitly invoked by name by another skill or agent.

shopwareLabs/ai-coding-tools · 32 tokens

audit-comment-residue

Read-only classifier that flags residue in code comments: history narration, plan or session references, conversational asides, ticket or PR back-references, origin notes, and workarounds with no link or removal condition. Use when asked to 'audit code comments' or report which comments only make sense with the chat…

melodic-software/claude-code-plugins · 96 tokens

issue-analyzing

Use this skill when the user asks to analyze a specific GitHub issue, understand what area of code an issue affects, assess an issue's scope, or research the code context around an issue — example triggers like "analyze issue.

shopwareLabs/ai-coding-tools · 51 tokens

pr-analyzing

Use this skill when the user asks to analyze a specific GitHub pull request, review a PR's architectural impact, assess what changed in a PR and why it matters, or research the code relationships affected by a PR — example triggers like "analyze PR.

shopwareLabs/ai-coding-tools · 56 tokens