---
allowed-tools: Read, Write, Bash, Grep
argument-hint: [date] | --yesterday | --save-only
description: Generate End of Day report summarizing commits and work across all branches
---

# End of Day Report

Generate daily work summary: $ARGUMENTS

## Current State

- Current Date: !`date +%Y-%m-%d`
- Current Time: !`date +%H:%M`
- Current Branch: !`git branch --show-current`
- Git User: !`git config user.name`
- Git Email: !`git config user.email`

## Tasks

### 1. Determine Report Date and Scope

**Objective**: Identify the date range for the report

- [ ] Ask user for their work start time
  - Use AskUserQuestion to ask: "What time did you start working today?"
  - Provide options: "First commit time", "08:00", "09:00", "10:00", "Custom time"
  - If "Custom time" selected, ask for specific time (HH:MM format)
  - Default to first commit time if not specified
  - Use this for accurate "Work Duration" calculation

- [ ] Check if date argument provided
  - If `[date]` provided: Use specific date (format: YYYY-MM-DD)
  - If `--yesterday` provided: Use yesterday's date
  - Otherwise: Use today's date

```bash
# Get today's date
TODAY=$(date +%Y-%m-%d)

# Get yesterday's date
YESTERDAY=$(date -d "yesterday" +%Y-%m-%d)

# Get start of day
START_TIME="${TODAY} 00:00:00"

# Get end of day
END_TIME="${TODAY} 23:59:59"
```

- [ ] Set report scope
  - Search across **all branches** (local and remote)
  - Filter by git user name and email
  - Include commits from start to end of specified day

### 2. Collect Commit Information

**Objective**: Gather all commits made by the user on the specified date (excluding merge commits)

- [ ] Fetch commits across all branches (non-merge commits only)

```bash
# Get all non-merge commits by current user today across all branches
git log --all \
  --author="$(git config user.name)" \
  --since="$START_TIME" \
  --until="$END_TIME" \
  --pretty=format:"%h|%ai|%s|%D" \
  --no-merges
```

**Important**: Use `--no-merges` flag to exclude PR merge commits. These will be tracked separately in section 3.

- [ ] Extract commit details:
  - Commit hash (short)
  - Commit time
  - Commit message
  - Branch references (if any)

- [ ] Group commits by branch
  - Parse branch references from commit output
  - Identify which branch each commit belongs to
  - Track branch switches during the day
  - Exclude "Merged PR" commits from this section (they appear in Merge Activity instead)

**Example Output**:
```
c208327db|2025-10-28 14:23:45|feat(crm-data-access,checkout): improve primary bonus card selection logic|feature/5202-Praemie
9020cb305|2025-10-28 10:15:32|✨ feat(navigation): implement title management and enhance tab system|feature/5351-navigation
```

### 3. Identify PR and Merge Activity

**Objective**: Find pull requests created or merged today, distinguishing between PRs I merged vs PRs merged by colleagues

- [ ] Find ALL merge commits with "Merged PR" (check both author and committer)

```bash
# Get all PR merge activity with author and committer info
git log --all \
  --since="$START_TIME" \
  --until="$END_TIME" \
  --grep="Merged PR" \
  --pretty=format:"%h|%ai|%s|Author: %an <%ae>|Committer: %cn <%ce>"
```

- [ ] Categorize PR merges:
  - **PRs I merged**: Where I am the COMMITTER (git config user.name matches committer name)
  - **My PRs merged by colleagues**: Where I am the AUTHOR but someone else is the COMMITTER
  - **Colleague PRs I merged**: Where someone else is the AUTHOR and I am the COMMITTER

- [ ] Parse PR numbers from commit messages
  - Look for patterns: "Merged PR 1234:", "PR #1234", etc.
  - Extract PR title/description
  - Note which branch was merged
  - Note who performed the merge (committer name)

- [ ] Identify branch merges
  - Look for merge commits to develop/main
  - Note feature branches merged

### 4. Analyze Branch Activity

**Objective**: Summarize branches worked on today

- [ ] List all branches with commits today

