|
| 1 | +--- |
| 2 | +allowed-tools: Bash(git:*), Write |
| 3 | +description: Generate PR title and description from multiple commits (Korean and English) |
| 4 | +argument-hint: [BASE-BRANCH (default: auto-detect)] |
| 5 | +--- |
| 6 | + |
| 7 | +# Pull Request Content Generator |
| 8 | + |
| 9 | +Generates PR title and description by analyzing all commits in the current branch compared to the base branch. **Creates both Korean and English versions for easy copying.** |
| 10 | + |
| 11 | +## Repository State Analysis |
| 12 | + |
| 13 | +- Git status: !git status --porcelain |
| 14 | +- Current branch: !git branch --show-current |
| 15 | +- Default branch: !git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo "main" |
| 16 | +- Remote branches: !git branch -r --list 'origin/main' 'origin/master' 2>/dev/null |
| 17 | +- Commits since divergence: !git log --oneline origin/HEAD..HEAD 2>/dev/null || git log --oneline origin/main..HEAD 2>/dev/null || git log --oneline origin/master..HEAD 2>/dev/null || echo "Unable to detect base branch" |
| 18 | +- Changed files summary: !git diff --stat origin/HEAD..HEAD 2>/dev/null || git diff --stat origin/main..HEAD 2>/dev/null || git diff --stat origin/master..HEAD 2>/dev/null |
| 19 | + |
| 20 | +## What This Command Does |
| 21 | + |
| 22 | +1. Detects the base branch (main/master) automatically or uses provided argument |
| 23 | +2. Collects all commits from base to current HEAD |
| 24 | +3. Analyzes commit messages and changed files |
| 25 | +4. Generates a consolidated PR title (Conventional Commits style) |
| 26 | +5. Generates PR description with summary, changes, and related issues |
| 27 | +6. **Saves to pr_content.md file for easy copying** |
| 28 | + |
| 29 | +## When to Use This Command |
| 30 | + |
| 31 | +| Scenario | Recommendation | |
| 32 | +| ----------------------- | ------------------------------------------------------------ | |
| 33 | +| Single commit PR | Use commit message directly (GitHub does this automatically) | |
| 34 | +| **Multiple commits PR** | **Use this command** to consolidate changes | |
| 35 | +| Large feature branch | Use this command to summarize all work | |
| 36 | + |
| 37 | +## PR Title Format (Conventional Commits) |
| 38 | + |
| 39 | +``` |
| 40 | +<type>[(optional scope)]: <description> |
| 41 | +``` |
| 42 | + |
| 43 | +### Type Selection for PRs |
| 44 | + |
| 45 | +Analyze all commits and select the dominant type: |
| 46 | + |
| 47 | +| Pattern | PR Type | |
| 48 | +| ------------------------- | --------------------------------- | |
| 49 | +| Mostly `feat` commits | `feat` | |
| 50 | +| Mostly `fix` commits | `fix` | |
| 51 | +| Mixed `feat` and `fix` | `feat` (features take precedence) | |
| 52 | +| Only `docs` commits | `docs` | |
| 53 | +| Only `chore`/`ci` commits | `chore` | |
| 54 | +| `refactor` focused | `refactor` | |
| 55 | + |
| 56 | +**Priority**: `feat` > `fix` > `refactor` > `perf` > `docs` > `chore` |
| 57 | + |
| 58 | +### Title Writing Guidelines |
| 59 | + |
| 60 | +- **50 characters or less** (GitHub truncates longer titles) |
| 61 | +- Focus on **user-facing value**, not implementation details |
| 62 | +- Use imperative mood: "add feature" not "added feature" |
| 63 | + |
| 64 | +**Examples:** |
| 65 | + |
| 66 | +- ✅ `feat: add user authentication with OAuth2` |
| 67 | +- ✅ `fix: resolve memory leak in dashboard` |
| 68 | +- ❌ `Update files` (too vague) |
| 69 | +- ❌ `feat: implement OAuth2 authentication flow with Google and GitHub providers and session management` (too long) |
| 70 | + |
| 71 | +## PR Body Format |
| 72 | + |
| 73 | +### Summary Section |
| 74 | + |
| 75 | +1-3 sentences describing the overall change and its purpose. |
| 76 | + |
| 77 | +### Changes Section |
| 78 | + |
| 79 | +- Bullet points of key changes |
| 80 | +- Group by category if many changes |
| 81 | +- Focus on **what** changed, not **how** |
| 82 | + |
| 83 | +### Related Issues Section |
| 84 | + |
| 85 | +- Extract issue numbers from branch name and commits |
| 86 | +- Use `fix #N` format (consistent with commit.md) |
| 87 | + |
| 88 | +### Test Plan Section (Optional) |
| 89 | + |
| 90 | +- How to verify the changes work |
| 91 | +- Only include if non-trivial testing is needed |
| 92 | + |
| 93 | +## Output Template |
| 94 | + |
| 95 | +```markdown |
| 96 | +## PR Title (Korean) |
| 97 | + |
| 98 | +{type}: {한글 제목} |
| 99 | + |
| 100 | +## PR Title (English) |
| 101 | + |
| 102 | +{type}: {English title} |
| 103 | + |
| 104 | +--- |
| 105 | + |
| 106 | +## PR Body (Korean) |
| 107 | + |
| 108 | +### 요약 |
| 109 | + |
| 110 | +{변경사항 요약 1-3문장} |
| 111 | + |
| 112 | +### 주요 변경사항 |
| 113 | + |
| 114 | +- {변경사항 1} |
| 115 | +- {변경사항 2} |
| 116 | +- {변경사항 3} |
| 117 | + |
| 118 | +### 관련 이슈 |
| 119 | + |
| 120 | +fix #{issue_number} |
| 121 | + |
| 122 | +### 테스트 계획 |
| 123 | + |
| 124 | +{테스트 방법 - 필요시만} |
| 125 | + |
| 126 | +--- |
| 127 | + |
| 128 | +## PR Body (English) |
| 129 | + |
| 130 | +### Summary |
| 131 | + |
| 132 | +{1-3 sentence summary of changes} |
| 133 | + |
| 134 | +### Changes |
| 135 | + |
| 136 | +- {Change 1} |
| 137 | +- {Change 2} |
| 138 | +- {Change 3} |
| 139 | + |
| 140 | +### Related Issues |
| 141 | + |
| 142 | +fix #{issue_number} |
| 143 | + |
| 144 | +### Test Plan |
| 145 | + |
| 146 | +{How to test - if needed} |
| 147 | +``` |
| 148 | + |
| 149 | +## Issue Number Detection |
| 150 | + |
| 151 | +Extract issue numbers from: |
| 152 | + |
| 153 | +1. **Branch name**: `feature/123-add-auth` → `#123` |
| 154 | +2. **Commit messages**: `fix: resolve bug (fix #456)` → `#456` |
| 155 | +3. **Branch patterns**: `develop/user/42`, `issue-42-fix` → `#42` |
| 156 | + |
| 157 | +## Important Notes |
| 158 | + |
| 159 | +- This command ONLY generates PR content - it never creates actual PRs |
| 160 | +- **pr_content.md file contains both versions** - choose the one you prefer |
| 161 | +- For single-commit PRs, consider using the commit message directly |
| 162 | +- If branch name contains issue number, it will be auto-detected |
| 163 | +- Copy content from generated file and paste into GitHub PR form |
| 164 | +- Use `gh pr create` with the generated content for CLI workflow |
| 165 | + |
| 166 | +## Execution Instructions for Claude |
| 167 | + |
| 168 | +1. **Determine base branch**: |
| 169 | + - Use argument if provided: `$ARGUMENTS` |
| 170 | + - Otherwise: detect from `origin/HEAD`, `origin/main`, or `origin/master` |
| 171 | + |
| 172 | +2. **Collect commit information**: |
| 173 | + - Run: `git log --oneline {base}..HEAD` |
| 174 | + - Run: `git log --pretty=format:"%s" {base}..HEAD` for full messages |
| 175 | + - Run: `git diff --stat {base}..HEAD` for changed files |
| 176 | + |
| 177 | +3. **Analyze commits**: |
| 178 | + - Count commit types (feat, fix, docs, etc.) |
| 179 | + - Identify primary type based on frequency |
| 180 | + - Extract scope if commits share a common scope |
| 181 | + |
| 182 | +4. **Extract issue numbers**: |
| 183 | + - From branch name (current branch) |
| 184 | + - From commit messages (fix #N, closes #N patterns) |
| 185 | + |
| 186 | +5. **Generate PR title**: |
| 187 | + - Use dominant type |
| 188 | + - Summarize the overall change in ≤50 chars |
| 189 | + - Focus on user value |
| 190 | + |
| 191 | +6. **Generate PR body**: |
| 192 | + - Summary: What and why |
| 193 | + - Changes: Key modifications (3-7 bullet points) |
| 194 | + - Issues: All detected issue numbers |
| 195 | + - Test Plan: Only if non-trivial |
| 196 | + |
| 197 | +7. **Create both versions**: |
| 198 | + - Korean version first |
| 199 | + - English version second |
| 200 | + |
| 201 | +8. **Write to file**: |
| 202 | + - Save to `/workspaces/ai-config-toolkit/pr_content.md` |
| 203 | + - Overwrite if exists |
| 204 | + |
| 205 | +**Token optimization**: |
| 206 | + |
| 207 | +- Focus on commit messages, not full diffs |
| 208 | +- Summarize file changes by category |
| 209 | +- Limit to most recent 20 commits if branch has many |
0 commit comments