Diff Review Doc
Generate comprehensive code review documents from git diffs, providing detailed analysis with real code snippets, business flow breakdown, and actionable review recommendations.
Workflow
1. Obtain Diff Content
If user provides diff directly:
- Accept the diff content as-is
- Parse to identify changed files and hunks
If no diff is provided:
2. Analyze the Changes
Parse the diff to extract:
- File paths and change types (added/modified/deleted)
- Line-level changes (+/- lines)
- Context around changes
Read relevant files:
- For significant changes, read the full file to understand context
- For large files (>500 lines), focus on changed sections with surrounding context
- Pay special attention to backend files and large file changes
Identify patterns:
- Consult
references/patterns.md for common code issues
- Look for anti-patterns, security vulnerabilities, performance issues
- Check architectural concerns
3. Structure the Analysis
Follow this analysis framework:
改动概览 (Change Summary)
- Count files changed, lines added/removed
- Identify change type (feature/bugfix/refactor/performance/security)
- List key files with brief descriptions
- Note dependency or configuration changes
业务流程分析 (Business Flow Analysis)
- Explain what functionality is being implemented/changed
- Map out the complete business flow
- Show data flow between components
- Identify all affected modules
关键代码详解 (Key Code Analysis)
- For each significant file:
- Show actual diff snippets (use real code from the diff)
- Explain what the code does and why it changed
- Highlight logic correctness, edge cases, error handling, performance
- Prioritize backend files and large changes (>200 lines)
- Include file paths with line numbers for reference
风险评估 (Risk Assessment)
- Categorize risks as High/Medium/Low
- Identify breaking changes, security concerns, performance impacts
- Suggest mitigation measures
- Flag large file changes and backend-critical changes
4. Generate Review Recommendations
Consult references/review-checklist.md for comprehensive evaluation criteria:
- 代码质量 (Code Quality): Readability, complexity, best practices
- 架构设计 (Architecture): Modularity, coupling, extensibility, data flow
- 功能验证 (Functionality): Business logic, error handling, data consistency
- 安全性 (Security): Input validation, authentication, data protection (if applicable)
- 性能 (Performance): Database queries, resource usage, caching (if applicable)
For each category:
- Give a rating (1-5 stars)
- List strengths (what's done well)
- List issues (what needs improvement)
- Provide specific, actionable recommendations
Final recommendation:
- Must Fix: Critical issues that block merge
- Should Fix: Important issues to address
- Nice to Have: Optional improvements
- Merge decision: Approve / Conditional / Needs Work
5. Write the Review Document
Use assets/review-template.md as the base structure:
- Copy the template structure
- Fill in all sections with actual analysis from steps 2-4
- Ensure all code snippets are real (from the actual diff)
- Include complete business flow explanation
- Provide specific, actionable review suggestions
Output:
- Save as a Markdown file (e.g.,
REVIEW.md)
- Format for easy reading (proper headings, code blocks, lists)
- Include generation timestamp
Key Principles
Base on Real Code
- All code snippets must be extracted from the actual diff
- Never use placeholder or example code
- Show actual line numbers and file paths
Complete Business Context
- Explain the full user journey and data flow
- Connect frontend changes to backend logic
- Show how pieces fit together
Actionable Review Suggestions
- Be specific about what to check
- Identify potential risks with clear explanations
- Provide concrete improvement suggestions
- Prioritize issues by severity
Focus on Critical Areas
- Large file changes: >200 lines need detailed review
- Backend changes: API, database, auth, integrations
- Architectural changes: Design patterns, module boundaries
- Security-sensitive code: Input validation, data access
Resources
scripts/get_diff.sh
Bash script to retrieve git diffs in various scenarios. Supports getting uncommitted changes, staged changes, branch comparisons, and specific commits.
references/review-checklist.md
Comprehensive checklist covering all aspects of code review: quality, architecture, functionality, security, performance, testing, compatibility, operations, and documentation.
Load this reference when generating review recommendations to ensure thorough evaluation.
references/patterns.md
Catalog of common code patterns to watch for, including anti-patterns, security vulnerabilities, performance issues, and architectural concerns.
Load this reference during analysis phase to identify potential issues in the code changes.
assets/review-template.md
Structured Markdown template for the review document. Provides consistent format with sections for change summary, business flow, code analysis, risk assessment, and review recommendations.
Use as the base structure and fill in with actual analysis.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: diff-review-doc3description: Generate comprehensive, reviewer-ready code review documents from git diffs. Use this when the user provides code changes (git diff output, file changes, or asks to review code changes) and wants a structured review document. Creates detailed analysis covering change overview, business flow, key code explanation, risk assessment, and review recommendations. Supports both manual diff input and automatic git workspace detection. Particularly useful for reviewing pull requests, feature branches, or any code changes requiring thorough documentation for reviewers. Use when this capability is needed.4---56# Diff Review Doc78Generate comprehensive code review documents from git diffs, providing detailed analysis with real code snippets, business flow breakdown, and actionable review recommendations.910## Workflow1112### 1. Obtain Diff Content1314**If user provides diff directly:**15- Accept the diff content as-is16- Parse to identify changed files and hunks1718**If no diff is provided:**19- Use `scripts/get_diff.sh` to retrieve changes:20 ```bash21 # Get all uncommitted changes (default)22 ./scripts/get_diff.sh2324 # Get staged changes only25 ./scripts/get_diff.sh --staged2627 # Compare with a branch28 ./scripts/get_diff.sh --branch main2930 # Get changes from specific commit31 ./scripts/get_diff.sh --commit abc12332 ```3334### 2. Analyze the Changes3536**Parse the diff to extract:**37- File paths and change types (added/modified/deleted)38- Line-level changes (+/- lines)39- Context around changes4041**Read relevant files:**42- For significant changes, read the full file to understand context43- For large files (>500 lines), focus on changed sections with surrounding context44- Pay special attention to backend files and large file changes4546**Identify patterns:**47- Consult `references/patterns.md` for common code issues48- Look for anti-patterns, security vulnerabilities, performance issues49- Check architectural concerns5051### 3. Structure the Analysis5253**Follow this analysis framework:**54551. **改动概览 (Change Summary)**56 - Count files changed, lines added/removed57 - Identify change type (feature/bugfix/refactor/performance/security)58 - List key files with brief descriptions59 - Note dependency or configuration changes60612. **业务流程分析 (Business Flow Analysis)**62 - Explain what functionality is being implemented/changed63 - Map out the complete business flow64 - Show data flow between components65 - Identify all affected modules66673. **关键代码详解 (Key Code Analysis)**68 - For each significant file:69 - Show actual diff snippets (use real code from the diff)70 - Explain what the code does and why it changed71 - Highlight logic correctness, edge cases, error handling, performance72 - Prioritize backend files and large changes (>200 lines)73 - Include file paths with line numbers for reference74754. **风险评估 (Risk Assessment)**76 - Categorize risks as High/Medium/Low77 - Identify breaking changes, security concerns, performance impacts78 - Suggest mitigation measures79 - Flag large file changes and backend-critical changes8081### 4. Generate Review Recommendations8283**Consult `references/review-checklist.md` for comprehensive evaluation criteria:**8485- **代码质量 (Code Quality)**: Readability, complexity, best practices86- **架构设计 (Architecture)**: Modularity, coupling, extensibility, data flow87- **功能验证 (Functionality)**: Business logic, error handling, data consistency88- **安全性 (Security)**: Input validation, authentication, data protection (if applicable)89- **性能 (Performance)**: Database queries, resource usage, caching (if applicable)9091**For each category:**92- Give a rating (1-5 stars)93- List strengths (what's done well)94- List issues (what needs improvement)95- Provide specific, actionable recommendations9697**Final recommendation:**98- Must Fix: Critical issues that block merge99- Should Fix: Important issues to address100- Nice to Have: Optional improvements101- Merge decision: Approve / Conditional / Needs Work102103### 5. Write the Review Document104105**Use `assets/review-template.md` as the base structure:**106- Copy the template structure107- Fill in all sections with actual analysis from steps 2-4108- Ensure all code snippets are real (from the actual diff)109- Include complete business flow explanation110- Provide specific, actionable review suggestions111112**Output:**113- Save as a Markdown file (e.g., `REVIEW.md`)114- Format for easy reading (proper headings, code blocks, lists)115- Include generation timestamp116117## Key Principles118119### Base on Real Code120- All code snippets must be extracted from the actual diff121- Never use placeholder or example code122- Show actual line numbers and file paths123124### Complete Business Context125- Explain the full user journey and data flow126- Connect frontend changes to backend logic127- Show how pieces fit together128129### Actionable Review Suggestions130- Be specific about what to check131- Identify potential risks with clear explanations132- Provide concrete improvement suggestions133- Prioritize issues by severity134135### Focus on Critical Areas136- **Large file changes**: >200 lines need detailed review137- **Backend changes**: API, database, auth, integrations138- **Architectural changes**: Design patterns, module boundaries139- **Security-sensitive code**: Input validation, data access140141## Resources142143### scripts/get_diff.sh144Bash script to retrieve git diffs in various scenarios. Supports getting uncommitted changes, staged changes, branch comparisons, and specific commits.145146### references/review-checklist.md147Comprehensive checklist covering all aspects of code review: quality, architecture, functionality, security, performance, testing, compatibility, operations, and documentation.148149Load this reference when generating review recommendations to ensure thorough evaluation.150151### references/patterns.md152Catalog of common code patterns to watch for, including anti-patterns, security vulnerabilities, performance issues, and architectural concerns.153154Load this reference during analysis phase to identify potential issues in the code changes.155156### assets/review-template.md157Structured Markdown template for the review document. Provides consistent format with sections for change summary, business flow, code analysis, risk assessment, and review recommendations.158159Use as the base structure and fill in with actual analysis.160161---162> Converted and distributed by [TomeVault](https://tomevault.io/claim/arcblock) — claim your Tome and manage your conversions.163<!-- tomevault:4.0:skill_md:2026-04-12 -->