--- name: codebase-exploration description: Explore this codebase, its architecture, where code lives and how a module works. --- # Codebase Exploration with Repowise This project has a Repowise intelligence layer. For an exact identifier, string or file name, Grep, Glob and Read are faster. For how code works, who calls it, what a change breaks and why it is shaped this way, reach for the Repowise MCP tools: they return documentation, ownership, history, decisions, and graph structure that plain file reads don't, usually in one round-trip instead of many. ## Which tool for which question | You want… | Call | |---|---| | An exact identifier, string or file name | Grep, Glob and Read. | | First orientation in an unfamiliar repo | `get_answer(question="what are the main modules and entry points?")`. For the full map (architecture, git health, knowledge map), add `+get_overview` to `mcp.tools` in `.repowise/config.yaml` and restart the MCP server. | | How X works or flows end to end | `get_answer(question="how does …")`, one question per call: synthesised answer with citations + one `confidence` trust signal. Collapses the search → read → reason loop. | | Callers before a rename or signature change | `get_context(targets=[""], include=["references"])`: definition, imports and calls; a `complete` list is the whole edit set. | | What breaks if X changes | `repowise risk --target `. | | Why X is shaped this way, before changing a pattern | `get_why(query="why …", targets=[""])`. | | Before finishing a multi-file change | `repowise risk ..HEAD`, then `repowise health --score --against `. | | A fuzzy concept, or symbol ids and line bounds to feed `get_symbol` | `search_codebase(query="…")`: hybrid search. `mode="auto"` routes an identifier to indexed symbol hits (`symbol_id`/line bounds → pipe into `get_symbol`), a path to file pages (→ `get_context`), and prose to semantic wiki search (each hit's `sources` lists what matched it: `fts`, `symbol` or `vector`). Force a branch with `mode=symbol\|path\|concept\|hybrid`; narrow symbols with `symbol_kind`. | | A triage card for specific files/symbols | `get_context(targets=[…])`: title, summary, signatures, hotspot bit, top callers, decision titles, symbol_ids (a row without one is `path::name`). Batch many targets in one call. | | The actual source of one symbol | `get_symbol("path/to/file.py::Name")`: exact bytes with line bounds. Cheaper than Read + offset math. Use a `symbol_id` from `get_context`. | ## Recommended flow 1. New area you don't know → one orientation `get_answer` call. 2. A specific question → `get_answer(question=…)` first. - High confidence → answer it, cite the paths. - `medium`/`low` confidence → follow `best_guesses[0].file` or `fallback_targets[0]` into `get_context`, then `get_symbol` for bytes. 3. A named symbol or a path you only need to find → Grep, Glob or Read. When you need its callers or history, pass it to `get_context` or `get_why` instead; for its risk, `repowise risk --target `. 4. More files around a concept → `search_codebase`, then `get_context` on the hits (batched), then `get_symbol` only for the bodies you actually need. Read source directly for details the indexed context doesn't cover. ## Trust signals — verify when - `_meta.stale_warning` is present (the index has diverged from HEAD), or - `confidence` is `medium`/`low`, or - a concept result's `sources` is only `fts` (a keyword match, no semantic hit). Otherwise the response is current — act on it. ## Error handling - "No repositories found. Run 'repowise init' first." → suggest `/prompts:repowise-init`. Add `--no-editor-setup` if this repo is a scratch clone, a fixture, or a worktree, so `init` writes nothing outside `.repowise/` (no editor config, agent hooks or git hook). - MCP tools unavailable → prefer the matching CLI slash commands when the plugin is installed (`/prompts:repowise-ask`, `/prompts:repowise-context`, `/prompts:repowise-symbol`, `/prompts:repowise-search`) rather than grepping blind. - `get_answer`/`search_codebase` come back empty → the repo may have a template-rendered wiki. Fall back to `get_context` with explicit paths, and note that model-written pages (`repowise generate`, or `/prompts:repowise-init` with an LLM provider) unlock richer docs + semantic search. - Tools fail to connect at all → the `repowise` binary may not be installed; suggest `/prompts:repowise-init`.