Skip to content
Back to skills

Use Cli Ast Grep

ASecurity

Structural search and rewrite by AST pattern via ast-grep CLI.

  • 12 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 24, 2026
ai-agentsbashgit

Works with

  • cli

Security analysis

A100/100

Scanned September 24, 2026

npx -y skills add thkt/dotclaude --skill use-cli-ast-grep --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Use Cli Ast Grep?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Use Cli Ast Grep
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/thkt-use-cli-ast-grep-dotclaude/badge)](https://www.skillsdirectory.com/skills/thkt-use-cli-ast-grep-dotclaude)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: use-cli-ast-grep
description: Structural search and rewrite by AST pattern via ast-grep CLI.
when_to_use: AST pattern, structural search, structural rewrite, syntax-aware search, pattern-based refactor across files, code shape match, 構造検索, 構文パターン, 一括書き換え, AST 書き換え
allowed-tools: Bash(ast-grep:*) Read
user-invocable: false
---

# use-cli-ast-grep

## When to use

Structural queries and rewrites only. Route a match by AST shape to ast-grep, and keep text or regex matching on ugrep and bfs, and symbol-level call graphs on codegraph.

| Question                                                    | Tool        |
| ----------------------------------------------------------- | ----------- |
| Structural match / rewrite by AST pattern, syntax-tree unit | ast-grep    |
| Free-text, literal string, or regex search                  | ugrep / bfs |
| Symbol-level callers / callees, change impact               | codegraph   |
| Reading or editing one already-known location               | Read / Edit |

## Commands

`run` is a one-off search or rewrite, `scan` applies a rule file at scale, and `outline` extracts a symbol listing.

| Purpose                                    | Command                                                       |
| ------------------------------------------ | ------------------------------------------------------------- |
| Pattern search                             | `ast-grep run -p '<pattern>' -l <lang> <PATHS>`               |
| Pattern rewrite (with interactive confirm) | `ast-grep run -p '<pattern>' -r '<fix>' -l <lang> -i <PATHS>` |
| Pattern rewrite (apply all, no confirm)    | `ast-grep run -p '<pattern>' -r '<fix>' -l <lang> -U <PATHS>` |
| Rule-file scan / rewrite                   | `ast-grep scan -r <rule.yml> <PATHS>`                         |
| Symbol listing (structure overview)        | `ast-grep outline -l <lang> <PATHS>`                          |
| JSON output                                | `ast-grep run -p '<pattern>' --json <PATHS>`                  |

## Prerequisites

The call carries 3 required constraints.

| Item                      | Detail                                                                                                                                                                      |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| State PATHS explicitly    | `run` / `scan` / `outline` default PATHS to the whole current directory (`.`). Never omit it; state the target path on every call                                           |
| `-U` on a clean tree only | `-U` applies every rewrite without confirmation. Confirm a clean tree with `git status` before running it, and never run it on a dirty tree                                 |
| `.ja/` in the same pass   | When the target has a `.ja/` counterpart (see MIRROR.md), process both the `.ja/` side and the English side in the same session. Rewriting one side alone breaks the mirror |

## The help output is authoritative

Options, output format and exit codes live in `ast-grep --help` and `ast-grep <subcommand> --help`. Where help and memory differ, help is right.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.