what-happened
Explain why code looks the way it does by tracing the latest change for a file range or pasted snippet through `git blame` and deduplicated `entire checkpoint explain` lookups. Use when the user asks what happened, says "tell me why" about a code block, is confused about a section of code, asks "wtf is going on", "why is this like this", "why was this changed", or wants provenance for a specific file block.
entireio · AI review on file
Installation
Read the source and dependencies before running a command. Copying does not install or execute anything.
npx skills add entireio/skills --skill what-happenedAbout this skill
name: what-happened
description: >
Explain why code looks the way it does by tracing the latest change for a file
range or pasted snippet through git blame and deduplicated entire checkpoint explain
lookups. Use when the user asks what happened, says "tell me why" about a code
block, is confused about a section of code, asks "wtf is going on", "why is
this like this", "why was this changed", or wants provenance for a specific
file block.
What Happened
Use this skill when the user wants a provenance-focused explanation for a code block.
Supported inputs:
path:linepath:start-endpathplus a pasted code snippet from that file
If the user asks a vague provenance question without a file path, line range, or pasted snippet, ask for the target code and stop without running commands or using the header.
Goal
Find the most recent change blocks matching the user's target lines, list the matching commit hashes and checkpoint state, then summarize why each block was changed using the best available context. When checkpoint-backed context is unavailable, still explain what the current code does as an explicit fallback and clearly mark that explanation as not checkpoint-backed.
Rules
- Do not guess about file contents or line numbers. Resolve the exact target lines before explaining anything.
- Use the installed
entirebinary fromPATH, not./entirefrom the current repo. - Prefer
git blamefor provenance andentire checkpoint explain --commitfor transcript-backed context. Do not use experimentalentire whyfor this skill. - Use this skill for latest-change provenance on a specific block. For broad original intent
of a symbol, file, or feature, prefer the
explainskill. - Do not manually hunt through
.git/entire-sessions/or raw transcript files for commit provenance. Ifentire checkpoint explaincannot provide transcript context, report the exact missing or unavailable state. - If multiple blame blocks match, include all distinct ranges. Deduplicate commit hashes
before running
entire checkpoint explain; run transcript lookups once per unique commit, not once per range. Also deduplicate checkpoint IDs before expanding checkpoint transcripts; run checkpoint expansion once per unique checkpoint, not once per commit or range. - Distinguish these states explicitly:
- no checkpoint is referenced for the commit
- a checkpoint is referenced but is unavailable locally or remotely
- a checkpoint is available, but full transcript expansion failed and raw transcript expansion was not explicitly requested
- Entire transcript lookup failed (the
entire checkpoint explaincommand itself errored) - the code is untracked, uncommitted, or otherwise has no committed history
- any other provenance command fails after the target code was resolved
- For every resolved code block, include either checkpoint-backed history or a fallback explanation of what the current code does. Label fallback explanations as "not checkpoint-backed" and do not imply intent or historical rationale from checkpoints.
- Treat
entire checkpoint explaincommand output as intermediate source material for summarization. Do not paste raw command output or full transcripts into the user response unless the user explicitly asks for raw output. Include only short error excerpts when they help the user fix a failed lookup. - Keep the final explanation concise and block-focused. Do not summarize unrelated parts of the file.
Workflow
1. Resolve the target block
If the user did not provide a file path plus exact line/range or pasted snippet, ask them for
the target code and stop. Do not run commands or use the Entire What Happened: header.
If the user gave path:line or path:start-end, use that line or range directly and read
only that target from the file before explaining it. If the path does not exist, the file
cannot be read, or the line/range is outside the file, say so plainly and stop without using
the Entire What Happened: header.
If the user gave a path and a snippet:
- Pick the most distinctive exact line from the snippet and search the file with fixed-string matching to find candidate locations:
grep -n -F -- "<distinctive snippet line>" "<path>"
- Read the small candidate windows around each hit, not the whole file unless the file is already small or the search produces too many candidates to inspect efficiently.
- Find the exact snippet in the candidate window.
- Convert the match to
start-endline numbers. - If whitespace differs but the code is otherwise identical, normalize leading indentation and trailing whitespace before deciding the snippet does not match.
- If the snippet appears multiple times, report the ambiguity and list the candidate ranges
instead of picking one silently. Do not use the
Entire What Happened:header for this unresolved-input response. - If the snippet cannot be found exactly, say so plainly and stop rather than inferring a nearby
match. Do not use the
Entire What Happened:header for this unresolved-input response.
2. Gather provenance
Only run blame after the target has been resolved to actual line numbers in the current file.
Do not run git blame -L against an unresolved pasted snippet, inferred nearby block, symbol
name, or approximate range.
Run:
git blame --porcelain -L <start>,<end> -- "<path>"
If the command fails because the file is untracked, mark the whole target range as an untracked file with no committed history, keep the exact snippet for that range, and continue to fallback code behavior analysis.
If blame reports an uncommitted pseudo-commit such as all zeroes or Not Committed Yet, mark
those ranges as local uncommitted changes and do not run entire checkpoint explain for them. If other
target ranges resolve to real commits, continue with those committed ranges.
Use t
Read the complete source ↗