From 5e73fc1dabfe045ab6be7aaa0f6ef4b3b300078f Mon Sep 17 00:00:00 2001 From: Lorenz Hilpert Date: Tue, 28 Oct 2025 21:04:04 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20chore:=20ad?= =?UTF-8?q?d=20EOD=20report=20and=20changelog=20generation=20slash=20comma?= =?UTF-8?q?nds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add two new Claude Code slash commands for developer workflow: - /eod-report: Generate daily work summaries from git commits - /generate-changelog: Create changelog entries from git tags Both commands support flexible date ranges and output formatting. --- .claude/commands/eod-report.md | 434 +++++++++++++++++++++++++ .claude/commands/generate-changelog.md | 309 ++++++++++++++++++ 2 files changed, 743 insertions(+) create mode 100644 .claude/commands/eod-report.md create mode 100644 .claude/commands/generate-changelog.md diff --git a/.claude/commands/eod-report.md b/.claude/commands/eod-report.md new file mode 100644 index 000000000..03de09d87 --- /dev/null +++ b/.claude/commands/eod-report.md @@ -0,0 +1,434 @@ +--- +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] +**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 +**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 +**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` diff --git a/.claude/commands/generate-changelog.md b/.claude/commands/generate-changelog.md new file mode 100644 index 000000000..44743f0a9 --- /dev/null +++ b/.claude/commands/generate-changelog.md @@ -0,0 +1,309 @@ +--- +allowed-tools: Read, Write, Edit, Bash, Grep +argument-hint: [version] | --since [tag] | --dry-run +description: Generate changelog entries from git tags using Keep a Changelog format +--- + +# Generate Changelog + +Generate changelog entries from git commits between version tags: $ARGUMENTS + +## Current State + +- Latest Tag: !`git tag --sort=-creatordate | head -n 1` +- CHANGELOG.md: !`test -f CHANGELOG.md && echo "exists" || echo "does not exist"` +- Commits Since Last Tag: !`git log $(git tag --sort=-creatordate | head -n 1)..HEAD --oneline | wc -l` +- Current Branch: !`git branch --show-current` + +## Tasks + +### 1. Determine Version Range + +**Objective**: Identify the commit range for changelog generation + +- [ ] Check if version argument provided + - If `[version]` provided: Use as the new version number + - If `--since [tag]` provided: Use custom tag as starting point + - Otherwise: Use latest tag as starting point + +```bash +# Find latest tag +LATEST_TAG=$(git tag --sort=-creatordate | head -n 1) + +# Get commits since tag +git log ${LATEST_TAG}..HEAD --oneline + +# If no tags exist, use entire history +if [ -z "$LATEST_TAG" ]; then + git log --oneline +fi +``` + +**Edge Cases**: +- No tags exist → Use entire commit history and suggest version 0.1.0 +- No commits since last tag → Notify user, no changelog needed +- Invalid tag provided → Error with available tags list + +### 2. Extract and Categorize Commits + +**Objective**: Parse commit messages and group by Keep a Changelog categories + +- [ ] Fetch commits with detailed information + +```bash +# Get commits with format: hash | date | message +git log ${LATEST_TAG}..HEAD --pretty=format:"%h|%as|%s" --no-merges +``` + +- [ ] Parse conventional commit patterns and map to categories: + +**Mapping Rules**: +- `feat:` or `feature:` → **Added** +- `fix:` or `bugfix:` → **Fixed** +- `refactor:` → **Changed** +- `perf:` or `performance:` → **Changed** +- `docs:` → **Changed** (or skip if only documentation) +- `style:` → **Changed** +- `test:` → (skip from changelog) +- `chore:` → (skip from changelog) +- `build:` or `ci:` → (skip from changelog) +- `revert:` → **Changed** or **Fixed** +- `security:` → **Security** +- `deprecate:` or `deprecated:` → **Deprecated** +- `remove:` or `breaking:` → **Removed** +- Non-conventional commits → **Changed** (default) + +- [ ] Extract scope and description from commit messages + +**Commit Pattern**: `type(scope): description` + +Example: +``` +feat(checkout): add reward delivery order support +fix(remission): resolve currency constraint violations +refactor(navigation): implement title management system +``` + +### 3. Generate Changelog Entry + +**Objective**: Create properly formatted changelog section + +- [ ] Determine version number + - Use provided `[version]` argument + - Or prompt for new version if not provided + - Format: `[X.Y.Z]` following semantic versioning + +- [ ] Get current date in ISO format: `YYYY-MM-DD` + +```bash +TODAY=$(date +%Y-%m-%d) +``` + +- [ ] Build changelog entry following Keep a Changelog format: + +```markdown +## [VERSION] - YYYY-MM-DD + +### Added +- New feature description from feat: commits +- Another feature + +### Changed +- Refactored component description +- Performance improvements + +### Deprecated +- Feature marked for removal + +### Removed +- Deleted feature or breaking change + +### Fixed +- Bug fix description +- Another fix + +### Security +- Security improvement description +``` + +**Rules**: +- Only include sections that have entries +- Sort entries alphabetically within each section +- Use sentence case for descriptions +- Remove commit type prefix from descriptions +- Include scope in parentheses if present: `(scope) description` +- Add reference links to commits/PRs if available + +### 4. Update or Preview CHANGELOG.md + +**Objective**: Append new entry to changelog file or show preview + +**If `--dry-run` flag provided**: +- [ ] Display generated changelog entry to stdout +- [ ] Show preview of where it would be inserted +- [ ] Do NOT modify CHANGELOG.md +- [ ] Exit with success + +**Otherwise (append mode)**: +- [ ] Check if CHANGELOG.md exists + - If not, create with standard header: + +```markdown +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +``` + +- [ ] Read existing CHANGELOG.md content +- [ ] Find insertion point (after "## [Unreleased]" section, or after main header) +- [ ] Insert new changelog entry +- [ ] Maintain reverse chronological order (newest first) +- [ ] Write updated content back to CHANGELOG.md + +```bash +# Backup existing file +cp CHANGELOG.md CHANGELOG.md.bak + +# Insert new entry +# (Implementation handled by Edit tool) +``` + +### 5. Validate and Report + +**Objective**: Verify changelog quality and provide summary + +- [ ] Validate generated entry: + - Version format is valid (X.Y.Z) + - Date is correct (YYYY-MM-DD) + - At least one category has entries + - No duplicate entries + - Proper markdown formatting + +- [ ] Report statistics: + - Number of commits processed + - Entries per category + - Version number used + - File status (preview/updated) + +- [ ] Show next steps: + - Review changelog entry + - Update version in package.json if needed + - Create git tag if appropriate + - Commit changelog changes + +## Output Format + +### Dry Run Preview + +``` +🔍 Changelog Preview (--dry-run mode) +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +## [1.5.0] - 2025-10-28 + +### Added +- (checkout) Add reward delivery order support +- (navigation) Implement title management and tab system + +### Changed +- (carousel) Update carousel library implementation +- (remission) Enhance returns processing workflow + +### Fixed +- (checkout) Resolve currency constraint violations in price handling + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +📊 Statistics +───────────── +Commits processed: 12 +Added: 2 entries +Changed: 2 entries +Fixed: 1 entry +Version: 1.5.0 +Date: 2025-10-28 + +⚠️ This is a preview. Run without --dry-run to update CHANGELOG.md +``` + +### Append Mode Success + +``` +✅ Changelog Updated Successfully +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +## [1.5.0] - 2025-10-28 + +### Added +- (checkout) Add reward delivery order support +- (navigation) Implement title management and tab system + +### Changed +- (carousel) Update carousel library implementation +- (remission) Enhance returns processing workflow + +### Fixed +- (checkout) Resolve currency constraint violations in price handling + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +📊 Statistics +───────────── +Commits processed: 12 +Added: 2 entries +Changed: 2 entries +Fixed: 1 entry +Version: 1.5.0 +File: CHANGELOG.md (updated) +Backup: CHANGELOG.md.bak + +📋 Next Steps +───────────── +1. Review the changelog entry in CHANGELOG.md +2. Update version in package.json: npm version 1.5.0 +3. Commit the changelog: git add CHANGELOG.md && git commit -m "docs: update changelog for v1.5.0" +4. Create git tag: git tag -a v1.5.0 -m "Release v1.5.0" +5. Push changes: git push && git push --tags +``` + +### Error Cases + +``` +❌ No Changes Found +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +No commits found since last tag (v1.4.5). +Nothing to add to changelog. +``` + +``` +❌ No Tags Found +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +No git tags found in this repository. + +Suggestions: +- Create your first tag: git tag v0.1.0 +- Or specify a commit range: /generate-changelog --since HEAD~10 +- Or generate from all commits: /generate-changelog 0.1.0 +``` + +``` +⚠️ Invalid Version Format +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Version "1.5" is invalid. +Expected format: X.Y.Z (e.g., 1.5.0) + +Please provide a valid semantic version. +``` + +## References + +- Keep a Changelog: https://keepachangelog.com/ +- Semantic Versioning: https://semver.org/ +- Conventional Commits: https://www.conventionalcommits.org/ +- Project Conventions: See CLAUDE.md for commit message standards