```bash
# Get unique branches with activity today
git log --all \
  --author="$(git config user.name)" \
  --since="$START_TIME" \
  --until="$END_TIME" \
  --pretty=format:"%D" | \
  grep -v '^$' | \
  tr ',' '\n' | \
  sed 's/^ *//' | \
  grep -E '^(origin/)?[a-zA-Z]' | \
  sort -u
```

- [ ] Identify:
  - Primary branch worked on (most commits)
  - Other branches touched
  - New branches created today
  - Branches merged today

- [ ] Check current branch status
  - Uncommitted changes
  - Untracked files
  - Ahead/behind develop

### 5. Generate Report Summary

**Objective**: Create formatted markdown report

- [ ] Build report structure:

```markdown
# End of Day Report - YYYY-MM-DD

**Developer**: [Name] <email>
**Date**: Day, Month DD, YYYY
**Time**: HH:MM

---

## 📊 Summary

- **Commits**: X commits across Y branches
- **PRs I Merged**: Z pull requests (as committer)
- **My PRs Merged by Colleagues**: W pull requests
- **Primary Branch**: branch-name
- **Work Duration**: Started at HH:MM, worked for Xh Ym

## 🔨 Commits Today

### Branch: feature/5351-navigation (5 commits)
- `9020cb3` (10:15) ✨ feat(navigation): implement title management and enhance tab system
- `abc1234` (11:30) fix(navigation): resolve routing edge case
- `def5678` (14:45) test(navigation): add comprehensive test coverage
- `ghi9012` (15:20) refactor(navigation): improve code organization
- `jkl3456` (16:00) docs(navigation): update README with usage examples

### Branch: feature/5202-Praemie (2 commits)
- `c208327` (14:23) feat(crm-data-access,checkout): improve primary bonus card selection logic
- `mno7890` (16:45) fix(checkout): handle edge case for bonus points

## 🔀 Merge Activity

### PRs I Merged (as committer)
- **PR #1990**: feat(ui): add new button variants → develop
- **PR #1991**: fix(api): resolve timeout issues → develop

### My PRs Merged by Colleagues
- **PR #1987**: Carousel Library → develop (merged by Nino Righi)
- **PR #1989**: fix(checkout): resolve currency constraint violations → develop (merged by Nino Righi)

### Branch Merges
- `feature/5202-Praemie-stock-info-request-batching` → `feature/5202-Praemie`

## 🌿 Branch Activity

**Primary Branch**: feature/5351-navigation (5 commits)

**Other Branches**:
- feature/5202-Praemie (2 commits)
- develop (merged 2 PRs)

**Current Branch**: feature/5351-navigation
**Status**: 3 files changed, 2 files staged, 1 file untracked

## 📝 Notes

[Optional section for manual notes - left empty by default]

---

_Report generated on YYYY-MM-DD at HH:MM_
```

**Formatting Rules**:
- Use emoji for section headers (📊 📝 🔨 🔀 🌿)
- Group commits by branch
- Show time for each commit in (HH:MM) format
- Include commit prefixes (feat:, fix:, docs:, etc.)
- Sort branches by number of commits (most active first)
- Highlight primary branch (most commits)

### 6. Save and Display Report

**Objective**: Output report to terminal and save to file

**Display to Terminal**:
- [ ] Print formatted report to stdout
- [ ] Use clear visual separators
- [ ] Ensure easy copy/paste to Slack/Teams/Email

**Save to File**:
- [ ] Create reports directory if it doesn't exist

```bash
mkdir -p reports/eod
```

- [ ] Determine filename
  - Format: `reports/eod/YYYY-MM-DD.md`
  - Example: `reports/eod/2025-10-28.md`

- [ ] Write report to file

```bash
# Save report
cat > "reports/eod/${TODAY}.md" << 'EOF'
[report content]
EOF
```

- [ ] Provide file location feedback
  - Show absolute path to saved file
  - Confirm successful save

**If `--save-only` flag**:
- [ ] Skip terminal display
- [ ] Only save to file
- [ ] Show success message with file path

### 7. Provide Summary Statistics

**Objective**: Show quick statistics and next steps

- [ ] Calculate and display:
  - Total commits today (excluding PR merge commits)
  - Number of branches worked on
  - PRs I merged (as committer)
  - My PRs merged by colleagues (authored by me, committed by others)
  - Work duration (user-specified start time → last commit time)
  - Lines of code changed (optional, if available)

