| name | explain-diff |
| description | Explain code diffs in Markdown, one changed file at a time. Use when user asks to explain unstaged changes, staged changes, a commit, commit range, branch diff, PR diff, or pasted diff. Ask for diff source when missing. |
Explain Diff
Explain what changed in each changed file.
Flow
- Use user-provided diff source.
- If source is missing, use unstaged changes.
- If unstaged changes are empty, ask for source: staged, commit, range, branch, PR, or pasted diff.
- Read diff.
- Read surrounding code only when diff lacks context.
- Explain every changed file.
- Mention other files affected by each change.
- Separate facts from inferred intent.
Sort Files
Sort by dependency flow:
- Contracts, API, schemas, types.
- Data, services, server actions.
- State, context, hooks, cache.
- UI, routes, pages, components, styles.
- Tests, mocks, docs, config.
Within same layer, explain files that clarify other files first.
If still tied, use path order.
Diff Commands
- Unstaged:
git diff
- Staged:
git diff --staged
- Commit:
git show --stat --patch <commit>
- Range or branch:
git diff <base>...<head>
Output
Use TEMPLATE.md.