ast-grep-search

ast-grep-search is a skill for Claude Code from laurigates/claude-plugins. It costs 40 tokens per session (2,191 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: model in frontmatter.

Part of the code-quality-plugin plugin — 16 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 16 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.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.svg" alt="Measured on agentmods" 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,191 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.02191
Opus 5 $0.00020 $0.01095
Sonnet 5 $0.00008 $0.00438
Haiku 4.5 $0.00004 $0.00219

Measured 4d ago against content hash 826a223947fb, 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-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 4d 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 · 259 lines

How it starts

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

Pattern Syntax

Pattern Matches Example
$VAR Single AST node console.log($MSG)
$$$ARGS Zero or more nodes func($$$ARGS)
$_ Single node (no capture) $_ == $_
$A == $A Same node repeated Finds x == x (not x == y)

Essential Commands

Search for Patterns

# Find structural patterns
ast-grep -p 'console.log($$$)' --lang js
ast-grep -p 'def $FUNC($$$): $$$' --lang py
ast-grep -p 'fn $NAME($$$) -> $RET { $$$ }' --lang rs

# Search in specific directory
ast-grep -p 'import $PKG' --lang js src/

# JSON output for parsing
ast-grep -p 'pattern' --lang js --json=compact

Read the full file on GitHub · 259 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. 4d 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 (58 stars, last pushed today), licensed MIT. It adds 40 tokens to every session and 2,191 once invoked, about $0.0002 per session on Opus 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

a0-review-plugin

Full audit of Agent Zero plugins in usr/plugins/. Reviews manifest validity, directory structure, code patterns (Store Gating, notifications, imports), security, and duplicate detection against the community index. Use when asked to review, audit, validate, or check an existing plugin before using or contributing it.

agent0ai/agent-zero · 64 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

batch-simplify

Batch-run simplification across changed files, or across an entire repository, grouped by ecosystem and dependency order. Use when: 'batch simplify', 'simplify recent changes', 'forgot to run simplify', 'catch up on simplify', sweeping a named scope such as a branch, a whole repository, or one directory, or after a…

melodic-software/claude-code-plugins · 153 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