Git Commit Analysis Reference
Git Commands Reference
Basic Commit Inspection
# View commit summary
git show <hash> --stat
# View full diff
git show <hash>
# View commit message
git log -1 <hash> --pretty=format:"%s%n%n%b"
# View specific file in commit
git show <hash>:path/to/file
# View file before commit
git show <hash>^:path/to/file
# Compare with parent commit
git diff <hash>^..<hash>
Advanced Inspection
# View commit with context
git show <hash> -U10 # 10 lines of context
# View only specific file changes
git show <hash> -- path/to/file
# View commit tree
git show <hash> --name-status
# View commit with word diff
git show <hash> --word-diff
Analysis Depth Levels
Level 1: Surface Analysis
- Read commit message
- List changed files
- Summarize changes
Level 2: Code Analysis
- Read changed code sections
- Understand what changed
- Identify patterns
Level 3: Deep Analysis (This Skill)
- Read surrounding context
- Understand why changes were made
- Analyze design decisions
- Assess impact
Code Reading Strategies
Strategy 1: Top-Down
- Read function/class definition
- Read callers
- Read implementation details
Strategy 2: Bottom-Up
- Read changed code
- Read related functions
- Understand overall pattern
Strategy 3: Context-First
- Read 50-100 lines before change
- Read changed section
- Read 50-100 lines after change
- Understand full context
Common Change Patterns
Pattern: Variable Rename
- Usually simple but check all usages
- May indicate semantic change
Pattern: Function Extraction
- Check if extracted function is reused
- Understand abstraction level
Pattern: Condition Addition
- What edge case is being handled?
- Why wasn't it handled before?
Pattern: Data Structure Change
- Performance implications?
- API compatibility?
Analysis Questions Checklist
For each change, ask:
What Changed?
Why Changed?
How Changed?
Impact?
Code Context Guidelines
Minimum Context
- Function changes: Include entire function
- Class changes: Include class definition
- File-level: Include imports and related functions
Recommended Context
- 50-100 lines before change
- 50-100 lines after change
- Related functions in same file
- Callers of changed functions
Extended Context (when needed)
- Related files that interact
- Similar patterns in codebase
- Historical context (previous commits)
Output Quality Standards
Code Snippets
- ✅ Include line numbers
- ✅ Show sufficient context (50-100 lines)
- ✅ Highlight key changes
- ✅ Include both before/after
Analysis Depth
- ✅ Explain "why" not just "what"
- ✅ Cover business and technical aspects
- ✅ Identify potential issues
- ✅ Suggest improvements if relevant
Structure
- ✅ Clear sections and subsections
- ✅ Use emojis for visual organization
- ✅ Code blocks properly formatted
- ✅ Links to related code when helpful