---
description: Generate comprehensive summaries of changes, PRs, or development work
argument-hint: <PR URL or commit range or status>
---

# /eg:summary

You are tasked with generating comprehensive summaries of development work including changed files, implementation approach, testing coverage, and impact assessment.

Input: `$ARGUMENTS`

## Step 1: Parse Summary Target

The entire argument is the summary target:
- PR URL (e.g., https://github.com/org/repo/pull/123)
- Commit range (e.g., HEAD~5..HEAD)
- "status" for current uncommitted changes

## Step 2: Gather Change Information

Based on the target type:

### For PR URL:
```
!gh pr view {pr-url} --json title,body,state,files
!gh pr diff {pr-url} | head -1000
```

### For commit range:
```
!git log --oneline {commit-range}
!git diff {commit-range} --stat
!git diff {commit-range} | head -1000
```

### For status:
```
!git status --porcelain
!git diff --stat
!git diff --cached --stat
!git diff HEAD | head -1000
```

## Step 3: Generate Summary

Use the Task tool to create a comprehensive summary:

```
Task(
  description="Generate change summary",
  prompt=`
    Create a comprehensive summary of the changes.
    
    Use the summary template from .claude/templates/summary.template.md
    
    Include in the summary:
    - Overview: High-level description of changes
    - Motivation: Why these changes were made
    - Technical Details: Key implementation decisions
    - Files Changed: Grouped by type/purpose
    - Testing: What was tested and coverage
    - Breaking Changes: Any backwards compatibility issues  
    - Migration Guide: If applicable
    - Impact Assessment: Performance, security, UX impacts
    
    Focus on:
    - The "why" not just the "what"
    - Grouping related changes
    - Highlighting important implications
    - Making it easy for reviewers
    
    Adapt tone based on context:
    - Technical and detailed for PR reviews
    - Broader and clearer for release notes
    - Concise for commit messages
  `,
  subagent_type="summarizer"
)
```

## Step 4: Format Output

Based on the use case, format appropriately:

### For PRs:
Include sections reviewers need:
- Problem/Solution summary
- Technical approach
- Testing performed
- Review checklist

### For Releases:
Focus on user-facing changes:
- New features
- Bug fixes
- Breaking changes
- Upgrade instructions

### For Documentation:
Provide context and examples:
- What changed
- Why it changed
- How to use new features
- Migration examples

## Step 5: Save Summary

Save the summary for future reference:
```
!echo "{generated-summary}" > summary-$(date +%Y%m%d-%H%M%S).md
```

Provide the formatted summary and suggest next steps based on the context.