- [ ] Suggest next steps:
  - Commit uncommitted changes
  - Push branches to remote
  - Create PR for completed work
  - Update task tracking system

## Output Format

### Standard Display

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 End of Day Report - 2025-10-28
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

**Developer**: Lorenz Hilpert <lorenz@example.com>
**Date**: Monday, October 28, 2025
**Time**: 17:30

---

## 📊 Summary

- **Commits**: 5 commits across 1 branch
- **PRs I Merged**: 2 pull requests (as committer)
- **My PRs Merged by Colleagues**: 0
- **Primary Branch**: feature/5351-navigation
- **Work Duration**: Started at 09:00, worked for 7h 45m (last commit at 16:45)

## 🔨 Commits Today

### Branch: feature/5351-navigation (5 commits)
- `9020cb3` (10:15) ✨ feat(navigation): implement title management and enhance tab system
- `abc1234` (11:30) 🐛 fix(navigation): resolve routing edge case
- `def5678` (14:45) ✅ test(navigation): add comprehensive test coverage
- `ghi9012` (15:20) ♻️ refactor(navigation): improve code organization
- `jkl3456` (16:00) 📝 docs(navigation): update README with usage examples

### Branch: feature/5202-Praemie (2 commits)
- `c208327` (14:23) ✨ feat(crm-data-access,checkout): improve primary bonus card selection logic
- `mno7890` (16:45) 🐛 fix(checkout): handle edge case for bonus points

## 🔀 Merge Activity

### PRs I Merged (as committer)
- **PR #1987**: Carousel Library → develop
- **PR #1989**: fix(checkout): resolve currency constraint violations → develop

### My PRs Merged by Colleagues
_None today_

## 🌿 Branch Activity

**Primary Branch**: feature/5351-navigation (5 commits)

**Other Branches**:
- feature/5202-Praemie (2 commits)
- develop (2 PR merges)

**Current Status**:
- Branch: feature/5351-navigation
- Changes: 3 files changed, 2 files staged, 1 file untracked
- Remote: 5 commits ahead of origin/feature/5351-navigation

## 📝 Notes

_No additional notes_

---

✅ Report saved to: /home/lorenz/Projects/ISA-Frontend/reports/eod/2025-10-28.md

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 Daily Statistics
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Total Commits: 5 (excluding PR merges)
Branches: 1 active branch
PRs I Merged: 2
My PRs Merged by Colleagues: 0
Work Duration: 7h 45m (started at 09:00, last commit at 16:45)

📋 Next Steps
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1. ✅ Push feature/5351-navigation to remote
2. ⚠️  Consider creating PR for completed work
3. 💾 1 untracked file - review and commit if needed
```

### No Activity Case

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 End of Day Report - 2025-10-28
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

**Developer**: Lorenz Hilpert <lorenz@example.com>
**Date**: Monday, October 28, 2025
**Time**: 17:30

---

## 📊 Summary

No commits found for today (2025-10-28).

**Possible Reasons**:
- No development work performed
- Working on uncommitted changes
- Using different git user configuration

**Current Branch**: feature/5351-navigation
**Uncommitted Changes**: 5 files modified, 2 files staged

---

💡 Tip: If you have uncommitted work, commit it before generating the report.
```

### Yesterday's Report

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 End of Day Report - 2025-10-27 (Yesterday)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

[Report content for yesterday]

✅ Report saved to: /home/lorenz/Projects/ISA-Frontend/reports/eod/2025-10-27.md
```

## Usage Examples

```bash
# Generate today's EOD report
/eod-report

# Generate yesterday's report (if you forgot)
/eod-report --yesterday

# Generate report for specific date
/eod-report 2025-10-25

# Save to file only (no terminal output)
/eod-report --save-only

# Generate yesterday's report and save only
/eod-report --yesterday --save-only
```

## References

- Git Log Documentation: https://git-scm.com/docs/git-log
- Conventional Commits: https://www.conventionalcommits.org/
- Project Conventions: See CLAUDE.md for commit message standards
- Git Configuration: `git config user.name` and `git config user.email`
