Guide for writing ast-grep rules to perform structural code search and analysis. Use when users need to search codebases using Abstract Syntax Tree (AST) patterns, find specific code structures, or perform complex code queries that go beyond simple text search.
安装
npx skills add ast-grep/agent-skill --skill ast-grepnpx skills add ast-grep/agent-skill --skill ast-grep -a claude-code -gnpx skills add ast-grep/agent-skill --skill ast-grep -a codex -ggemini skills install https://github.com/ast-grep/agent-skill.git --path ast-grep/skills/ast-grepgh skill install ast-grep/agent-skill ast-grepgit clone --depth 1 https://github.com/ast-grep/agent-skill /tmp/ast-grep__agent-skill
mkdir -p ~/.claude/skills ~/.agents/skills
cp -R /tmp/ast-grep__agent-skill/ast-grep/skills/ast-grep ~/.claude/skills/ast-grep # Claude Code
cp -R /tmp/ast-grep__agent-skill/ast-grep/skills/ast-grep ~/.agents/skills/ast-grep # Codex, Cursor, Gemini CLI, Copilot, OpenCode