# ast-grep

This skill uses the ast-grep CLI to find code by syntax. Use it when a text or regex search cannot express the structure you need.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 148 installs · ★ 5 repo stars
- Author: ulpi-io
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/ulpi-io/skills/tree/HEAD/ast-grep/SKILL.md
- Updated: 2026-08-31
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/ulpi-io-ast-grep

## What it does

The skill turns a description of a code shape into an `ast-grep` rule. It can use patterns, node kinds, metavariables, and `inside` or `has` relationships. Before searching a repository, the agent checks that the CLI is installed, builds a small example, and tests the rule against it. When the tree shape is unclear, it inspects it with `--debug-query`.

Once the rule passes the example, the agent searches the codebase and checks the match count and sample results. Its report includes the language, rule type, representative file paths and lines, plus a reusable rule or command. The `ast-grep` CLI must be installed first; without it, this workflow stops. For plain text searches, use `Grep` instead.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add ulpi-io/skills --skill ast-grep -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/ast-grep/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/ast-grep/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add ulpi-io/skills --skill ast-grep -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/ast-grep/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add ulpi-io/skills --skill ast-grep -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/ast-grep/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install ulpi-io/skills ast-grep
```

2. **Manually: put the files in place**
- File: `.github/skills/ast-grep/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add ulpi-io/skills --skill ast-grep -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/ulpi-io/skills --path ast-grep
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/ast-grep/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add ulpi-io/skills --skill ast-grep -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/ulpi-io/skills/tree/HEAD/ast-grep/SKILL.md

## When to use it
- find async functions that lack `try/catch`
- spot conditional calls to React hooks
- locate calls with a specified syntax shape
- test a search rule on a sample before scanning the repository

## Example prompts
- Find async functions without `try/catch` in this project; test the rule on a small example first.
- Look for conditional React hook calls and verify the search against an example.
- Create an `ast-grep` rule for calls shaped like this, then report matching files and lines.

## Similar
- [ast-grep-outline](https://affpapa.org/en/nevibecode/skills/ast-grep-outline.md) — skill · 2800 installs
- [codegraph-ast-grep](https://affpapa.org/en/nevibecode/skills/codegraph-ast-grep.md) — skill · 2800 installs
- [ast-grep-find](https://affpapa.org/en/nevibecode/skills/ast-grep-find.md) — skill · 524 installs
- [file-search](https://affpapa.org/en/nevibecode/skills/file-search.md) — skill · 549 installs
- [search-hierarchy](https://affpapa.org/en/nevibecode/skills/search-hierarchy.md) — skill · ★ 3951 repo stars
- [Vercel Grep](https://affpapa.org/en/nevibecode/mcp/vercel-grep.md) — MCP server · 1219 installs

## Other versions with the same name
- [ast-grep · ast-grep](https://affpapa.org/en/nevibecode/skills/ast-grep.md) — 20100 installs
- [ast-grep · pproenca](https://affpapa.org/en/nevibecode/skills/pproenca-ast-grep.md) — 346 installs
- [ast-grep · skempken](https://affpapa.org/en/nevibecode/skills/skempken-ast-grep.md) — 1 install

From the same set: [ulpi-io/skills](https://affpapa.org/en/nevibecode/by/ulpi-io/skills.md) — 49 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
