dist/gemini/skills/searching-code/SKILL.md
Intelligent codebase search with AST-first local search and zoom-out mapping. Use when user asks "how does X work", "trace flow", "find all implementations", "understand codebase", "zoom out", "map this area", structural code-pattern search, or cross-file exploration in large repos. Try ast-grep before rg for code-shape queries; use WarpGrep for semantic flow.
npx skillsauth add alexei-led/claude-code-config searching-codeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use the cheapest tool that answers the question with verified file references. For code structure, that means ast-grep before text search. For semantic flow, that means targeted entry points first, then WarpGrep or another semantic search. Do not read the whole repo because the user sounds curious. Curiosity is not a query plan.
ast-grep / sg — code structure: language constructs, call shapes,
functions containing or missing code, AST-aware refactor candidates.rg — exact text: strings, comments, docs, logs, config keys, unknown
identifiers where structure is irrelevant.fd — file and directory discovery.grep / find — only when modern tools are unavailable.rg.CONTEXT.md, CONTEXT-MAP.md, nearest */CONTEXT.md, and relevant
docs/adr/*.md files.Check the executable. Prefer ast-grep; use sg if that is what the system has.
command -v ast-grep || command -v sg
Pattern search:
ast-grep run --pattern 'console.log($$$)' --lang javascript .
ast-grep run --pattern 'func $NAME($$$) { $$$ }' --lang go .
ast-grep run --pattern 'def $NAME($$$): $$$' --lang python . --json
Relational or composite rule search:
ast-grep scan --inline-rules 'id: async-without-try
language: javascript
rule:
all:
- kind: function_declaration
- has:
pattern: await $EXPR
stopBy: end
- not:
has:
pattern: try { $$$ } catch ($E) { $$$ }
stopBy: end
' .
Debug pattern parsing:
ast-grep run --pattern 'class $NAME { $$$BODY }' --lang javascript --debug-query=pattern
ast-grep run --pattern 'class User { constructor() {} }' --lang javascript --debug-query=cst
Rule authoring details live in references/ast-grep-rule-reference.md.
ast-grep:
foo($A, $B) inside class methods."useEffect with an empty dependency list."rg:
NEXT_PUBLIC_API_URL."UserService mentioned?" when node shape does not matter.WarpGrep / semantic search:
Smart Explore after narrowing:
How does authentication flow from the login handler to the database?
Find all places where user permissions are checked.
Trace the request lifecycle from router to response.
Find async functions that await without try/catch.
Find calls to oldClient.query($$$) outside repository classes.
Find React components that use useEffect and setState.
Find UserService mentions. → use rg unless AST shape matters.
Search for import React. → use rg.
Find TypeScript files. → use fd.
For trace-flow requests, explicitly say you will first check for CONTEXT.md,
CONTEXT-MAP.md, nearest */CONTEXT.md, and docs/adr/*.md when present
before naming domain concepts.
CONTEXT.md, CONTEXT-MAP.md, nearest
*/CONTEXT.md, and relevant ADRs.ast-grep run or ast-grep scan.rg -n 'literal|symbol|route'.fd 'auth|login|session|user'.Use when the user says "zoom out", "map this area", "go up a layer", or sounds lost in local details.
Return a map, not a dump:
CONTEXT.mdAvoid line-by-line explanations unless asked. The point is orientation, not making paste soup.
Return a bounded code map:
file:line references.For structural searches, also include the ast-grep pattern or rule used.
rg / fd only for the parts
they can answer. Suggest brew install ast-grep, npm install -g @ast-grep/cli,
or cargo install ast-grep.rg, then report the gap without inventing
results.rg/fd for text/file searches, and Read for specific files; say which tool
is being used.tools
Use when planning, executing, checkpointing, finishing, or inspecting lightweight spec-driven work. Runs one task at a time using `.spec/` markdown files and the bundled `specctl` helper. NOT for broad product discovery beyond a short requirement interview. NOT for generic implementation planning that does not read or write `.spec/` files.
development
Simple web development with HTML, CSS, JS, and HTMX. Use when working with .html, .css, or .htmx files, web templates, stylesheets, or vanilla JS scripts. NOT for React/Vue/Angular (use writing-typescript) or Node.js backends.
tools
Idiomatic TypeScript development. Use when writing TypeScript code, Node.js services, React apps, or TypeScript design advice. Emphasizes strict typing, boundary validation, composition, fast feedback, behavior tests, and project-configured tooling. NOT for Go, Python, Rust, plain HTML/CSS/JS, or server-rendered templates (use writing-web).
tools
Idiomatic shell development for POSIX sh, Bash, Zsh, Fish, hooks, CI shell steps, and scriptable CLI glue. Use when writing or changing `.sh`, `.bash`, `.zsh`, `.fish`, `.bats`, shell functions, shell pipelines, CI `run:` shell bodies, or command-runner recipes. Emphasizes portability, quoting, safe filesystem/process handling, non-TUI CLI tools, ShellCheck, shfmt, Bats, and ShellSpec. NOT for Python, Rust, TypeScript, Go, web code, or GitHub Actions workflow/job/permissions semantics; use operating-infra.