why
why
Reconstruct the reasoning behind existing code by mining the record the repo already carries: the line's history, the commit messages, the PR discussion, the linked issues. The output is a story with evidence, not a link dump — and never a guess.
The one hard rule: never invent a rationale. A plausible-sounding explanation for code you didn't research is worse than "the record doesn't say" — it plants false understanding. Every claim about intent must cite a source (a comment, a commit, a PR, an issue) or be clearly labeled as inference.
The dig — layer by layer, stopping when answered
Go only as deep as the question demands. One git log -L answers most questions; the full dig is for load-bearing mysteries.
Layer 0 — the code itself
Check whether a nearby comment, docstring, or the project's docs already answer it. If yes, quote it and stop — that's the codebase working as it should.
Layer 1 — commit history
Find the commits that shaped the code in question: