get_why_context β
The code shows what. Git shows why.
Returns the commit history that shaped a symbol plus any anti-pattern warnings (reverts, re-reverts, "fix of fix" churn) detected from that history. Reverted code is invisible in the current source but lives on in git β this tool surfaces it before you repeat a mistake someone already undid.
v0.8 adds driftSignals β cluster transitions for the queried symbol, so "this symbol used to live with the Auth cluster but now sits in Infrastructure" becomes a first-class fact alongside commit history. See Architectural Intelligence.
See the mandatory sequence before editing.
Parameters β
| Name | Type | Required | Description |
|---|---|---|---|
symbolId | string | yes | Fully-qualified symbol id (<file>::<name>::<kind>) |
maxCommits | integer | no | Limit returned commit history (default: full history from index) |
Example β
{
"symbolId": "packages/cli/src/adapters/storage/sqlite.ts::SqliteStorageAdapter::class"
}Trim to the 5 most recent commits:
{
"symbolId": "packages/cli/src/adapters/storage/sqlite.ts::SqliteStorageAdapter::class",
"maxCommits": 5
}Response β
{
"commitHistory": [
{
"hash": "def456",
"message": "revert: remove cache invalidation mutex",
"date": "2024-02-01",
"kind": "commit"
},
{
"hash": "abc123",
"message": "fix race condition in cache invalidation",
"date": "2024-01-28",
"kind": "commit"
}
],
"antiPatternWarnings": [
{
"hash": "def456",
"message": "revert: remove cache invalidation mutex",
"date": "2024-02-01"
}
],
"warningBadge": "β Anti-pattern detected",
"driftSignals": {
"confidence": "medium",
"snapshotsAvailable": 5,
"events": [
{
"symbolId": "packages/cli/src/auth/service.ts::AuthService::class",
"movedFrom": { "id": 3, "label": "Auth" },
"movedTo": { "id": 1, "label": "Infrastructure" },
"firstSeenInNewCluster": "2026-04-16T10:00:00.000Z"
}
]
}
}v0.8 driftSignals field β
Drift is computed by comparing the current community snapshot against the history stored in .ctxo/index/communities.history/. See Architectural Intelligence.
| Sub-field | Meaning |
|---|---|
events[] | Cluster transitions that include the queried symbol. Empty unless the symbol drifted. |
confidence | "low" when snapshotsAvailable < 3, "medium" for 3β6, "high" for 7+. |
snapshotsAvailable | Number of snapshots fed into the comparison. |
hint | Actionable recovery advice when confidence is low (enable post-commit hook, ctxo watch, or CI gate). |
When no communities.json exists, the driftSignals field is omitted entirely.
If the symbol is missing from the index:
{ "found": false, "hint": "Symbol not found. Run \"ctxo index\" to build the codebase index." }Reading the signal β
antiPatternWarningsis non-empty β someone already tried something here and reverted it. Read those commits before you write a single line. ThewarningBadgefield is also set so LLMs and UIs can flag the result.- High commit churn on a small symbol β the code is unstable. Pair with
get_change_intelligencefor a complexity x churn score. - No intent and no anti-patterns β either the symbol is new or git history is unavailable. The tool degrades gracefully: when the committed index lacks intent data it falls back to an on-demand
git logcall.
Killer example: silent architectural decay β
A symbol AuthService used to cluster with session/token code. Over 3 commits it starts importing AWS SDK helpers. No test fails, no typecheck complains, but Louvain moves it into the Infrastructure cluster.
get_why_context returns:
{
"commitHistory": [...],
"antiPatternWarnings": [],
"driftSignals": {
"confidence": "medium",
"snapshotsAvailable": 5,
"events": [
{
"symbolId": ".../AuthService::class",
"movedFrom": { "label": "Auth" },
"movedTo": { "label": "Infrastructure" }
}
]
}
}The next engineer who tries to extract auth as a standalone service discovers it is tangled with cloud SDK code. Drift is the decay you cannot see from a single commit β and the reason snapshots over time matter.
Worked example: a reverted fix β
A symbol with history like:
abc123β "fix race condition in cache invalidation"def456β "revert: remove cache invalidation mutex"ghi789β "add cache with no locking"
antiPatternWarnings will flag def456. The takeaway: the mutex caused a problem bad enough to revert, and the current code deliberately has no locking. Before "fixing" a race you think you see, read abc123 to understand what the original attempt looked like and def456 for why it was pulled.
Related tools β
get_blast_radiusβ required prerequisite before any editget_change_intelligenceβ complexity x churn hotspot scoringget_pr_impactβ run this on every high-risk symbol it surfacesget_logic_sliceβ the code itself, once you understand the history