Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

ast-grep — Claude Code skill for structural code search

This skill helps turn code-search requests into ast-grep rules. Use it when you need to find code by its structure rather than by matching text.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add ast-grep/agent-skill --skill ast-grep -a claude-code
Open on GitHub

What ast-grep does

The skill translates a plain-language request into an ast-grep rule. It starts by clarifying the language and the structures to include or exclude, then suggests testing the rule against a small code example. Complex queries can combine YAML rules such as pattern, kind, has, inside, all, any, and not.

Test a rule with ast-grep scan, then search a project with ast-grep run or ast-grep scan. The guide also covers inspecting parsed code with --debug-query and reading --json results. You need the ast-grep CLI installed; without it, the command-line checks in the guide cannot run.

What it helps with

  • find async functions without error handling
  • locate function calls with specific arguments
  • match language constructs by AST structure
  • test a search rule against a code snippet

Example prompts for the agent

  • Find async functions without error handling in this project and write an ast-grep rule for them.
  • Locate JavaScript calls to `fetchData` with these arguments.
  • Test this ast-grep rule against the snippet and explain why it returns no matches.

How to install ast-grep

1Skills CLI (Vercel)

npx skills add ast-grep/agent-skill --skill ast-grep -a claude-code

2Manually: put the files in place

~/.claude/skills/ast-grep/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/ast-grep/

Similar

ce-code-review EveryInc Reviews a named diff or pull request for bugs, regressions, tests, and project standards. Use it for a current branch review or a specific PR. Claude Code CX Codex Cursor +1 3,700installs ce-work EveryInc Executes a plan document or build spec end-to-end with local verification. Ideal for implementing features without reopening architectural debates. Claude Code CX Codex Cursor +1 3,600installs ce-doc-review EveryInc This skill reviews requirements, plans, and specs through role-based reviewers. Use it to catch consequential issues in an existing document and apply fixes within the granted authority. Claude Code CX Codex Cursor +1 3,600installs hunk-review modem-dev Controls live Hunk diff review sessions via CLI to inspect focus, navigate hunks and lines, and post inline review comments. Claude Code CX Codex Cursor +1 1,800installs evaluation-methodology Seth Hobson Reference guide for the PluginEval quality framework. Explains scoring formulas, anti-pattern penalties, and multi-layer checks for agent skills. Claude Code CX Codex Cursor 7,200installs lfg EveryInc Takes a request from intake to a finished result and opens a pull request for code changes. Use it when the user explicitly wants autonomous end-to-end work. Claude Code CX Codex Cursor +1 3,500installs improve-codebase-architecture Matt Pocock This skill scans a codebase for architectural friction, then builds a visual HTML report with refactoring candidates. Use it before a deeper architecture review. Claude Code 1,163,035installs tdd Matt Pocock Guides the red-green TDD loop: ensures tests are written first, keep them at public interfaces, and avoid coupling to implementation details. Claude Code 1,141,062installs

Questions about ast-grep

How do I install ast-grep in Claude Code?

Run npx skills add ast-grep/agent-skill --skill ast-grep -a claude-code. This installs the skill for Claude Code.

What does the ast-grep skill do?

It helps write and test structural search rules, then apply them to a codebase with the ast-grep CLI.

What do I need to test ast-grep rules?

The guide uses the ast-grep CLI. You can test a rule on a snippet with scan --stdin or run it against files and a project.

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor