DiffLoupe Skill
DiffLoupe is an AI-powered diff analysis tool that provides:
- Intent derivation (what the change does and why)
- Risk assessment (bugs, security, breaking changes)
- Intent alignment (comparing stated vs actual changes)
When to Use
- Pre-commit review of staged changes
- Reviewing a PR before merge
- Understanding unfamiliar code changes
- Checking if changes match stated intent
Invocation
Use the wrapper script:
~/.config/opencode/scripts/diffloupe.ts <command> [args]
CLI Reference
Analyze Local Changes
diffloupe.ts analyze [target]
Targets:
staged (default) # git diff --cached
unstaged # git diff
HEAD # git diff HEAD
branch:NAME # git diff NAME...HEAD
commit:HASH # single commit
range:A..B # commit range
Options:
-i, --intent "..." # Stated intent for alignment
--intent-file PATH # Read intent from file
-v, --verbose # Full output
--json # JSON output
-C, --cwd PATH # Run in directory
Analyze GitHub PRs
diffloupe.ts pr <identifier>
Identifiers:
123 # PR number (current repo)
owner/repo#123 # Cross-repo PR
https://github.com/.../pull/123 # URL
Options:
-R, --repo owner/repo # Specify repository
-v, --verbose # Full output
--json # JSON output
Preview Without API Call
diffloupe.ts summarize [target]
Options:
--stats # Only file list + tokens
--files-only # Only file list
--json # JSON output
Output Structure (JSON)
{
"intent": {
"summary": "...",
"purpose": "...",
"scope": "feature|bugfix|refactor|config|docs|test|mixed",
"affectedAreas": ["..."],
"suggestedReviewOrder": ["file1.ts", "file2.ts"]
},
"risks": {
"overallRisk": "low|medium|high|critical",
"summary": "...",
"confidence": "high|medium|low",
"risks": [
{
"severity": "low|medium|high|critical",
"category": "security|breaking-change|performance|...",
"description": "...",
"evidence": "...",
"file": "...",
"mitigation": "..."
}
]
},
"alignment": {
"alignment": "aligned|partial|misaligned",
"confidence": "high|medium|low",
"summary": "...",
"matches": ["..."],
"mismatches": ["..."],
"missing": ["..."],
"unstated": ["..."]
}
}
Integration Tips
- Use
--jsonfor programmatic processing - Pipe intent via stdin:
echo "intent" | diffloupe.ts analyze - For large diffs, use
summarize --statsfirst to check token count - Commit messages are auto-used as intent for
commit:targets