ast-grep
Guide for writing ast-grep rules to perform structural code search and analysis. Use when users need to search codebases using…
Use when exploring or modifying a codebase and you need a cheap structural map of files, directories, imports, exports, or direct members before reading full source.
Claude Code
$ npx -y skills add ast-grep/agent-skill --skill outline --agent claude-code
Codex
$ npx skills add ast-grep/agent-skill --skill outline -a codex -y
Cursor
$ npx skills add ast-grep/agent-skill --skill outline -a cursor -y
Gemini CLI
$ npx skills add ast-grep/agent-skill --skill outline -a gemini-cli -y
GitHub Copilot
$ npx skills add ast-grep/agent-skill --skill outline -a github-copilot -y
OpenCode
$ npx skills add ast-grep/agent-skill --skill outline -a opencode -y
Windsurf
$ npx skills add ast-grep/agent-skill --skill outline -a windsurf -y
name: ast-grep-outline description: Use when exploring or modifying a codebase and you need a cheap structural map of files, directories, imports, exports, or direct members before reading full source.
`ast-grep outline` prints a structural map of source code with line numbers: top-level declarations (imports, functions, classes, structs, interfaces, modules, enums) and their direct **members** (fields, methods, constructors, enum variants). It is a local, syntax-only view — cheap enough to run before any full file read.
Read code in stages: find candidate files with search or file names, outline them, then open only the source range the outline points to. Defaults adapt to input: a file shows its local structure with member digests; a directory shows only its exported surface as grouped names.
**Understand a file before editing.** Get a table of contents, dependencies, and public entry points before reading implementation details:
ast-grep outline <file> ast-grep outline <file> --items imports ast-grep outline <file> --items exports
**Map an unfamiliar directory.** Scan the public surface of a subtree, then narrow by symbol type when you know what you are looking for:
ast-grep outline <dir> --items exports ast-grep outline <dir> --type struct,enum,function
**Zoom into a known symbol.** After search finds a likely name, list its members with line numbers instead of reading the whole body:
ast-grep outline <file> --match <symbol> --type class --view expanded
**Trace dependency direction.** Find which files import a package or module to decide where a change belongs:
ast-grep outline <dir> --items imports --view signatures
**Review changed files after editing.** Git tells you what changed; outline summarizes the resulting structure and public surface:
ast-grep outline $(git diff --name-only HEAD) --items exports
`exports` for public API, `imports` for dependencies, `all` when import/export edges matter together. The default, `auto`, picks `structure` for a file and `exports` for a directory. No other value is accepted; to keep only functions, classes, or another symbol kind, use `--type`.
scans, `signatures` for one line per item, `digest` for signatures plus member names, `expanded` for one line per member with its line number. The default, `auto`, picks one from the input path. No other value is accepted.
case-sensitive; it never matches members.
`--type class,function`. Member types like `method,field` never match top-level items.
only to pipe or post-process entries; prefer text for navigation.
`outline` shows local syntax structure. It does not resolve references, infer types, follow re-export chains, or build a call graph. Use `ast-grep run`, `rg`, or compiler-backed tools for those questions, then outline the candidate files they surface.
A Claude Code plugin marketplace containing the ast-grep skill for powerful structural code search using Abstract Syntax Tree (AST) patterns. Search your codebase based on code structure rather than just text matching.
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.