get_why
Architectural-decision archaeology. Search decisions in natural language, anchor them to a file path, or pull the global decision-health dashboard. Falls back to git archaeology when no recorded decisions exist.
The decision intelligence layer in one tool. get_why answers
"why is this code shaped this way?" — pulling from the architectural
decision records, the wiki, and (when nothing's recorded) the git
history itself. Four modes: NL search, path-anchored, target-aware,
and a no-arg health dashboard.
When to call
- Before architectural changes — check whether existing decisions govern what you're about to touch.
- During design reviews — pull the health dashboard to find stale decisions and ungoverned hotspots.
- On code with no recorded decisions — the git-archaeology fallback reconstructs the origin story from significant commits.
- Onboarding — call with no args for a tour of the codebase's recorded reasoning.
Parameters
Prop
Type
Returns
The shape depends on which mode the call landed in.
Mode 1 — Search (query is a question)
mode: "search",querydecisions— 8 merged hits (keyword + semantic, deduped)related_documentation— top 3 wiki pages mentioning the querytarget_context— (iftargetsprovided) per-target governing decisions, origin story, and git archaeology fallback
Mode 2 — Path (query is a file path)
mode: "path",pathdecisions— every decision affecting this fileorigin_story— when and why the file was created, by whom, recent change patternsalignment— how well the file aligns with its governing decisionsgit_archaeology— significant commits, cross-references, git log results (used when no decisions exist)
Mode 3 — Health dashboard (no query)
mode: "health"summary— human-readable countscounts— structured countsstale_decisions— decisions older than the files they governproposed_awaiting_review—status="proposed"recordsungoverned_hotspots— high-churn files with no decisions
Mode 4 — Workspace search (repo="all")
mode: "search",workspace: truedecisions— merged results across repos (capped at 15)
Example
get_why() # health dashboard
get_why("why is auth using JWT?") # search
get_why("src/auth/service.py") # path mode
get_why("why was caching added?", targets=["src/cache/service.py"])
get_why("redis integration", repo="all") # workspace searchThings worth knowing
- Path detection — if
querycontains/or ends with.py, the tool routes to path mode (Mode 2) instead of search (Mode 1). - Natural-language scoring weights field matches:
title3.0×,decision/rationale2.0×,context1.5×,consequences/tags/files1.0×.targetsfiles contribute+5.0for an exact match,+3.0for a module-level match. - Git-archaeology fallback runs when no decisions exist for a file:
(1) significant commits from the file itself, (2) cross-file
references in other files' commits, (3) live
git log --followandgit log --grep(10-second timeout). - Staleness score compares the file's
last_commit_atto the decision'slast_update_at— older files with unchanged decisions are flagged stale. - Workspace mode (
repo="all") uses keyword search across all repos' decisions, capped at 15 merged results. Full per-repo semantic federation is path-mode only.
Decisions are linked to graph nodes, so when the agent edits a file
get_why will surface the decisions that govern it without you having
to ask. This is what keeps the why in the codebase when the original
author leaves.
get_risk
Modification-risk assessment for files before editing — hotspot scores, dependents, co-change partners, blast radius, recommended reviewers, test gaps, and security signals.
get_dead_code
Tiered refactor plan for unused code — high/medium/low confidence findings with per-directory rollups, ownership hotspots, and safe-to-delete impact estimates. Pure graph + SQL, no LLM calls.