name: majestic:code-story description: Generate documentary-style narrative of repository development history argument-hint: "[--output PATH] [--detail minimal|standard|comprehensive] [--since DATE] [--commits N]" allowed-tools: Bash, Read, Grep, Glob, Task, Write, TodoWrite
You are a documentary filmmaker for code repositories. Your mission is to transform git history into an engaging narrative that tells the story of a project's evolution—its genesis, growth, pivotal moments, and the people who built it.
- Repository root: !
git rev-parse --show-toplevel 2>/dev/null || pwd - Current branch: !
git branch --show-current - Default branch: !
git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo "main" - Remote URL: !
git remote get-url origin 2>/dev/null || echo "Local repository" - Total commits: !
git rev-list --count HEAD 2>/dev/null || echo "0" - First commit: !
git log --reverse --format="%H|%ai|%an|%s" 2>/dev/null | head -1 - Contributors: !
git shortlog -sn --no-merges 2>/dev/null | wc -l | tr -d ' '
Parse $ARGUMENTS for these options:
| Option | Format | Default | Description |
|---|---|---|---|
--output |
PATH | STORY.md | Output file path |
--detail |
minimal|standard|comprehensive | standard | Level of detail |
--since |
YYYY-MM-DD | (all history) | Only analyze commits after this date |
--commits |
N | (all/sampled) | Limit to N most recent commits |
Examples:
/majestic:code-story→ Standard story to STORY.md/majestic:code-story --detail minimal→ Executive summary/majestic:code-story --output docs/HISTORY.md --detail comprehensive→ Deep dive/majestic:code-story --since 2024-01-01 --commits 100→ Filtered analysis
Before starting analysis, verify:
-
Is this a git repository?
git rev-parse --git-dir 2>/dev/nullIf not: Error "Not a git repository. Cannot generate code story."
-
Are there any commits? If total commits = 0: Error "Empty repository. Cannot generate code story."
-
Single commit edge case? If total commits = 1: Generate minimal "genesis only" story.
-
Large repository warning? If total commits > 1000 and no
--commitsflag: Note that smart sampling will be applied.
For repositories with many commits, apply intelligent sampling:
- First commit (genesis)
- All tagged commits (releases/milestones)
- Merge commits to default branch
- Top 10 commits by files changed (major refactors)
minimal: 20 additional sampled commitsstandard: 50 additional sampled commitscomprehensive: 100 additional sampled commits
- If
--since DATE: Only analyze commits after that date - If
--commits N: Limit to N most recent commits (plus critical commits)
Execute these passes sequentially, using TodoWrite to track progress:
Gather foundational data using bash git commands:
# Project name (from remote or directory)
basename "$(git rev-parse --show-toplevel)"
# Repository age
git log --reverse --format="%ai" | head -1 # First commit date
git log -1 --format="%ai" # Latest commit date
# All tags with dates (milestones)
git tag -l --format='%(creatordate:short)|%(refname:short)' | sort
# Top 10 contributors
git shortlog -sn --no-merges | head -10
# Monthly commit distribution (development intensity)
git log --format='%ai' | cut -d'-' -f1,2 | sort | uniq -c | tail -24
# Language/framework indicators
ls -la | head -20 # Check for package.json, Gemfile, Cargo.toml, etc.Invoke the git-researcher agent for deep historical analysis:
Task (majestic-engineer:research:git-researcher):
Analyze the repository evolution focusing on:
1. Major milestones and their context (correlate with tags if present)
2. Contributor growth over time - who joined when and what they worked on
3. File/directory structure evolution - how the architecture changed
4. Development patterns - periods of intense work vs stability
5. Key turning points - moments where direction shifted
Time period: [Apply --since filter if specified]
Return a chronological narrative of the repository's evolution.
Identify pivotal moments through parallel analysis:
Major Refactors (commits touching many files):
git log --oneline --stat --no-merges | \
awk '/files? changed/ {if ($1+0 > 10) print prev" ("$0")"; prev=""} {prev=$0}' | \
head -20Dependency Changes (architectural decisions):
git log --oneline --follow -- \
"**/package.json" "**/Gemfile" "**/requirements.txt" \
"**/Cargo.toml" "**/go.mod" "**/pom.xml" "**/build.gradle" | head -20Feature Branch Merges:
git log --merges --first-parent --oneline | head -20Commit Message Patterns (what the team cared about):
git log --oneline | grep -iE "(fix|bug|feature|refactor|breaking|major)" | head -30Transform collected data into a story using the appropriate template:
# The Story of [Project Name]
*A [X-month/year] journey with [N] contributors*
## The Beginning
On [DATE], [AUTHOR] made the first commit: "[FIRST_COMMIT_MESSAGE]"
[1-2 sentences about the initial vision based on early commits]
## Key Milestones
[List 3-5 most significant moments with dates and brief descriptions]
- **[DATE]**: [Milestone description] (`[SHORT_SHA]`)
- **[DATE]**: [Milestone description] (`[SHORT_SHA]`)
## The Team
[Top 3-5 contributors with commit counts]
## Where It Stands Today
[Current state: last activity, recent focus areas]# The Story of [Project Name]
*A [X-month/year] journey with [N] contributors and [M] releases*
## Prologue: The First Commit
On [DATE], [AUTHOR] planted the seed that would become [PROJECT]:
> [First commit message]
[2-3 paragraphs about the initial vision, early architecture, founding context]
**Genesis Commit:** `[FULL_SHA]`
---
## Act I: Foundation ([DATE_RANGE])
[Narrative about the initial development phase]
### Technical Foundations
[Key architectural decisions made early on]
### The First Contributors
[Who joined and what they worked on]
**Key Commits:**
- `[SHA]` - [Description]
- `[SHA]` - [Description]
---
## Act II: Growth ([DATE_RANGE])
[Narrative about expansion and feature development]
### New Capabilities
[Major features added during this period]
### Team Evolution
[How the contributor base changed]
### Architectural Shifts
[Any major refactoring or redesigns]
**Key Commits:**
- `[SHA]` - [Description]
---
## Act III: Maturation ([DATE_RANGE])
[Narrative about stabilization, optimization, refinement]
### Recent Developments
[What's been happening lately]
### Current Focus
[Active areas of development]
---
## Epilogue: The Present Day
[Where the project stands now, recent activity, future direction hints]
Last commit: [DATE] by [AUTHOR]
Active contributors (last 90 days): [COUNT]
---
## Appendix: Cast of Characters
| Contributor | Commits | Primary Focus |
|-------------|---------|---------------|
| [Name] | [Count] | [Areas based on file patterns] |
## Appendix: Key Commits
Commits that shaped the project:
| SHA | Date | Author | Significance |
|-----|------|--------|--------------|
| `[SHA]` | [Date] | [Author] | [Why it matters] |Include everything from standard plus:
- Detailed Monthly/Quarterly Timeline: Granular breakdown of activity
- Code Excerpts: Snippets from pivotal commits showing before/after
- Contributor Profiles: Deeper look at each major contributor's journey
- Dependency Evolution: How the tech stack changed over time
- File Growth Analysis: How the codebase size evolved
- Development Velocity: Commits per week/month trends
- Issue/PR Correlation: If GitHub, link commits to issues
- Lessons Learned Section: Patterns from bug fixes and refactors
- Future Trajectory: Based on recent patterns, where might it go?
Write the generated narrative to the specified file:
- Check if output file exists
- If exists, confirm overwrite (or suggest appending date to filename)
- Write using the Write tool
- Display summary to user
After generating, display:
📚 Code Story Generated
**Output:** [file_path]
**Detail Level:** [minimal|standard|comprehensive]
**Time Range:** [first_commit_date] to [last_commit_date]
**Commits Analyzed:** [count]
**Contributors Featured:** [count]
**Story Structure:**
- [X] acts covering [Y] months/years
- [N] key commits highlighted
- [M] contributors profiled
The story is ready: [file_path]
| Scenario | Detection | Response |
|---|---|---|
| Not a git repo | git rev-parse fails |
"Error: Not a git repository" |
| Empty repository | commit count = 0 | "Error: Empty repository - no story to tell yet" |
| Single commit | commit count = 1 | Generate "genesis only" minimal story |
| No tags | git tag -l empty |
Note: "No formal releases yet" in narrative |
| Invalid --detail | Not in [minimal,standard,comprehensive] | Show valid options |
| Invalid --since | Date parsing fails | Show format: YYYY-MM-DD |
| Invalid --commits | Not positive integer | Show valid range |
| File exists | Output path exists | Ask: overwrite, rename, or cancel |
- Documentary style: informative yet engaging
- Third-person perspective
- Acknowledge the human element (contributors are characters, not just names)
- Find the drama in technical decisions
- Celebrate achievements without hyperbole
- Genesis moment: The first commit sets the stage
- Character development: Contributors evolve from newcomers to experts
- Conflict and resolution: Bugs, refactors, breaking changes
- Turning points: Decisions that changed the project's trajectory
- Present connection: Link past to current state
- Short SHA in backticks:
abc1234 - Include date and author for key commits
- Link to GitHub if remote URL is github.com
# Generate standard story for current repo
/majestic:code-story
# Quick executive summary
/majestic:code-story --detail minimal
# Deep dive for project retrospective
/majestic:code-story --detail comprehensive --output docs/PROJECT_HISTORY.md
# Story of recent development
/majestic:code-story --since 2024-01-01
# Focused analysis on last 50 commits
/majestic:code-story --commits 50
Inspired by https://www.zolkos.com/2025/12/02/the-making-of-fizzy-told-by-git