ast-grep Structural Search
code-yeongyu/oh-my-openagent
Searches and rewrites code by syntax-tree shape across 25 languages with ast-grep, for codemods, structural queries and YAML lint rules, using a Python wrapper script.
Turns natural-language code queries into ast-grep rules for structural search, testing each rule against an example file before running it on a codebase.
$ npx skills add warp-drive-data/warp-drive --skill ast-grep -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install warp-drive-data/warp-drive ast-grep --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/warp-drive-data/warp-drive.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/ast-grep .claude/skills/ast-grep && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "ast-grep" agent skill from https://github.com/warp-drive-data/warp-drive/tree/main/.claude/skills/ast-grep into .claude/skills/ast-grep/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "ast-grep", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/warp-drive-data/warp-drive/tree/main/.claude/skills/ast-grepType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add warp-drive-data/warp-drive --skill ast-grep -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install warp-drive-data/warp-drive ast-grep --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/warp-drive-data/warp-drive.git skills-src && mkdir -p .agents/skills && cp -r skills-src/.claude/skills/ast-grep .agents/skills/ast-grep && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "ast-grep" agent skill from https://github.com/warp-drive-data/warp-drive/tree/main/.claude/skills/ast-grep into .agents/skills/ast-grep/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "ast-grep", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add warp-drive-data/warp-drive --skill ast-grep -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install warp-drive-data/warp-drive ast-grep --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/warp-drive-data/warp-drive.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/.claude/skills/ast-grep .cursor/skills/ast-grep && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "ast-grep" agent skill from https://github.com/warp-drive-data/warp-drive/tree/main/.claude/skills/ast-grep into .cursor/skills/ast-grep/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "ast-grep", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/warp-drive-data/warp-drive.git --path .claude/skills/ast-grep--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add warp-drive-data/warp-drive --skill ast-grep -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install warp-drive-data/warp-drive ast-grep --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/warp-drive-data/warp-drive.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/.claude/skills/ast-grep .gemini/skills/ast-grep && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "ast-grep" agent skill from https://github.com/warp-drive-data/warp-drive/tree/main/.claude/skills/ast-grep into .gemini/skills/ast-grep/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "ast-grep", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install warp-drive-data/warp-drive ast-grepInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add warp-drive-data/warp-drive --skill ast-grep -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/warp-drive-data/warp-drive.git skills-src && mkdir -p .github/skills && cp -r skills-src/.claude/skills/ast-grep .github/skills/ast-grep && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "ast-grep" agent skill from https://github.com/warp-drive-data/warp-drive/tree/main/.claude/skills/ast-grep into .github/skills/ast-grep/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "ast-grep", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add warp-drive-data/warp-drive --skill ast-grep -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install warp-drive-data/warp-drive ast-grep --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/warp-drive-data/warp-drive.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/.claude/skills/ast-grep .opencode/skills/ast-grep && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "ast-grep" agent skill from https://github.com/warp-drive-data/warp-drive/tree/main/.claude/skills/ast-grep into .opencode/skills/ast-grep/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "ast-grep", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
ast-grepTurns natural-language code queries into ast-grep rules for structural search, testing each rule against an example file before running it on a codebase.
ast-grep matches code by its syntax tree rather than plain text, so it can answer questions such as which async functions lack error handling or which calls use particular arguments. The skill converts a request into a rule through a fixed workflow: clarify what to find and in which language, write a small example snippet to a temporary file, write the rule starting simple, test it against the example, and then search the real code.
Key principles are to set stopBy: end on relational rules such as inside and has so the search runs to the end of its direction, to use pattern for simple structures and kind with has or inside for complex ones, and to break big queries into sub-rules with all, any and not. Rules can be tested inline for quick iteration or from a rule file such as test_rule.yml, and references/rule_reference.md holds the full rule documentation. It also applies when working with @ast-grep/napi.
5 steps, taken from the step headings in SKILL.md.
Read from SKILL.md and the folder at commit 34ad57e. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
No scripts in the folder and no shell commands in SKILL.md (its code samples are bash, yaml and javascript).
From the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Structural Code Search with ast-grep loads about 2.4k tokens when it runs, and up to ~5k if it reads all its reference files. Until then it costs about 120 tokens; SKILL.md has 835 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from warp-drive-data/warp-drive at commit 34ad57e, republished under its MIT licence (© warp-drive-data). 835 words, ~2,370 tokens.
.claude/skills/ast-grep/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.This skill helps translate natural language queries into ast-grep rules for structural code search. ast-grep uses Abstract Syntax Tree (AST) patterns to match code based on its structure rather than just text, enabling powerful and precise code search across large codebases.
Use this skill when users:
Follow this process to help users write effective ast-grep rules:
Clearly understand what the user wants to find. Ask clarifying questions if needed:
Write a simple code snippet that represents what the user wants to match. Save this to a temporary file for testing.
Example: If searching for "async functions that use await", create a test file:
// test_example.js
async function example() {
const result = await fetchData();
return result;
}Translate the pattern into an ast-grep rule. Start simple and add complexity as needed.
Key principles:
stopBy: end for relational rules (inside, has) to ensure search goes to the end of the directionpattern for simple structureskind with has/inside for complex structuresall, any, or notExample rule file (test_rule.yml):
id: async-with-await
language: javascript
rule:
kind: function_declaration
has:
pattern: await $EXPR
stopBy: endSee references/rule_reference.md for comprehensive rule documentation.
Use ast-grep CLI to verify the rule matches the example code. There are two main approaches:
Option A: Test with inline rules (for quick iterations)
echo "async function test() { await fetch(); }" | ast-grep scan --inline-rules "id: test
language: javascript
rule:
kind: function_declaration
has:
pattern: await \$EXPR
stopBy: end" --stdinOption B: Test with rule files (recommended for complex rules)
ast-grep scan --rule test_rule.yml test_example.jsDebugging if no matches:
stopBy: end to relational rules if not present--debug-query to understand the AST structure (see below)kind values are correct for the languageOnce the rule matches the example code correctly, search the actual codebase:
For simple pattern searches:
ast-grep run --pattern 'console.log($ARG)' --lang javascript /path/to/projectFor complex rule-based searches:
ast-grep scan --rule my_rule.yml /path/to/projectFor inline rules (without creating files):
ast-grep scan --inline-rules "id: my-rule
language: javascript
rule:
pattern: \$PATTERN" /path/to/projectDump the AST structure to understand how code is parsed:
ast-grep run --pattern 'async function example() { await fetch(); }' \
--lang javascript \
--debug-query=cstAvailable formats:
cst: Concrete Syntax Tree (shows all nodes including punctuation)ast: Abstract Syntax Tree (shows only named nodes)pattern: Shows how ast-grep interprets your patternUse this to:
kind values for nodesExample:
# See the structure of your target code
ast-grep run --pattern 'class User { constructor() {} }' \
--lang javascript \
--debug-query=cst
# See how ast-grep interprets your pattern
ast-grep run --pattern 'class $NAME { $$$BODY }' \
--lang javascript \
--debug-query=patternTest a rule against code snippet without creating files:
echo "const x = await fetch();" | ast-grep scan --inline-rules "id: test
language: javascript
rule:
pattern: await \$EXPR" --stdinAdd --json for structured output:
echo "const x = await fetch();" | ast-grep scan --inline-rules "..." --stdin --jsonSimple pattern-based search for single AST node matches:
# Basic pattern search
ast-grep run --pattern 'console.log($ARG)' --lang javascript .
# Search specific files
ast-grep run --pattern 'class $NAME' --lang python /path/to/project
# JSON output for programmatic use
ast-grep run --pattern 'function $NAME($$$)' --lang javascript --json .When to use:
YAML rule-based search for complex structural queries:
# With rule file
ast-grep scan --rule my_rule.yml /path/to/project
# With inline rules
ast-grep scan --inline-rules "id: find-async
language: javascript
rule:
kind: function_declaration
has:
pattern: await \$EXPR
stopBy: end" /path/to/project
# JSON output
ast-grep scan --rule my_rule.yml --json /path/to/projectWhen to use:
Tip: For relational rules (inside/has), always add stopBy: end to ensure complete traversal.
For relational rules, always use stopBy: end unless there's a specific reason not to:
has:
pattern: await $EXPR
stopBy: endThis ensures the search traverses the entire subtree rather than stopping at the first non-matching node.
Begin with the simplest rule that could work:
pattern firstkind to match the node typehas, inside) as neededall, any, not) for complex logicconsole.log($ARG))When rules don't match:
--debug-query=cst to see the actual AST structurekind matches what you expectWhen using --inline-rules, escape metavariables in shell commands:
\$VAR instead of $VAR (shell interprets $ as variable)'$VAR' works in most shellsExample:
# Correct: escaped $
ast-grep scan --inline-rules "rule: {pattern: 'console.log(\$ARG)'}" .
# Or use single quotes
ast-grep scan --inline-rules 'rule: {pattern: "console.log($ARG)"}' .Find async functions that use await:
ast-grep scan --inline-rules "id: async-await
language: javascript
rule:
all:
- kind: function_declaration
- has:
pattern: await \$EXPR
stopBy: end" /path/to/projectFind console.log inside class methods:
ast-grep scan --inline-rules "id: console-in-class
language: javascript
rule:
pattern: console.log(\$\$\$)
inside:
kind: method_definition
stopBy: end" /path/to/projectFind async functions without try-catch:
ast-grep scan --inline-rules "id: async-no-trycatch
language: javascript
rule:
all:
- kind: function_declaration
- has:
pattern: await \$EXPR
stopBy: end
- not:
has:
pattern: try { \$\$\$ } catch (\$E) { \$\$\$ }
stopBy: end" /path/to/projectContains detailed documentation for ast-grep rule syntax:
rule_reference.md: Comprehensive ast-grep rule documentation covering atomic rules, relational rules, composite rules, and metavariablesLoad these references when detailed rule syntax information is needed.
© warp-drive-data, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
SKILL.md and 1 other file (references) in .claude/skills/ast-grep of warp-drive-data/warp-drive.
Open the folder on GitHubat commit 34ad57e
We found 5 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 5 other GitHub owners. This page covers the copy in warp-drive-data/warp-drive, which our catalogue first saw on October 7, 2026.
Structural Code Search with ast-grep next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Structural Code Search with ast-grep this skillwarp-drive-data/warp-drive | 3.2k | 5 repos | ~2.4k | Automated safety check: Pass | MIT | |
| ast-grep Structural Searchcode-yeongyu/oh-my-openagent | 70k | — | ~3.3k | Automated safety check: Pass | MIT | |
| Eslint Migrate Optionsbiomejs/biome | 26k | — | ~1.4k | Automated safety check: Pass | Apache-2.0 | |
| New Rule for sonar-javaSonarSource/sonar-java | 1.2k | — | ~833 | Automated safety check: Pass | Custom licence | |
| Openqodexopenqodex/openqodex | 470 | — | ~2.4k | Automated safety check: Pass | Apache-2.0 | |
| Gograph Go Repository Intelligenceozgurcd/gograph | 228 | — | ~4.8k | Automated safety check: Notes | MIT |
code-yeongyu/oh-my-openagent
Searches and rewrites code by syntax-tree shape across 25 languages with ast-grep, for codemods, structural queries and YAML lint rules, using a Python wrapper script.
biomejs/biome
A skill your agent uses when biome migrate eslint must preserve configurable ESLint rule options through source-option models, Biome conversions, typed rule variants, and migration fixtures.
SonarSource/sonar-java
Sets the sonar-java conventions for adding an analyzer rule: metadata from rule-api, test locations, MethodMatchers and what not to commit or change.
openqodex/openqodex
Code review for the current change, before it is pushed. An agent skill from openqodex/openqodex.
ozgurcd/gograph
Gives an agent working in a Go codebase a structural view through a local MCP server: call graphs, blast-radius and impact analysis, and bounded first-call exploration.
samber/cc-skills-golang
GitHub Actions CI/CD pipeline configuration for Golang projects — workflow files for test, lint, SAST, coverage and vulnerability-scan jobs, Dependabot and Renovate config files, GoReleaser release…
warp-drive-data/warp-drive
Reference for writing and debugging TypeScript and JavaScript codemods with @ast-grep/napi: parsing, node queries, meta-variables, rule objects and editing.
warp-drive-data/warp-drive
Ensures `.mock-cache` fixture directories under `tests/*` are staged and committed whenever a change adds or modifies a test that uses…
Categories
Turns natural-language code queries into ast-grep rules for structural search, testing each rule against an example file before running it on a codebase. ast-grep matches code by its syntax tree rather than plain text, so it can answer questions such as which async functions lack error handling or which calls use particular arguments. The skill converts a request into a rule through a fixed workflow: clarify what to find and in which language, write a small example snippet to a temporary file, write the rule starting simple, test it against the example, and then search the real code.
Structural Code Search with ast-grep fits situations like: finding every async function without error handling across a codebase; locating calls to a function with particular arguments; writing and debugging a new ast-grep rule in YAML; code queries that plain text search cannot express.
Run `npx skills add warp-drive-data/warp-drive --skill ast-grep -a claude-code`. Or copy the skill folder (.claude/skills/ast-grep in warp-drive-data/warp-drive) into .claude/skills/ast-grep in your project. Claude Code loads it when a task matches its description.
Run `npx skills add warp-drive-data/warp-drive --skill ast-grep -a codex`. Or copy the skill folder (.claude/skills/ast-grep in warp-drive-data/warp-drive) into .agents/skills/ast-grep in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add warp-drive-data/warp-drive --skill ast-grep -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/ast-grep, .gemini/skills/ast-grep, .github/skills/ast-grep and .opencode/skills/ast-grep in your project.
SKILL.md names no scripts, command-line tools or credentials: Structural Code Search with ast-grep is instructions for the agent only. Our summary lists: The ast-grep CLI.
SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Structural Code Search with ast-grep is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 2.4k tokens (SKILL.md is roughly 9.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 2.7k tokens, read only when the agent opens those files.
Skills that share tags, products or a category with Structural Code Search with ast-grep: ast-grep Structural Search (code-yeongyu/oh-my-openagent, 70k stars), Eslint Migrate Options (biomejs/biome, 26k stars), New Rule for sonar-java (SonarSource/sonar-java, 1.2k stars) and Openqodex (openqodex/openqodex, 470 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
warp-drive-data (a GitHub organization) maintains it in warp-drive-data/warp-drive, which has 3,158 GitHub stars. The repository holds 3 skills in this directory. The repository was last updated on October 9, 2026.
Source: warp-drive-data/warp-drive on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.