ast-grep
Skill10 starsChanged 56 days agoMITView on GitHub
Search, outline, and rewrite code structurally with ast-grep rules.
13 other projects use a version of this.
Adopted by
Most recently taken up by
- moeru-ai/auvtheir own version, first seen Oct 4, 2026
- oldwinter/skillstheir own version, first seen Sep 26, 2026
- nodetool-ai/nodetooltheir own version, first seen Sep 20, 2026
- coleam00/skillstheir own version, first seen Sep 17, 2026
- hughdbrown/claude-skillstheir own version, first seen Sep 4, 2026
- shalomb/agent-skillstheir own version, first seen Aug 23, 2026
Used with
Projects with it also use research, tdd and 1 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
DockerSkillresearch
Research a documentation topic — locate affected files, understand the problem, identify what to change. Use when investigating an issue, a question, or a topic before writing a fix. Triggers on: "research issue 1234", "investigate what needs changing for #500", "what files are affected by #200", "where is X documented", "is our docs page about Y accurate", "look into how we document Z".
Also in 3 projects that use this
AWSSkilltdd
Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
Also in 3 projects that use this
MicrosoftSkillskill-creator
Guide for creating effective GitHub Copilot skills (.github/skills/) in this repository. Use when creating a new skill, updating an existing skill, or when asked about skill structure, format, or best practices for the vscode-documentdb project.
Also in 3 projects that use this
Other versions13 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 13
- coleam00/skills★ 663same name
- nodetool-ai/nodetool★ 551same name
- damusix/skills★ 62same name
- moeru-ai/auv★ 55same name
- oldwinter/skills★ 8same name
- drunkcoding/AgentSkillsArxiv★ 4same name
- rolandbrecht/agent-skills★ 4same name
- tentacle-pro/skills★ 4same name
- shalomb/agent-skills★ 3same name
- tizee/skills★ 2same name
3 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository101 other files it gives its agents.
- AGENTS.mdAGENTS.md
- dot_agents/AGENTS.mdAGENTS.md
- skills/agent-project/templates/AGENTS.mdAGENTS.md
- skills/repository-docs/references/agents.mdAGENTS.md
- chezmoiSkill
- dot-developmentSkill
- dot-releaseSkill
- dot-skillsSkill
- dot-verifySkill
- acliSkill
- agent-evaluationSkill
- agent-frameworksSkill
- agent-harnessesSkill
- agent-loopsSkill
- agent-projectSkill
- agent-protocolsSkill
- agent-usageSkill
- agySkill
- airflowSkill
- ai-security-assessmentSkill
- api-clientSkill
- auth-statusSkill
- awsSkill
- benchmarkSkill
- bfSkill
- chrome-devtoolsSkill
- cli-developmentSkill
- clipboardSkill
- cloud-runSkill
- code-securitySkill
- colabSkill
- containerizeSkill
- course-developmentSkill
- databricksSkill
- data-migrationSkill
- delegate-tasksSkill
- diagrams-as-codeSkill
- dockerSkill
- documentation-siteSkill
- dot-cliSkill
- dprintSkill
- draft-mailSkill
- duckdbSkill
- fact-checkSkill
- fmind-visualsSkill
- full-reviewSkill
- gcloudSkill
- ghSkill
- git-deliverySkill
- github-actionsSkill
- github-issuesSkill
- github-pull-requestSkill
- github-repositorySkill
- git-worktreeSkill
- google-developerSkill
- gwsSkill
- handoffSkill
- hfSkill
- implementation-planSkill
- incident-responseSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 0 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 13 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 33
Rewrite in two steps: add -r to see the diff, then --update-all (or -i for an interactive session).
- Very specific: line 35
Wire into the gate: run ast-grep scan inside check:lint (see mise) so hooks and CI apply the same rules.
“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
ast-grep
Structural code search and rewrite: a pattern is real code with meta-variables, matched against the syntax tree. A call-expression pattern distinguishes a call from similar text inside a string or comment; string and comment nodes can also be matched deliberately. Use it where rg gives false positives; plain text search stays with rg.
Commands
ast-grep outline -l python src/ # symbols, imports, and members per file
ast-grep run -p 'print($$$ARGS)' -l python src/ # scope search to the relevant source
ast-grep run -p 'print($$$ARGS)' -r 'logger.info($$$ARGS)' -l python src/ # dry run: prints the diff, changes nothing
ast-grep run -p 'print($$$ARGS)' -r 'logger.info($$$ARGS)' -l python --update-all src/ # apply after reviewing the dry run (-i to confirm per hunk)
ast-grep run -p 'os.getenv($KEY)' -l python --json=compact src/ # structured output after narrowing paths
ast-grep scan # every rule in sgconfig.yml
ast-grep scan -r rules/no-print.yml --format github # one rule file; GitHub annotations in CIWorkflow
- Write the pattern as code:
$NAMEmatches one node,$$$NAMEa sequence (arguments, statements),$_a node without binding; always pass-l <lang>so the pattern parses in the right grammar, and use--debug-query=astwhen a pattern that should match does not. - Search first: map unfamiliar files with
ast-grep outlinebefore reading full source; pass the relevant path or--globs; use--files-with-matcheswhen only filenames are needed, then read selected matches with-C 2. Use JSON only for structured processing. Widen scope deliberately, and use--no-ignore vcs(orhidden; the flag requires a value) only when skipped files are relevant. - Rewrite in two steps: add
-rto see the diff, then--update-all(or-ifor an interactive session); captured meta-variables are reused in the replacement. - Promote to a rule: for a lint or a repeated refactor,
ast-grep new projectscaffoldssgconfig.ymlandrules/; a rule file hasid,language,rule(pattern,kind,inside,has,not), optionalfix,severity, andmessage;ast-grep testruns itsvalidandinvalidcases. - Wire into the gate: run
ast-grep scaninsidecheck:lint(see mise) so hooks and CI apply the same rules.
Gotchas
- Meta-variables are uppercase:
$ais plain text;$A,$ARGS,$_are meta-variables. - Pattern must be a complete node:
foo(does not parse; matchfoo($$$)and narrow with--selector. - Rewrites replace the whole node:
-rreplaces the whole matched node, not a substring inside it. - Syntax is not name resolution: inspect imports, aliases, and shadowed names before rewriting; identical syntax can refer to different functions.
- Pass
-lfor inline patterns: pass-l pythonfor inline patterns; underscan, the.pyextension selects the grammar.
Official Skills
Upstream: ast-grep/agent-skill ships ast-grep (structural search) and ast-grep-outline (codebase map); preview the same-name upstream ast-grep instead of installing it (vendor-skill policy); the rest follow the same policy.
Documentation
- ast-grep guide · Pattern syntax · Rule reference · Languages
- Releases: ast-grep · changelog
- Companion skills: repository-maintenance (repository simplification), python-stack (Python quality gate).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

