masih-0x3/agent-skills/ast-grep

Claude Code and agent skill by masih-0x3/agent-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Use for AST-aware code search, syntax-shaped matching, codemods, API migrations, repeated structured edits, or refactors where text grep may overmatch or miss language structure.

Install

npx vskill@latest install masih-0x3/agent-skills/ast-grep

SKILL.md

The same SKILL.md was published earlier as masih-0x3/agent-skills/ast-grep.

AST Grep

Use AST-aware search when the question is about code shape, not just text. rg remains the default for plain strings; ast-grep is for syntax.

When To Use

Use this skill when:

  • Finding call sites by syntactic shape.
  • Searching for imports, JSX props, function calls, decorators, object patterns, assignments, or API usage.
  • Planning or applying a mechanical codemod.
  • Refactoring repeated code structures across files.
  • Avoiding false positives from comments, strings, generated files, or unrelated identifiers.

Skip this skill when:

  • A simple rg or rg --files query answers the question.
  • The language is unsupported or the repo lacks enough files for AST matching to pay off.
  • The task needs semantic call flow or impact analysis; use codegraph first when available.

Workflow

  1. Define the code shape in words before writing the pattern.
  2. Start with rg or rg --files if needed to identify languages and candidate directories.
  3. Choose the language/parser explicitly when the tool requires it.
  4. Test the AST pattern on a small scope first.
  5. Inspect matches before changing files.
  6. For codemods:
  • run a dry run or JSON/listing mode first.
  • apply changes to the narrowest safe file set.
  • inspect the diff.
  • run tests/typecheck/lint relevant to the changed language.

Pattern Discipline

  • Prefer concrete syntax over broad wildcards.
  • Exclude generated/build/vendor directories.
  • Avoid matching comments and strings unless that is the target.
  • Keep replacement patterns minimal.
  • If the pattern is brittle, stop and use manual edits or CodeGraph-assisted navigation.

Tool Notes

Common command shapes:

bash
ast-grep --lang ts -p '<pattern>' <path>
ast-grep --lang tsx -p '<pattern>' <path>
ast-grep --lang js -p '<pattern>' <path>

Use the installed tool's help output for exact flags. Some versions differ on JSON, rewrite, and update flags.

Guardrails

  • Do not apply a codemod without inspecting candidate matches.
  • Do not run broad rewrites over the whole home directory or unrelated workspaces.
  • Do not treat a clean AST search as proof of runtime behavior.
  • Preserve unrelated user changes.

Closeout

text
AST-grep:
- Shape searched:
- Scope:
- Matches:
- Changes applied:
- Validation:

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/masih-0x3/agent-skills/ast-grep/badge)](https://verified-skill.com/skills/masih-0x3/agent-skills/ast-grep)

Something wrong with this skill or its page? Tell us.