agentleFS
Masih-0x3Masih-0x3/agent-skills/skills/ast-grep/SKILL.md

ast-grep

Skill0 starsChanged 3 months agoMITView on GitHub

Use for AST-aware code search, syntax-shaped matching, codemods, API migrations, repeated structured edits, or refactors where text grep may overmatch or miss language structure.

27 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use ablate-ai-layer, second-brain-audit and 6 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.
  • acgs-aiSkill

    ablate-ai-layer

    Measure whether a repository's AI instructions still earn their place, by running the same real task many times with the layer intact and with it stripped, then grading every rule against what actually changed. Runs both arms itself in throwaway git worktrees and never touches the working tree. Agent-agnostic across CLAUDE.md, AGENTS.md, .claude/, .agents/, .cursor/rules, .clinerules, .windsurfrules and copilot-instructions. Use when the user wants to prune, audit, clean up, shrink or "delete" their CLAUDE.md, AGENTS.md, cursor rules, agent instructions or AI layer; when they ask whether their rules are still needed, whether their context is bloated, or what to cut; or when they mention ablating, ablation, or testing their agent without its instructions.

    Also in 3 projects that use this

  • acgs-aiSkill

    second-brain-audit

    Audit any second brain, notes folder, or agent memory for facts that have quietly stopped being true, then fix the worst one so it stops recurring. Works on a wiki, a single notes file, daily notes, or a non-markdown tool, and adapts the fix to whichever it finds. Checks every current-sounding claim in whatever the agent loads each session against the freshest evidence, and separates contradicted claims from unsupported ones. Use when an assistant gives an outdated answer, when notes or memory files may be stale, when a vault needs checking for contradictions, or when someone asks how to stop a second brain from rotting, mentions memory rot, or asks about state versus event.

    Also in 3 projects that use this

  • MicrosoftSkill

    rust

    Use this guide when working on Rust changes in the FAST monorepo.

    Also in 3 projects that use this

  • SentrySkill

    create-pr

    Create pull requests following Sentry conventions. Use when opening PRs, writing PR descriptions, or preparing changes for review. Follows Sentry's code review guidelines.

    Also in 4 projects that use this

  • VercelSkill

    agent-browser

    Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.

    Also in 4 projects that use this

  • SentrySkill

    skill-creator

    Create new agent skills following the Agent Skills specification. Use when asked to "create a skill", "add a new skill", "write a skill", "make a skill", "build a skill", or scaffold a new skill with SKILL.md. Guides through requirements, writing, registration, and verification.

    Also in 7 projects that use this

  • +1 more from acgs-ai
  • +1 more from getsentry

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. 0 are common, 11 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 25 edited versions we read keep these.

  • 11

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use AST-aware search when the question is about code shape, not just text.

    line 8
  2. Distinctive:

    Use this skill when:

    line 12
  3. Very specific:

    Start with rg or rg --files if needed to identify languages and candidate directories.

    line 29
  4. Distinctive:

    Test the AST pattern on a small scope first.

    line 31
  5. Distinctive:

    run a dry run or JSON/listing mode first.

    line 34
  6. Very specific:

    run tests/typecheck/lint relevant to the changed language.

    line 37
  7. Distinctive:

    Prefer concrete syntax over broad wildcards.

    line 41
  8. Distinctive:

    Avoid matching comments and strings unless that is the target.

    line 43
  9. Distinctive:

    Keep replacement patterns minimal.

    line 44
  10. Distinctive:

    If the pattern is brittle, stop and use manual edits or CodeGraph-assisted navigation.

    line 45
  11. Distinctive:

    Use the installed tool's help output for exact flags.

    line 57
  12. Distinctive:

    Do not apply a codemod without inspecting candidate matches.

    line 61
  13. Distinctive:

    Do not run broad rewrites over the whole home directory or unrelated workspaces.

    line 62
  14. Distinctive:

    Do not treat a clean AST search as proof of runtime behavior.

    line 63

“Common” is measured: kept by at least 6 in 10 of the 25 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

AST Grep

Use AST-aware search when the question is about code shape, not just text. rg remains the default for plain strings; ast-grep is for syntax.

When To Use

Use this skill when:

  • Finding call sites by syntactic shape.
  • Searching for imports, JSX props, function calls, decorators, object patterns, assignments, or API usage.
  • Planning or applying a mechanical codemod.
  • Refactoring repeated code structures across files.
  • Avoiding false positives from comments, strings, generated files, or unrelated identifiers.

Skip this skill when:

  • A simple rg or rg --files query answers the question.
  • The language is unsupported or the repo lacks enough files for AST matching to pay off.
  • The task needs semantic call flow or impact analysis; use codegraph first when available.

Workflow

  1. Define the code shape in words before writing the pattern.
  2. Start with rg or rg --files if needed to identify languages and candidate directories.
  3. Choose the language/parser explicitly when the tool requires it.
  4. Test the AST pattern on a small scope first.
  5. Inspect matches before changing files.
  6. For codemods:
    • run a dry run or JSON/listing mode first.
    • apply changes to the narrowest safe file set.
    • inspect the diff.
    • run tests/typecheck/lint relevant to the changed language.

Pattern Discipline

  • Prefer concrete syntax over broad wildcards.
  • Exclude generated/build/vendor directories.
  • Avoid matching comments and strings unless that is the target.
  • Keep replacement patterns minimal.
  • If the pattern is brittle, stop and use manual edits or CodeGraph-assisted navigation.

Tool Notes

Common command shapes:

ast-grep --lang ts -p '<pattern>' <path>
ast-grep --lang tsx -p '<pattern>' <path>
ast-grep --lang js -p '<pattern>' <path>

Use the installed tool's help output for exact flags. Some versions differ on JSON, rewrite, and update flags.

Guardrails

  • Do not apply a codemod without inspecting candidate matches.
  • Do not run broad rewrites over the whole home directory or unrelated workspaces.
  • Do not treat a clean AST search as proof of runtime behavior.
  • Preserve unrelated user changes.

Closeout

AST-grep:
- Shape searched:
- Scope:
- Matches:
- Changes applied:
- Validation:

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.