ast-grep

ast-grep is a skill for Claude Code, Codex from rcarmo/piclaw-addons. It costs 27 tokens per session (497 once invoked), scanned A, original, MIT.

Tools for searching and rewriting code by its structure, such as finding every function call or changing declarations across a project.

In plain words
What is it for?
Use it for syntax-based code searches and refactors in supported languages, previewing changes first and then applying them after review.
Why use it?
Structure-aware searches avoid the noisy or unsafe matches that ordinary text search can produce when code looks similar but means something different.

Skill for Claude CodeCodex

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

Good fit Use it for syntax-based code searches and refactors in supported languages, previewing changes first and then applying them after review.

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

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/rcarmo/piclaw-addons/ast-grep/github.svg)](https://agentmods.dev/skills/rcarmo/piclaw-addons/ast-grep)
Your own site
<a href="https://agentmods.dev/skills/rcarmo/piclaw-addons/ast-grep"><img src="https://agentmods.dev/badge/skills/rcarmo/piclaw-addons/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/rcarmo/piclaw-addons/ast-grep"><img src="https://agentmods.dev/badge/skills/rcarmo/piclaw-addons/ast-grep.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 27 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 497 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. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
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.00027 $0.00497
Opus 5 $0.00014 $0.00249
Sonnet 5 $0.00005 $0.00099
Haiku 4.5 $0.00003 $0.00050

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

addons/ast-grep-tool/skills/ast-grep/SKILL.md · 44 lines

What it actually says

AST Grep

Use this skill when text search would be noisy or unsafe.

Tools

  • code_search(pattern, lang, path?, limit?) — find code by AST pattern
  • code_rewrite(pattern, rewrite, lang, path?, dry_run?) — structural find-and-replace

Examples

  • console.log($MSG) — find all console.log calls
  • var $NAME = $VALconst $NAME = $VAL — modernize var declarations
  • catch ($ERR) { } — find empty catch blocks
  • import $X from "lodash" — find imports from a specific module

Workflow

  1. code_search(pattern, lang, path, limit=20) — narrow path, sample first
  2. Inspect matches — verify pattern catches what you want
  3. code_rewrite(pattern, rewrite, lang, path, dry_run=true) — preview changes
  4. Review the dry run output
  5. code_rewrite(pattern, rewrite, lang, path, dry_run=false) — apply
  6. Read changed files, run formatting/tests

Prefer other tools when

  • You need plain text, comments, or strings → grep
  • You need type/symbol-aware results → LSP/symbol tools if available

Safety

  • Always run dry_run=true before applying any rewrite
  • Scope with path to avoid unintended matches in vendored/generated code
  • Supported lang values: typescript, javascript, tsx, jsx, python, rust, go, java, c, cpp, csharp, ruby, swift, kotlin, lua, html, css, json, yaml
  • After applying rewrites, read changed files and run tests/formatting before moving on

Troubleshooting

  • No matches: verify lang is correct (e.g. typescript not ts), broaden pattern
  • Too many matches: narrow path, add more structure to pattern, lower limit
  • Pattern error: simplify — patterns must be valid syntax in the target language
  • Wrong language: typescripttsx, javascriptjsx — run separate passes
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. 9d ago First seen · 44 lines · 27 tokens per session scan A 236c48cf808c

Subscribe to this mod's changes

ast-grep is a skill published in the GitHub repository rcarmo/piclaw-addons (23 stars, last pushed today), licensed MIT. It adds 27 tokens to every session and 497 once invoked, about $0.0001 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-30.

Related

Other skills, from other repositories

triage-issues

Triage GitHub issues in the googleapis/mcp-toolbox repo: propose the correct labels (type / priority / product / status), check for duplicates, verify a bug has enough info to act on, and draft a triage comment. Use whenever a maintainer asks you to triage, label, categorize, prioritize, or "look at" an issue (or a…

googleapis/mcp-toolbox · 164 tokens

adk-debug

Diagnoses misbehaving ADK agents by inspecting sessions, events, tool calls, and the exact request that reached the model. Covers the adk run CLI and the adk web dev server with its session, trace, and debug HTTP endpoints. Use when an agent returns the wrong answer, ignores a tool or swallows a tool error, hangs…

google/adk-python · 191 tokens

browser-edge-cases

SOP for debugging browser automation failures on complex websites. Use when browser tools fail on specific sites like LinkedIn, Twitter/X, SPAs, or sites with Shadow DOM.

aden-hive/hive · 40 tokens

claw-admin

Claw system administration: service management, IM connections, logs, cron, and workspace diagnostics. Use when the user asks to manage claw services, connect/disconnect IM platforms, view logs, or perform system-wide operations.

x-cmd/x-cmd · 48 tokens

session-investigator

Investigate fast-agent session and history files to diagnose issues. Use when a session ended unexpectedly, when debugging tool loops, when correlating sub-agent traces with main sessions, or when analyzing conversation flow and timing. Covers session.json metadata, history JSON format, message structure, tool…

evalstate/fast-agent · 68 tokens

rubber-duck

Adversarial "rubber duck" review that turns explaining-out-loud into a hallucination check. The main session is the PRESENTER (it did the work — a design doc, investigation, or analysis — and holds the real reasoning) and reconstructs the topic to a LISTENER — a spawned subagent pinned to a DIFFERENT-vendor model that…

kirodotdev/KiroCrew · 161 tokens