diffscope-0.4.0 is not a library.
DiffScope
A composable code review engine for automated diff analysis.
Features
- Model Agnostic: Works with OpenAI, Anthropic Claude 4, Ollama, and any OpenAI-compatible API
- Git Integration: Review uncommitted, staged, or branch changes directly
- PR Reviews: Analyze and comment on GitHub pull requests
- Smart Prompting: Advanced prompt engineering with examples, XML structure, and chain-of-thought
- Commit Messages: AI-powered commit message suggestions following conventional commits
- Composable Architecture: Modular components that work together
- Plugin System: Extensible pre-analyzers and post-processors
- Multiple Outputs: JSON, patch, or markdown formats
- CI/CD Ready: GitHub Action, GitLab CI, and Docker support
- Smart Review: Enhanced analysis with confidence scoring, fix effort estimation, and executive summaries
Quick Start
Install via Homebrew (macOS/Linux)
Install from source
Docker
Usage
Review a diff file
Review from stdin
|
Git integration
# Review uncommitted changes
# Review staged changes
# Review changes from a branch
# Suggest commit message for staged changes
Pull Request review
# Review current PR
# Review specific PR
# Post comments directly to PR
Smart Review (Enhanced Analysis)
# Comprehensive analysis with executive summary
# Enhanced review from stdin
|
# Save detailed report to file
Use different models
# OpenAI GPT-4
# Anthropic Claude
# Local Ollama
Supported Models
OpenAI: gpt-4o, gpt-4-turbo, gpt-3.5-turbo
Anthropic:
- Claude 4: claude-opus-4-20250514, claude-sonnet-4-20250514
- Claude 3.5: claude-3-5-sonnet-20241022, claude-3-5-haiku-20240307
- Claude 3: claude-3-opus-20240229, claude-3-haiku-20240307
Ollama: Any locally installed model (codellama, llama3.2, mistral, etc.)
Output formats
# JSON (default)
# Markdown
# Patch comments
GitHub Action
name: Code Review
on:
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: haasonsaas/diffscope@v1
with:
model: gpt-4o
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
Configuration
Create a .diffscope.yml file in your repository:
model: gpt-4o
temperature: 0.2
max_tokens: 4000
system_prompt: |
You are an expert code reviewer. Focus on:
- Security vulnerabilities
- Performance issues
- Best practices
- Code clarity
Plugin Development
Create custom analyzers:
export interface PreAnalyzer {
id: string
run(diff: UnifiedDiff, repoPath: string): Promise<LLMContextChunk[]>
}
export interface PostProcessor {
id: string
run(comments: Comment[], repoPath: string): Promise<Comment[]>
}
Architecture
graph LR
A[git diff] --> B(core-engine)
subgraph core-engine
B1[Diff Parser]
B2[Context Fetcher]
B3[Prompt Builder]
B4[LLM Adapter]
B5[Comment Synthesizer]
end
B -->|JSON| C(output)
License
Apache-2.0 License. See LICENSE for details.
Example Output
Standard Review
Line 32: Security - Logging raw input data may expose sensitive information.
Risk of data leakage. Remove or sanitize before logging.
Line 14: Bug - TODO indicates missing error handling. Could cause crashes.
Implement proper error handling.
Smart Review Output
🟡 **Code Quality Score:** 7.2/10
📝 **Total Issues Found:** 3
🚨 **Critical Issues:** 1
📁 **Files Analyzed:** 2
1. 2.
**💡 Recommended Fix:**
Use parameterized queries: `query = "SELECT * FROM users WHERE username=%s AND password=%s"`
**🔧 Code Example:**
```diff
- ++
### Commit Message Suggestion
feat(auth): add JWT-based authentication system
## Author
Jonathan Haas <jonathan@haas.holdings>
## Contributing
Contributions are welcome! Please open an issue first to discuss what you would like to change.
## Support
- GitHub Issues: [github.com/Haasonsaas/diffscope/issues](https://github.com/Haasonsaas/diffscope/issues)