/ceh-codebase-explanation:trace-code-rationale <file>[:<line>-<line>] | <symbol>from ceh-codebase-explanation
Load this skill when the question is why code is the way it is, not what it does: trace it through git log, blame, PRs, and issues, citing each claim. Trigger on "why is it like this", "why was this added", "is this safe to remove".
Ships in ceh-codebase-explanation. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Answer "why is it like this" from the project's history, not from the current code. Done when every claim in the answer cites a commit, PR, issue, or file, and every part of the question the history does not answer is named as not recorded.
The current code shows what it does, never why. A reason guessed from the code reads as plausible and is often wrong, and someone who deletes a guard on a guessed reason brings back the bug it was added for.
Pin the target. Name the file and line range, or the symbol, and restate the question as
"why does <target> do <behavior>". Read the current code only to find the lines.
Check the history is whole. git rev-parse --is-shallow-repository printing true means
older commits are missing. Say so, and fetch them with git fetch --unshallow before going on.
Find the commits that shaped it. Start with the line history, then use blame and pickaxe for what it misses:
git log -L <start>,<end>:<file> # every commit that touched these lines
git blame -w -C -C -M -L <start>,<end> <file> # skips whitespace, follows moves and copies
git log -S'<distinctive string>' --follow -- <file> # when a string appeared or vanished
If .git-blame-ignore-revs exists, pass --ignore-revs-file .git-blame-ignore-revs. Blame
names the last commit to touch a line, which is often a reformat or a move. Keep going back
until you reach the commit that introduced the behavior, not just the text.
Read the introducing commit whole. git show <sha> gives the message and the full diff,
including the other files it changed. The reason often sits in a test or config file next to
the line you care about.
Find the PR and issue. Squash merges keep the discussion in the PR, not the commit:
gh api repos/{owner}/{repo}/commits/<sha>/pulls --jq '.[].number'
gh pr view <N> --comments # description and review discussion
Follow every #NNN, Fixes, or ticket id in the commit or PR to its issue. Check the repo's
decision records, ADRs, and CHANGELOG.md entries from the same dates.
Answer. Use the shape under Output.
#PR, #issue,
or path:line. A claim with no source is a guess, and a guess goes under Not recorded.Reply in chat, no files:
**Question:** why does `<target>` do `<behavior>`?
**Answer:** <two or three sentences, each with its citation>.
| Date | Commit | PR / issue | What changed | Why, as recorded |
| ---------- | --------- | ---------- | ---------------------- | ----------------------------------- |
| 2024-03-02 | `a1b2c3d` | #412, #398 | added the retry on 503 | "upstream drops 1 in 50 under load" |
**Not recorded:** <each part of the question the history does not answer, and where you looked>.
When the question was "is this safe to remove", end with the condition under which removing it would bring the original problem back, cited to the commit or issue that describes the problem.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub cheneeheng/ceh-claude-code-library --plugin ceh-codebase-explanation5 skills in this plugin
/document-architectureLoad this skill when creating or updating ARCHITECTURE.yaml (Mermaid diagrams plus a Key Decisions log), or when a change to the system's shape must be brought back into it. Trigger on "write the architecture doc", "diagram the system", "record this decision", "high-level overview"./explain-codebaseLoad this skill when a whole repo or knowledge base must be understood and the understanding written to .agents_workspace/CODEBASE_EXPLAINED.md, component by component. Trigger on "explain this codebase", "walk me through this project", "I inherited this repo"./Other plugins' skills for the same job