agentleFS
NicoGentiNicoGenti/opencode-orchestrator-kit/skills/structural-search/SKILL.md

structural-search

Skill9 starsChanged 8 days agoMITView on GitHub

Opt-in ast-grep patterns for structural code search (function defs, call sites, class usage). Read-only; falls back to rg when ast-grep is unavailable.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 0 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

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

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

    Use this skill when the explorer needs structural matches that plain rg cannot express well (e.g.

    line 8
  2. Very specific:

    Always scope with --globs to the relevant file set (e.g.

    line 22
  3. Very specific:

    Read-only: never use ast-grep to rewrite files (--rewrite is forbidden in this workflow).

    line 26
  4. Very specific:

    If sg is missing or errors, fall back silently to rg + targeted reads.

    line 27
  5. Very specific:

    If structural search yields nothing useful within 2 attempts, revert to the standard rg → targeted-read ladder and note it in Not checked: …

    line 32

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

Structural Search (ast-grep, opt-in)

Use this skill when the explorer needs structural matches that plain rg cannot express well (e.g. "find all call sites of X", "find all async functions", "find classes implementing Y").

When to use

  • The question is about code structure, not plain text.
  • The sg (ast-grep) binary is available on PATH (sg --version or ast-grep --version).
  • CRG is absent or did not narrow the search enough.

Core patterns

  • Function definition: sg run -p 'function $NAME($$$ARGS) { $$$ }' (adjust per language).
  • Call site: sg run -p '$OBJ.$METHOD($$$ARGS)'.
  • Class usage: sg run -p 'new $CLASS($$$ARGS)'.

Always scope with --globs to the relevant file set (e.g. --globs 'src/**/*.ts') to keep output small.

Safety

  • Read-only: never use ast-grep to rewrite files (--rewrite is forbidden in this workflow).
  • If sg is missing or errors, fall back silently to rg + targeted reads.
  • Respect the explorer's bounded-read and output-contract rules.

Fallback

If structural search yields nothing useful within 2 attempts, revert to the standard rg → targeted-read ladder and note it in Not checked: if relevant.

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.