ast-grep

ast-grep is a skill for Claude Code from and3r817/dot-claude-plugins. It costs 75 tokens per session (1,706 once invoked), scanned A, original, MIT.

A code search and rewriting tool that understands program structure, not just matching text. It uses the language’s syntax tree—the structure built from code such as functions and loops.

In plain words
What is it for?
For locating complex code patterns, writing custom checks, and applying large-scale rewrites across JavaScript, Python, Rust, Go, and other supported languages.
Why use it?
It finds code relationships that ordinary text search can miss or match incorrectly, such as functions containing one construct but not another.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the ast-grep plugin — 1 skill shipped together

Good fit For locating complex code patterns, writing custom checks, and applying large-scale rewrites across JavaScript, Python, Rust, Go, and other supported languages.

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

Made for: Claude Code.

Or install ast-grep, the plugin that ships this one along with the rest of its 1 skill.

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/and3r817/dot-claude-plugins/ast-grep/github.svg)](https://agentmods.dev/skills/and3r817/dot-claude-plugins/ast-grep)
Your own site
<a href="https://agentmods.dev/skills/and3r817/dot-claude-plugins/ast-grep"><img src="https://agentmods.dev/badge/skills/and3r817/dot-claude-plugins/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/and3r817/dot-claude-plugins/ast-grep"><img src="https://agentmods.dev/badge/skills/and3r817/dot-claude-plugins/ast-grep.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 75 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,706 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 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.00075 $0.01706
Opus 5 $0.00037 $0.00853
Sonnet 5 $0.00015 $0.00341
Haiku 4.5 $0.00007 $0.00171

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

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.

ast-grep/skills/ast-grep/SKILL.md · 248 lines

How it starts

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

ast-grep Skill

Structural code search using AST patterns. Use this skill when text-based search (grep/ripgrep) is insufficient.

When to Use This Skill

Activate when user asks to:

  • Find code patterns with structural constraints ("async functions without try-catch")
  • Locate nested or relational code ("await inside loops")
  • Search with negation ("functions that don't have X")
  • Rewrite code patterns at scale
  • Write custom lint rules

Prefer ast-grep over grep when:

  • Pattern involves parent-child or sibling relationships
  • Need "contains X but not Y" logic
  • Text matching would have too many false positives

Workflow

Step 1: Clarify Requirements

Ask user if unclear:

  • What code pattern to find?
  • Which programming language?
  • Simple match or complex structural query?
  • Find only, or also rewrite?

Supported languages: JavaScript, TypeScript, TSX, Python, Rust, Go, Java, C, C++, C#, Kotlin, Swift, Ruby, Lua, HTML, CSS, JSON, YAML

Step 2: Choose Approach

Is it a simple, single-node pattern?
├─ YES → Use `ast-grep run --pattern`
│        Example: ast-grep run --pattern 'console.log($ARG)' --lang javascript .
│
└─ NO → Does it need relational logic (inside/has/precedes/follows)?
        ├─ YES → Create YAML rule with `ast-grep scan --inline-rules`
        │        Consult: references/relational-rules.md
        │
        └─ NO → Does it need composite logic (all/any/not)?
                ├─ YES → Create YAML rule
                │        Consult: references/composite-rules.md
                │
                └─ NO → Use pattern with constraints
                        Consult: references/yaml-config.md

Step 3: Build the Pattern

For simple patterns:

ast-grep run --pattern 'PATTERN' --lang LANGUAGE /path

Meta-variable syntax (consult references/metavariables.md for details):

  • $VAR — matches single node
  • $$$VAR — matches zero or more nodes
  • $_ — matches but doesn't capture

For complex rules, build YAML:

Read the full file on GitHub · 248 lines

Files

What ships with it

6 files 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. 8d ago First seen · 248 lines · 75 tokens per session scan A 8b21c412fad2

Subscribe to this mod's changes

ast-grep is a skill published in the GitHub repository and3r817/dot-claude-plugins (2 stars, last pushed 8mo ago), licensed MIT. It adds 75 tokens to every session and 1,706 once invoked, about $0.0004 per session on Opus 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-31.

Related

Other skills, from other repositories

orchestrator

FULLY AUTONOMOUS Flutter development pipeline orchestrator. Smart routing: PM analyzes -> creates targeted tasks -> Orchestrator executes only needed agents. Supports Asana task URLs. Includes QE verification via Maestro E2E tests. 7-phase flow: PM -> TodoWrite -> Execute -> Review -> Tests -> QE E2E -> Close.

aleksandr-chaika/flutter-clean-arch-skills · 72 tokens

flutter-guide

Flutter/BLoC Clean Architecture patterns, review checklists, and testing guides. Background knowledge for flutter-dev, flutter-reviewer, flutter-tester. Not user-invocable.

aleksandr-chaika/flutter-clean-arch-skills · 39 tokens

maestro-flutter

Maestro E2E testing knowledge for Flutter apps. YAML-based flows, TestKeys, visual regression, Maestro MCP integration. Background knowledge for QE E2E testing phase.

aleksandr-chaika/flutter-clean-arch-skills · 41 tokens

cloudflare-workers-observability

Cloudflare Workers observability with logging, Analytics Engine, Tail Workers, metrics, and alerting. Use for monitoring, debugging, tracing, or encountering log parsing, metric aggregation, alert configuration errors.

secondsky/claude-skills · 47 tokens

cloudflare-workers-dev-experience

Cloudflare Workers local development with Wrangler, Miniflare, hot reload, debugging. Use for project setup, wrangler.jsonc configuration, or encountering local dev, HMR, binding simulation errors.

secondsky/claude-skills · 47 tokens

cloudflare-workers-performance

Cloudflare Workers performance optimization with CPU, memory, caching, bundle size. Use for slow workers, high latency, cold starts, or encountering CPU limits, memory issues, timeout errors.

secondsky/claude-skills · 42 tokens