use-cli-ast-grep

use-cli-ast-grep is a skill for Claude Code, Codex from thkt/dotclaude. It costs 35 tokens per session (885 once invoked), scanned A, original, MIT.

A command guide for ast-grep, a tool that searches and rewrites code by its syntax structure rather than by plain text. It distinguishes this work from text search and symbol call-graph analysis.

In plain words
What is it for?
Use it to find or rewrite syntax patterns, apply rule files across selected paths, list code symbols, and produce JSON results. It also defines safety checks for bulk rewrites.
Why use it?
It helps match code patterns accurately and prevents using the wrong search tool for a structural code change.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/thkt/dotclaude/use-cli-ast-grep
Any agent
npx skills add thkt/dotclaude --skill use-cli-ast-grep
Clone the repo
git clone --depth 1 https://github.com/thkt/dotclaude

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 use-cli-ast-grep

README.md
[![agentmods](https://agentmods.dev/badge/skills/thkt/dotclaude/use-cli-ast-grep.svg)](https://agentmods.dev/skills/thkt/dotclaude/use-cli-ast-grep)
Your own site
<a href="https://agentmods.dev/skills/thkt/dotclaude/use-cli-ast-grep"><img src="https://agentmods.dev/badge/skills/thkt/dotclaude/use-cli-ast-grep.svg" alt="Measured on agentmods" height="20"></a>
Per session 35 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 885 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00035 $0.00885
Opus 5 $0.00017 $0.00443
Sonnet 5 $0.00007 $0.00177
Haiku 4.5 $0.00003 $0.00089

Measured 3d ago against content hash 71761e11cafb, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

use-cli-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 3d 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.

.ja/skills/use-cli-ast-grep/SKILL.md · 48 lines

How it starts

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

use-cli-ast-grep

使いどころ

構文木の形で一致させる検索・書き換えに限る。テキストや正規表現の一致は ugrep と bfs に、シンボル単位の呼び出しグラフは codegraph に残す。

問い ツール
AST パターンによる構文木単位の一致・書き換え ast-grep
自由記述・リテラル文字列・正規表現の検索 ugrep / bfs
シンボル単位の呼び出し元 / 先・変更の波及範囲 codegraph
既知の 1 箇所を読む・直接編集する Read / Edit

コマンド

run が単発の検索・書き換え、scan がルールファイルによる一括適用、outline がシンボル一覧の抽出にあたる。

目的 コマンド
パターン検索 ast-grep run -p '<pattern>' -l <lang> <PATHS>
パターン書き換え (対話確認あり) ast-grep run -p '<pattern>' -r '<fix>' -l <lang> -i <PATHS>
パターン書き換え (確認なし一括適用) ast-grep run -p '<pattern>' -r '<fix>' -l <lang> -U <PATHS>
ルールファイルによるスキャン・書き換え ast-grep scan -r <rule.yml> <PATHS>
シンボル一覧 (構造の把握) ast-grep outline -l <lang> <PATHS>
JSON 出力 ast-grep run -p '<pattern>' --json <PATHS>

前提

呼び出しにあたり、次の 3 つを必須の制約とする。

項目 詳細
PATHS の明示 run / scan / outline の PATHS はデフォルトでカレントディレクトリ全体 (.) になる。省略せず、対象パスを都度明示する
-U はクリーンツリーで -U は確認なしで全ての書き換えを適用する。実行前に git status でクリーンツリーであることを確かめ、汚れたツリーでは使わない
.ja/ の同時処理 対象に .ja/ 対応がある (MIRROR.md 参照) 場合、.ja/ 側と英語側の両方を同じセッションで処理する。片側だけの書き換えはミラーを崩す

正典は help 出力

オプション、出力形式、終了コードは ast-grep --helpast-grep <subcommand> --help にある。help と記憶が食い違えば help が正しい。

Read the full file on GitHub · 48 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. 3d ago First seen · 48 lines · 35 tokens per session scan A 71761e11cafb

Subscribe to this mod's changes

use-cli-ast-grep is a skill published in the GitHub repository thkt/dotclaude (12 stars, last pushed yesterday), licensed MIT. It adds 35 tokens to every session and 885 once invoked, about $0.0002 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

create-modal

Create declarative modals using the modal library API. Covers modal types (confirm, input, select, form), sections (Text, Buttons, Input, Textarea, Checkbox, List, Combo, When, Custom), rendering with OverlayModal, and keyboard/mouse handling. Use when adding modals or dialogs to the application.

marcus/sidecar · 69 tokens

merge-strategy

Git merge strategies, conflict resolution approaches, merge vs rebase recommendations, and branch integration patterns in sidecar. Covers pull strategy menu, direct merge workflow, squash merge, commit message templates, configurable defaults, and protected branches. Use when working on git merge features or making…

marcus/sidecar · 63 tokens

autoprompt

Explicit-only useful-first orchestration. Invoke /autoprompt to turn a mission into one executable roadmap, build dependency-safe lanes, and verify the result with independent reviewers. Never infer invocation from ordinary requests. Never resume from leftover artifacts without an explicit resume instruction.

Spielewoy/autoprompt-skill · 56 tokens

autoprompt

Explicit-only useful-first orchestration. Invoke /autoprompt to turn a mission into one executable roadmap, build dependency-safe lanes, and verify the result with independent reviewers. Never infer invocation from ordinary requests. Never resume from leftover artifacts without an explicit resume instruction.

Spielewoy/autoprompt-skill · 56 tokens

autoprompt

Explicit-only useful-first orchestration. Invoke /autoprompt to turn a mission into one executable roadmap, build dependency-safe lanes, and verify the result with independent reviewers. Never infer invocation from ordinary requests. Never resume from leftover artifacts without an explicit resume instruction.

Spielewoy/autoprompt-skill · 56 tokens

ap-feature-coordinator

L1 feature coordinator - drives approved ROADMAP.md lanes through their required build/review/verification gates and owns the run-wide feature frontier.

Spielewoy/autoprompt-skill · 33 tokens