# Git Commit Analysis Reference ## Git Commands Reference ### Basic Commit Inspection ```bash # View commit summary git show --stat # View full diff git show # View commit message git log -1 --pretty=format:"%s%n%n%b" # View specific file in commit git show :path/to/file # View file before commit git show ^:path/to/file # Compare with parent commit git diff ^.. ``` ### Advanced Inspection ```bash # View commit with context git show -U10 # 10 lines of context # View only specific file changes git show -- path/to/file # View commit tree git show --name-status # View commit with word diff git show --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 1. Read function/class definition 2. Read callers 3. Read implementation details ### Strategy 2: Bottom-Up 1. Read changed code 2. Read related functions 3. Understand overall pattern ### Strategy 3: Context-First 1. Read 50-100 lines before change 2. Read changed section 3. Read 50-100 lines after change 4. 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? - [ ] What code was modified? - [ ] What files were affected? - [ ] What functions/classes changed? ### Why Changed? - [ ] What problem does this solve? - [ ] What requirement drives this? - [ ] What bug was fixed? ### How Changed? - [ ] What approach was used? - [ ] Why this approach vs alternatives? - [ ] What trade-offs were made? ### Impact? - [ ] Does this break existing code? - [ ] Are tests updated? - [ ] Is documentation needed? - [ ] Performance implications? ## 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