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
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, or command-runner recipes. Emphasizes portability, quoting, safe filesystem/process handling, non-TUI CLI tools, ShellCheck, shfmt, Bats, and ShellSpec. NOT for Python, TypeScript, Go, web code, or infrastructure operations.
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.
testing
Author, inspect, troubleshoot, and review infrastructure across IaC, Kubernetes, cloud resources, containers, CI/CD, and Linux hosts. Use when changing Terraform/OpenTofu, Kubernetes, Helm, Kustomize, Dockerfiles, GitHub Actions, AWS, GCP, Cloud Run, BigQuery, IAM, logs, instances, or service health. NOT for deploy/apply/rollback workflows (see deploying-infra). NOT for shell scripts or generic command pipelines (see writing-shell).
development
Configure safe git workflow hygiene: pre-commit/pre-push hooks, Gitleaks secret scanning, .gitignore rules, local git config, and guardrails. Use when setting up git hooks, gitleaks/git leaks, staged pre-commit checks, pre-push validation, core.hooksPath, .gitignore, or git config best practices. NOT for creating commits (use committing-code), cleaning branches/worktrees (use cleanup-git), or creating worktrees (use using-git-worktrees).