/code-intelligence:searching-codebasesfrom code-intelligence
Finds all true callers, definitions, or inferred signatures of Python symbols using pyright binding resolution, eliminating false positives from text search. Python only, for caller/definition queries.
Ships in code-intelligence. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Find code in any codebase by pattern or concept. One entry point, two search strategies, automatic routing.
Python callers and definitions only. Every other code question is cheaper elsewhere, and the measurement below is why this skill is edge-case-only.
| Situation | Use |
|---|---|
| What symbols does this file contain? | tree-sitting |
| Where is X defined, so I can read it? | tree-sitting |
| Any structure question, any language | tree-sitting |
| A literal string or regex | plain ripgrep |
| Which files are most about a concept? | bm25 |
| First look at an unfamiliar repo | exploring-codebases |
Non-Python code has no pyright binding resolution to offer, so there is no version of this skill that applies to it.
uv tool install ripgrep
tree-sitting installs automatically when needed — for --expand context
expansion and for the binding-resolved --refs/--def/--hover tier, which
uses it to resolve symbol positions. Only the bare tree-sitter package is
fetched; the language grammars ship bundled.
SKILL_DIR=/mnt/skills/user/searching-codebases
python3 $SKILL_DIR/scripts/search.py SOURCE "query1" ["query2" ...] [OPTIONS]
SOURCE is any of:
uploads (uses /mnt/user-data/uploads/)project (uses /mnt/project/).zip or .tar.gz archiveRegex mode (patterns, identifiers, literal text):
python3 $SKILL_DIR/scripts/search.py ./repo "def handle_error"
python3 $SKILL_DIR/scripts/search.py ./repo "class.*Exception" --regex
python3 $SKILL_DIR/scripts/search.py ./repo "TODO|FIXME|HACK"
Semantic mode (concepts, natural language):
python3 $SKILL_DIR/scripts/search.py ./repo "retry logic with backoff" --semantic
python3 $SKILL_DIR/scripts/search.py ./repo "authentication flow"
python3 $SKILL_DIR/scripts/search.py ./repo "error handling strategy"
Auto-detection: short queries and code-like tokens → regex. Multi-word
natural language → semantic. Override with --regex or --semantic.
Binding-resolved mode (Python only — pyright via the python-lsp skill):
python3 $SKILL_DIR/scripts/search.py ./repo --refs SYMBOL # find all real uses
python3 $SKILL_DIR/scripts/search.py ./repo --def SYMBOL # go-to-definition
python3 $SKILL_DIR/scripts/search.py ./repo --hover SYMBOL # inferred type/signature
Regex mode matches text, so a cross-reference for a function false-positives
on shadowed and same-named-but-unrelated symbols. --refs is binding-resolved:
pyright excludes the unrelated same-named symbol and follows imports. Use it when
you need a true "find all callers/users" for a .py symbol, not a text grep.
The tier is engaged lazily — pyright's index cost is paid only when you ask
for --refs/--def/--hover, never on ordinary searches. It is Python-only;
for non-.py sources, or when pyright/node is unavailable, it prints a one-line
degradation note and falls back to the regex text path. Each takes a single bare
symbol name and is mutually exclusive with the other two and with text queries.
--regex / --semantic: Force search mode--refs SYMBOL / --def SYMBOL / --hover SYMBOL: Binding-resolved Python
queries via pyright (see Binding-resolved mode above)--expand: Return full function bodies via tree-sitting AST context--benchmark: Compare indexed regex vs brute-force ripgrep--branch NAME: Git branch for GitHub URLs (default: main)--skip DIRS: Comma-separated directories to skip--json: Machine-readable output-v: Show index stats and query routing decisionsRegex search builds a sparse n-gram inverted index over all files. Queries are decomposed into literal fragments, looked up in the index to identify candidate files (typically 90-99% reduction), then verified with ripgrep. Frequency-weighted n-grams make rare character sequences more selective.
Semantic search builds a TF-IDF index over code chunks (functions, classes, structural entries). Queries are ranked by cosine similarity.
Context expansion (--expand) uses tree-sitting's AST cache to
identify function/class boundaries, returning complete structural units
rather than line fragments. On first use, tree-sitting scans the repo
(~700ms for 250 files); subsequent expansions are sub-millisecond.
Small codebases (< 20 files) skip indexing entirely — direct ripgrep is faster when there's nothing to narrow.
Multiple queries can use different modes in a single invocation. Each query is auto-routed independently, and indexes are built once per mode:
python3 $SKILL_DIR/scripts/search.py ./repo \
"class.*Error" \
"error recovery strategy" \
"def retry"
--expand and the
symbol→position resolution that seeds the binding-resolved tier
(--refs/--def/--hover). Auto-installs the bare tree-sitter package
when either is used (grammars are bundled). Regex and semantic search work
without it.uv tool install ripgrep.--refs/--def/--hover).
Self-bootstraps pyright on first use and requires system node (v18+). Not
required — without it those flags degrade to the regex text path.The ONE recommended use: binding-resolved Python symbol queries.
X" / "where is X really defined" for a .py
symbol, when same-named-but-unrelated symbols would pollute a text grep.
Empirical basis: rg get on psf/requests returned 232 hits, 224 of them
false; --refs get excluded all 224 (2026-06-15).Everything else. Measured head-to-head on real issue-localization tasks (7 scikit-learn issues with merged fix-PRs, gold = PR diff files, 2026-07-04, replicating the file-discovery metric of arXiv:2602.11988):
rg -l tied or beat the indexed
tier on recall@10 in every instance, at 0.4s vs 25s.The self-test before invoking: would plain rg return the same answer?
If yes, use rg. The indexed-regex and semantic tiers are retained for
completeness and for corpora where they may yet earn their cost (very
large repos, non-code document collections), but they carry the burden
of proof.
scripts/search.py — Entry point, query routing, output formattingscripts/resolve.py — Input source resolution (GitHub, uploads, archives)scripts/context.py — tree-sitting-based AST context expansionscripts/ngram_index.py — Sparse n-gram inverted index, regex decompositionscripts/sparse_ngrams.py — Core n-gram algorithms, frequency weightsscripts/code_rag.py — TF-IDF semantic search over code chunksscripts/lsp_refs.py — Binding-resolved Python tier: symbol→position
resolution (tree-sitting), pyright queries (python-lsp), soft fallbackCHANGELOG.md (opens in a new tab)README.md (opens in a new tab)scripts/code_rag.py (opens in a new tab)scripts/context.py (opens in a new tab)scripts/lsp_refs.py (opens in a new tab)scripts/ngram_index.py (opens in a new tab)scripts/resolve.py (opens in a new tab)scripts/search.py (opens in a new tab)scripts/sparse_ngrams.py (opens in a new tab)tests/fixture/pkg/__init__.py (opens in a new tab)tests/fixture/pkg/models.py (opens in a new tab)tests/fixture/pkg/other.py (opens in a new tab)tests/fixture/pkg/service.py (opens in a new tab)tests/test_lsp_refs.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub oaustegard/claude-skills --plugin code-intelligence14 skills in this plugin
/assessing-impactPre-change blast-radius report for a symbol or file. Walks tree-sitting references, augments with a plain-text scan over non-parsed files (configs, plain docs), and clusters affected sites by feature (`_FEATURES.md`) or top-level package. Use when about to refactor, rename, or delete something in a repo you don't own — "what breaks if I change `validateUser`", "who calls this", "is this safe to remove", "where is this used", "blast radius", "impact analysis". This is the CONVERGENT pre-change risk skill — for "what is this repo?" use exploring-codebases; for "where is X?" use searching-codebases./declaring-invariantsFind tests that enumerate a domain by copying it, and declare the invariants a codebase depends on. Reports where a parametrize list, for-loop, or it.each iterates a hand-written subset of a dict/set/tuple/Enum that exists in the source, and names the members nothing covers. Use when reviewing tests, when a module gains a name-to-thing table, registry, enum, or dispatch map, before trusting a green suite as evidence a domain is covered, or when asked "is this test actually total", "does anything cover X", "what does this repo guarantee", "which invariants do we declare". Also for vacuous tests that pass over an empty collection, for a domain that has silently NARROWED (an enumeration cannot see that), and for recording the refutation that proves a claim can fail.Other plugins' skills for the same job