| name | diffloupe |
| description | Run DiffLoupe AI code analysis for diff understanding and review |
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)
unstaged
HEAD
branch:NAME
commit:HASH
range:A..B
Options:
-i, --intent "..."
--intent-file PATH
-v, --verbose
--json
-C, --cwd PATH
Analyze GitHub PRs
diffloupe.ts pr <identifier>
Identifiers:
123
owner/repo#123
https://github.com/.../pull/123
Options:
-R, --repo owner/repo
-v, --verbose
--json
Preview Without API Call
diffloupe.ts summarize [target]
Options:
--stats
--files-only
--json
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
--json for programmatic processing
- Pipe intent via stdin:
echo "intent" | diffloupe.ts analyze
- For large diffs, use
summarize --stats first to check token count
- Commit messages are auto-used as intent for
commit: targets