Codebase Search
When to use this skill
- The main job is repo navigation before edits.
- The user needs to find definitions, call sites, entry points, config owners, tests, templates, content references, or likely impact surface.
- The repo is large enough that random file reading will waste time.
- The request is really "where does this live / what uses it / what should I inspect first?" even if the user never says "search".
- The repo may be app code, infra/config, content/templates, or game tooling/assets, and the first step is still discovery.
Do not use this skill as the main workflow when:
- The user already found the area and now needs root-cause diagnosis → use
debugging or log-analysis.
- The user wants a behavior-preserving cleanup or migration plan → use
code-refactoring.
- The user wants judgment on a concrete diff / PR → use
code-review.
- The user wants a persistent whole-repo or mixed-corpus structure map → use
graphify.
Core idea
codebase-search should act like a packet router, not a giant search tutorial.
- Normalize the request into one primary packet.
- Narrow scope before dumping matches.
- Read only the winning files.
- Return a compact evidence map.
- Route out as soon as search is no longer the bottleneck.
Read these support docs before choosing the packet:
- references/intake-packets-and-route-outs.md
- references/search-modes.md
- references/evidence-map-template.md
- references/handoff-boundaries.md
Instructions
Step 1: Normalize the request
Convert the prompt into this intake shape first:
codebase_search_packet:
primary_packet: exact-text | symbol-indexed | structural | config-content | hosted-search | graph-path
repo_shape: app | infra | content | game | mixed | unknown
search_goal: locate | references | ownership | impact | archaeology | unknown
scope_hint: path | package | file-type | subsystem | repo-wide | unknown
route_after: stay-here | debugging | log-analysis | code-refactoring | code-review | graphify
Choose one primary packet for the run. If two seem plausible, pick the cheaper one that reduces uncertainty fastest.
Step 2: Choose the packet
| Packet |
Use when |
Best fits |
Common tools / shapes |
exact-text |
The user knows a string, env var, route, flag, class name spelling, error text, or file fragment |
literal lookups, config keys, route paths, import names |
rg, git grep, editor search |
symbol-indexed |
The user needs definitions, references, or call sites |
function/class/interface ownership, API tracing, monorepo navigation |
LSP/workspace symbol, ctags, indexed repo search |
structural |
Syntax shape matters more than literal text |
missing cleanup, unsafe pattern inventories, migration prep |
ast-grep, Semgrep, Comby, tree-sitter-style search |
config-content |
The repo surface is config, content, templates, front matter, shortcodes, scenes, assets, or build scripts |
Terraform/Kubernetes, Markdown/MDX sites, Hugo/Next content, game packaging/config |
file discovery + exact-text + targeted scripts |
hosted-search |
The repo is remote/browser-first or cross-repo lookup matters |
PR archaeology, repo you do not have locally, shareable links |
GitHub/GitLab hosted search |
graph-path |
The request is really about dependency tracing or persistent structure |
call graph, path tracing, architecture map, graph report |
graphify, code graph/code map tools |
Packet rules:
- Prefer
exact-text when the user already has a concrete token.
- Prefer
symbol-indexed for “where is this defined / referenced?”
- Prefer
structural only when regex would be too blunt.
- Prefer
config-content when the real surface is not classic source code.
- Prefer
hosted-search when local context is missing.
- Prefer
graph-path only when ordinary search is no longer enough.
Step 3: Narrow scope before reading everything
Apply at least one narrowing move before reading files:
- limit by directory or package
- limit by file type
- separate authored files from generated/vendor folders
- start with entry points, loaders, config schemas, tests, examples, or build scripts
- in content/game repos, search metadata + template/asset surfaces before assuming code owns the answer
Useful heuristics by repo shape:
- app → start with entry point, router/handler, config loader, test
- infra → start with module/overlay/root config, variable/schema, deployment surface
- content → start with content folder, front matter key, partial/include/shortcode/template
- game → start with runtime code, engine config, scene/asset/build script, editor/visual graph references
Step 4: Read winners, not the whole match list
After the search packet returns matches:
- pick the most likely definition / ownership file
- pick 1–3 important consumers or references
- pick 1 config/test/example/build file when setup matters
- summarize the flow instead of pasting raw terminal output
Step 5: Return an evidence map
Default response shape:
## Search brief
- Goal: [what I was locating]
- Packet: exact-text | symbol-indexed | structural | config-content | hosted-search | graph-path
- Scope: [paths/file types/packages]
## Best entry points
- `path/to/file`: why it matters
- `path/to/other-file`: why it matters
## Key evidence
- `path:line` — what it shows
- `path:line` — how it connects
## Likely flow / ownership
- entry → consumer → config/test/content surface
## Next route-out
- stay in `codebase-search` or route to the next skill
Step 6: Use packet-specific heuristics
For bug-location requests
- start from the error string, route, flag, or recent change token
- locate the definition plus highest-signal consumers
- switch to
debugging once the likely failure path is mapped
For impact analysis
- definition first
- major consumers second
- tests/config/docs/content surfaces third
- separate must-update from maybe-affected
- route to
code-refactoring when the user is ready to change behavior-preserving structure
For config/content ownership
- locate loader/schema/template first
- then find runtime consumers or referenced pages/assets
- call out whether ownership sits in config, content metadata, templates, or code
For structural search
- explain the search shape in plain English
- prefer AST-aware tooling
- if forced to approximate with regex, label the confidence limit clearly
For archaeology requests
- start from entry points, docs, examples, tests, or build scripts
- avoid pretending you already understand the architecture after one search
- route to
graphify if the user actually wants persistent structure mapping
Step 7: Route out aggressively
Switch when the next job is no longer search:
- Root cause, reproduction, hypotheses →
debugging
- Raw log triage →
log-analysis
- Behavior-preserving cleanup / codemod planning →
code-refactoring
- Diff / PR judgment →
code-review
- Persistent architecture graph or path tracing →
graphify
Examples
Example 1: Pre-change discovery
Prompt:
Find where auth is implemented and what files I should inspect before changing it.
Good response shape:
- choose
symbol-indexed or exact-text
- identify entry points, config, and tests
- return a compact evidence map
- route to
code-refactoring or debugging only after the discovery step
Example 2: Config/content ownership
Prompt:
Which MDX pages still use the old pricing CTA shortcode, and where is the shared partial defined?
Good response shape:
- choose
config-content
- search content metadata + shortcode/template surfaces
- identify source partial plus affected pages
- keep the answer discovery-first
Example 3: Structural query
Prompt:
Find all React effects missing cleanup. I do not want plain grep.
Good response shape:
- choose
structural
- prefer AST-aware matching
- list highest-confidence hits
- label regex fallback limits if needed
Example 4: Game/infrastructure archaeology
Prompt:
Search this repo for where matchmaking region config is defined and what scenes or services consume it.
Good response shape:
- choose
config-content or symbol-indexed based on repo shape
- separate config ownership from runtime consumers
- call out code + asset/build surfaces if they both matter
Best practices
- Choose the smallest packet that can answer the question.
- Narrow scope before reading large match sets.
- Return an evidence map, not a terminal transcript.
- Cover config/content/game surfaces honestly; repo navigation is not only source-code lookup.
- Separate search from diagnosis, refactoring, review, and persistent graphing.
- Label confidence when structural intent is approximated with plain text search.
- For monorepos, group findings by package or subsystem.
References
1---2name: codebase-search3description: Route repo-navigation requests to one search packet before editing: exact-text, symbol/indexed, structural, config/content, hosted search, or graph/path trace. Use when the user asks where something is defined or referenced, which files own config/content surfaces, or what must be inspected before a change.4---567891011# Codebase Search1213## When to use this skill14- The main job is **repo navigation before edits**.15- The user needs to find **definitions, call sites, entry points, config owners, tests, templates, content references, or likely impact surface**.16- The repo is large enough that random file reading will waste time.17- The request is really **"where does this live / what uses it / what should I inspect first?"** even if the user never says "search".18- The repo may be **app code, infra/config, content/templates, or game tooling/assets**, and the first step is still discovery.1920Do **not** use this skill as the main workflow when:21- The user already found the area and now needs root-cause diagnosis → use `debugging` or `log-analysis`.22- The user wants a behavior-preserving cleanup or migration plan → use `code-refactoring`.23- The user wants judgment on a concrete diff / PR → use `code-review`.24- The user wants a persistent whole-repo or mixed-corpus structure map → use `graphify`.2526## Core idea27`codebase-search` should act like a **packet router**, not a giant search tutorial.28291. Normalize the request into **one primary packet**.302. Narrow scope before dumping matches.313. Read only the winning files.324. Return a compact evidence map.335. Route out as soon as search is no longer the bottleneck.3435Read these support docs before choosing the packet:36- [references/intake-packets-and-route-outs.md](references/intake-packets-and-route-outs.md)37- [references/search-modes.md](references/search-modes.md)38- [references/evidence-map-template.md](references/evidence-map-template.md)39- [references/handoff-boundaries.md](references/handoff-boundaries.md)4041## Instructions4243### Step 1: Normalize the request44Convert the prompt into this intake shape first:4546```yaml47codebase_search_packet:48 primary_packet: exact-text | symbol-indexed | structural | config-content | hosted-search | graph-path49 repo_shape: app | infra | content | game | mixed | unknown50 search_goal: locate | references | ownership | impact | archaeology | unknown51 scope_hint: path | package | file-type | subsystem | repo-wide | unknown52 route_after: stay-here | debugging | log-analysis | code-refactoring | code-review | graphify53```5455Choose **one** primary packet for the run. If two seem plausible, pick the cheaper one that reduces uncertainty fastest.5657### Step 2: Choose the packet5859| Packet | Use when | Best fits | Common tools / shapes |60|---|---|---|---|61| `exact-text` | The user knows a string, env var, route, flag, class name spelling, error text, or file fragment | literal lookups, config keys, route paths, import names | `rg`, `git grep`, editor search |62| `symbol-indexed` | The user needs definitions, references, or call sites | function/class/interface ownership, API tracing, monorepo navigation | LSP/workspace symbol, ctags, indexed repo search |63| `structural` | Syntax shape matters more than literal text | missing cleanup, unsafe pattern inventories, migration prep | ast-grep, Semgrep, Comby, tree-sitter-style search |64| `config-content` | The repo surface is config, content, templates, front matter, shortcodes, scenes, assets, or build scripts | Terraform/Kubernetes, Markdown/MDX sites, Hugo/Next content, game packaging/config | file discovery + exact-text + targeted scripts |65| `hosted-search` | The repo is remote/browser-first or cross-repo lookup matters | PR archaeology, repo you do not have locally, shareable links | GitHub/GitLab hosted search |66| `graph-path` | The request is really about dependency tracing or persistent structure | call graph, path tracing, architecture map, graph report | `graphify`, code graph/code map tools |6768Packet rules:69- Prefer `exact-text` when the user already has a concrete token.70- Prefer `symbol-indexed` for “where is this defined / referenced?”71- Prefer `structural` only when regex would be too blunt.72- Prefer `config-content` when the real surface is not classic source code.73- Prefer `hosted-search` when local context is missing.74- Prefer `graph-path` only when ordinary search is no longer enough.7576### Step 3: Narrow scope before reading everything77Apply at least one narrowing move before reading files:78- limit by directory or package79- limit by file type80- separate authored files from generated/vendor folders81- start with entry points, loaders, config schemas, tests, examples, or build scripts82- in content/game repos, search metadata + template/asset surfaces before assuming code owns the answer8384Useful heuristics by repo shape:85- **app** → start with entry point, router/handler, config loader, test86- **infra** → start with module/overlay/root config, variable/schema, deployment surface87- **content** → start with content folder, front matter key, partial/include/shortcode/template88- **game** → start with runtime code, engine config, scene/asset/build script, editor/visual graph references8990### Step 4: Read winners, not the whole match list91After the search packet returns matches:921. pick the most likely definition / ownership file932. pick 1–3 important consumers or references943. pick 1 config/test/example/build file when setup matters954. summarize the flow instead of pasting raw terminal output9697### Step 5: Return an evidence map98Default response shape:99100```markdown101## Search brief102- Goal: [what I was locating]103- Packet: exact-text | symbol-indexed | structural | config-content | hosted-search | graph-path104- Scope: [paths/file types/packages]105106## Best entry points107- `path/to/file`: why it matters108- `path/to/other-file`: why it matters109110## Key evidence111- `path:line` — what it shows112- `path:line` — how it connects113114## Likely flow / ownership115- entry → consumer → config/test/content surface116117## Next route-out118- stay in `codebase-search` or route to the next skill119```120121### Step 6: Use packet-specific heuristics122123#### For bug-location requests124- start from the error string, route, flag, or recent change token125- locate the definition plus highest-signal consumers126- switch to `debugging` once the likely failure path is mapped127128#### For impact analysis129- definition first130- major consumers second131- tests/config/docs/content surfaces third132- separate **must-update** from **maybe-affected**133- route to `code-refactoring` when the user is ready to change behavior-preserving structure134135#### For config/content ownership136- locate loader/schema/template first137- then find runtime consumers or referenced pages/assets138- call out whether ownership sits in config, content metadata, templates, or code139140#### For structural search141- explain the search shape in plain English142- prefer AST-aware tooling143- if forced to approximate with regex, label the confidence limit clearly144145#### For archaeology requests146- start from entry points, docs, examples, tests, or build scripts147- avoid pretending you already understand the architecture after one search148- route to `graphify` if the user actually wants persistent structure mapping149150### Step 7: Route out aggressively151Switch when the next job is no longer search:152- **Root cause, reproduction, hypotheses** → `debugging`153- **Raw log triage** → `log-analysis`154- **Behavior-preserving cleanup / codemod planning** → `code-refactoring`155- **Diff / PR judgment** → `code-review`156- **Persistent architecture graph or path tracing** → `graphify`157158## Examples159160### Example 1: Pre-change discovery161**Prompt:**162> Find where auth is implemented and what files I should inspect before changing it.163164**Good response shape:**165- choose `symbol-indexed` or `exact-text`166- identify entry points, config, and tests167- return a compact evidence map168- route to `code-refactoring` or `debugging` only after the discovery step169170### Example 2: Config/content ownership171**Prompt:**172> Which MDX pages still use the old pricing CTA shortcode, and where is the shared partial defined?173174**Good response shape:**175- choose `config-content`176- search content metadata + shortcode/template surfaces177- identify source partial plus affected pages178- keep the answer discovery-first179180### Example 3: Structural query181**Prompt:**182> Find all React effects missing cleanup. I do not want plain grep.183184**Good response shape:**185- choose `structural`186- prefer AST-aware matching187- list highest-confidence hits188- label regex fallback limits if needed189190### Example 4: Game/infrastructure archaeology191**Prompt:**192> Search this repo for where matchmaking region config is defined and what scenes or services consume it.193194**Good response shape:**195- choose `config-content` or `symbol-indexed` based on repo shape196- separate config ownership from runtime consumers197- call out code + asset/build surfaces if they both matter198199## Best practices2001. Choose the **smallest packet** that can answer the question.2012. Narrow scope before reading large match sets.2023. Return an evidence map, not a terminal transcript.2034. Cover config/content/game surfaces honestly; repo navigation is not only source-code lookup.2045. Separate search from diagnosis, refactoring, review, and persistent graphing.2056. Label confidence when structural intent is approximated with plain text search.2067. For monorepos, group findings by package or subsystem.207208## References209- `references/intake-packets-and-route-outs.md`210- `references/search-modes.md`211- `references/evidence-map-template.md`212- `references/handoff-boundaries.md`213- GitHub Code Search syntax docs: https://docs.github.com/en/search-github/github-code-search/understanding-github-code-search-syntax214- Sourcegraph code search docs: https://sourcegraph.com/docs/code_search215- ast-grep introduction: https://ast-grep.github.io/guide/introduction.html216- ripgrep guide: https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md