Comprehensive code evolution analysis through git history, PRs, and collaborative development patterns
Analyzes git history, PRs, and collaboration patterns to generate comprehensive code evolution reports.
/plugin marketplace add dgriffith/bad-daves-robot-army/plugin install dgriffith-bad-daves-robot-army@dgriffith/bad-daves-robot-armyUsing @agent-code-historian analyze the code history and evolution patterns. You must create a comprehensive, detailed historical analysis report WITHOUT making any changes.
The user invoked: /code-history-detailed {optional_scope}
Valid scopes:
If scope is a file or directory path:
git log --follow --stat -- <path> to track changesgit blame <path> for line-level authorshipIf scope includes "author:":
git log --author="<name>" to filter commitsIf scope includes time period:
git log --since="<date>" to filter by dateIf scope is "PR #N":
gh pr view <N> to get PR detailsgh pr diff <N> to see changesgit log --grep="<PR reference>" to find related commitsIf scope is "hotspots":
git log --all --numstat --format="%H" to count changes per fileIf scope is "co-changes":
git log --name-only --pretty=format:"%H" to group files by commitIf no scope provided:
Data Collection
Timeline Construction
Authorship Analysis
Co-change Pattern Detection
Hotspot Identification
PR Pattern Analysis
Create a markdown file at /reports/code-history-{scope}-{timestamp}.md with:
# Code History Analysis
Generated: {timestamp}
Scope: {scope_description}
Analysis Period: {date_range}
## Executive Summary
Brief overview of code evolution patterns and key findings
## Timeline
### Major Events
- YYYY-MM-DD: {significant change description} (commit: abc123)
- YYYY-MM-DD: {feature introduction} (PR #456)
- YYYY-MM-DD: {refactoring event} (commit: def789)
### Evolution Visualization
{ASCII timeline or text-based visualization}
## Authorship Analysis
### Top Contributors
| Author | Commits | Files Changed | Lines Added | Lines Removed |
|--------|---------|---------------|-------------|---------------|
| Alice | 150 | 45 | 5000 | 2000 |
| Bob | 120 | 38 | 4500 | 1800 |
### Code Ownership
- **Module A**: Primarily Alice (60%), Bob (30%)
- **Module B**: Primarily Bob (70%), Charlie (20%)
### Collaboration Patterns
- Alice and Bob frequently collaborate on auth module
- Charlie works independently on UI components
## Change Frequency Analysis
### Hotspots (Top 20)
| File | Changes | Authors | First Modified | Last Modified |
|------|---------|---------|----------------|---------------|
| src/auth.js | 45 | 3 | 2023-01-15 | 2024-12-01 |
### Interpretation
- High churn files indicate:
- Unstable requirements
- Technical debt areas
- Complex business logic
## Co-change Patterns
### Files That Change Together
| File Pair | Co-change Count | Coupling Strength |
|-----------|-----------------|-------------------|
| auth.js + user.js | 23 | High |
| api.js + routes.js | 18 | Medium |
### Change Clusters
- **Cluster 1**: Authentication system (auth.js, user.js, session.js)
- **Cluster 2**: API layer (api.js, routes.js, middleware.js)
### Architectural Insights
- Co-change patterns reveal module boundaries
- High coupling between X and Y suggests refactoring opportunity
## Pull Request Analysis
### PR Statistics
- Total PRs: X
- Average PR size: Y files changed
- Average review time: Z hours
### Notable PRs
- **PR #123** (2024-06-15): Major refactoring of auth system
- Files: 15 changed
- Impact: Touched multiple modules
### PR Patterns
- Feature PRs typically involve 5-8 files
- Bug fixes usually touch 1-3 files
- Refactorings can affect 10+ files
## Commit Patterns
### Commit Message Analysis
- X% follow conventional commits
- Common prefixes: feat, fix, refactor, docs
- Quality varies by author
### Commit Size
- Average files per commit: X
- Median lines changed: Y
- Large commits (>500 lines): Z
## Historical Insights
### Code Stability
- Stable modules (few changes): {list}
- Unstable modules (many changes): {list}
### Development Velocity
- Commits per week trend: {description}
- Active development periods: {list}
### Technical Debt Indicators
- Files with >20 commits: {list}
- Frequent bug fixes in: {list}
- Refactoring candidates: {list}
## Key Findings
1. {Finding with supporting data}
2. {Finding with supporting data}
3. {Finding with supporting data}
## Appendix
### Command Reference
```bash
# Commands used for this analysis
git log --all --since="X" --format="%h|%an|%at|%s"
gh pr list --state merged --limit 100
Remember: DO NOT make any changes. Only analyze and report. Focus on building insights from historical data to inform future development decisions.