|
| 1 | +--- |
| 2 | +name: commit-message |
| 3 | +description: This skill should be used when the user asks to "create a commit", "generate commit message", "commit changes", "make a commit", mentions "conventional commits", references "Jira issue in commit", or discusses commit message formatting. Provides guided workflow for creating properly formatted commit messages with Jira integration, line length validation, and required footers. |
| 4 | +version: 0.1.0 |
| 5 | +--- |
| 6 | + |
| 7 | +# Conventional Commit Message Creation |
| 8 | + |
| 9 | +Create properly formatted conventional commit messages following project standards with Jira integration, line length validation, and required footers. |
| 10 | + |
| 11 | +## Purpose |
| 12 | + |
| 13 | +Generate commit messages that: |
| 14 | + |
| 15 | +- Follow conventional commits format (`type(scope): description`) |
| 16 | +- Integrate Jira issue numbers automatically |
| 17 | +- Respect line length limits (50 for subject, 72 for body) |
| 18 | +- Include required footers (Signed-off-by, Assisted-by) |
| 19 | +- Pass gitlint validation |
| 20 | + |
| 21 | +## Quick Workflow |
| 22 | + |
| 23 | +1. **Analyze changes**: Run git status and git diff to understand modifications |
| 24 | +2. **Detect Jira scope**: Extract issue number from branch name or ask user |
| 25 | +3. **Generate message**: Create conventional commit message with proper formatting |
| 26 | +4. **Add footers**: Include Signed-off-by and Assisted-by trailers |
| 27 | +5. **Confirm with user**: Display message and wait for approval before committing |
| 28 | + |
| 29 | +**CRITICAL**: Never commit without explicit user confirmation. |
| 30 | + |
| 31 | +## Conventional Commit Format |
| 32 | + |
| 33 | +### Structure |
| 34 | + |
| 35 | +```text |
| 36 | +<type>(<scope>): <description> |
| 37 | +
|
| 38 | +[optional body] |
| 39 | +
|
| 40 | +Signed-off-by: <name> <email> |
| 41 | +Assisted-by: <model-name> (via Claude Code) |
| 42 | +```text |
| 43 | +
|
| 44 | +### Type Selection |
| 45 | +
|
| 46 | +Choose the appropriate commit type based on changes: |
| 47 | +
|
| 48 | +| Type | Description | Example | |
| 49 | +| ------ | ------------- | --------- | |
| 50 | +| `feat` | New features | `feat(webhook): add GitHub App support` | |
| 51 | +| `fix` | Bug fixes | `fix(controller): resolve pipeline race condition` | |
| 52 | +| `docs` | Documentation | `docs(README): update installation steps` | |
| 53 | +| `refactor` | Code refactoring | `refactor(matcher): simplify regex logic` | |
| 54 | +| `test` | Test changes | `test(webhook): add integration tests` | |
| 55 | +| `chore` | Maintenance | `chore(deps): update go dependencies` | |
| 56 | +| `build` | Build system | `build(Makefile): add vendor target` | |
| 57 | +| `ci` | CI/CD changes | `ci(github): add golangci-lint action` | |
| 58 | +| `perf` | Performance | `perf(cache): optimize lookup speed` | |
| 59 | +| `style` | Code style | `style(format): run fumpt formatter` | |
| 60 | +| `revert` | Revert commit | `revert: undo breaking API change` | |
| 61 | +
|
| 62 | +For complete type reference, see `references/commit-types.md`. |
| 63 | +
|
| 64 | +### Scope Rules |
| 65 | +
|
| 66 | +#### Priority 1: Extract from branch name |
| 67 | +
|
| 68 | +```bash |
| 69 | +# Branch: SRVKP-123-add-webhook-support |
| 70 | +# Scope: SRVKP-123 |
| 71 | +# Result: feat(SRVKP-123): add webhook support |
| 72 | +```text |
| 73 | +
|
| 74 | +Detect Jira issue using regex pattern: `[A-Z]{2,}-[0-9]+` |
| 75 | +
|
| 76 | +#### Priority 2: Ask user for Jira issue |
| 77 | +
|
| 78 | +If branch is `main`, `master`, or doesn't contain Jira pattern: |
| 79 | +
|
| 80 | +1. Ask user for Jira issue number |
| 81 | +2. Look up issue on issues.redhat.com if provided |
| 82 | +3. Use component name as fallback (webhook, controller, etc.) |
| 83 | +
|
| 84 | +#### Priority 3: Component fallback |
| 85 | +
|
| 86 | +Use affected component as scope: |
| 87 | +
|
| 88 | +- `feat(webhook): ...` |
| 89 | +- `fix(controller): ...` |
| 90 | +- `docs(README): ...` |
| 91 | +
|
| 92 | +## Line Length Requirements |
| 93 | +
|
| 94 | +### Subject Line |
| 95 | +
|
| 96 | +- **Target**: 50 characters maximum |
| 97 | +- **Hard limit**: 72 characters (gitlint enforced) |
| 98 | +- **Format**: `type(scope): description` counts toward limit |
| 99 | +- **Tips**: Use present tense, no period at end |
| 100 | +
|
| 101 | +```text |
| 102 | +# Good (45 chars) |
| 103 | +feat(SRVKP-123): add webhook controller |
| 104 | +
|
| 105 | +# Too long (78 chars) - will fail gitlint |
| 106 | +feat(SRVKP-123): add comprehensive webhook controller with GitHub integration |
| 107 | +```text |
| 108 | +
|
| 109 | +### Body |
| 110 | +
|
| 111 | +- **Wrap at 72 characters per line** |
| 112 | +- **Blank line** required between subject and body |
| 113 | +- **Content**: Explain why, not what (code shows what) |
| 114 | +- **Format**: Wrap manually or use heredoc in git commit |
| 115 | +
|
| 116 | +```text |
| 117 | +feat(SRVKP-123): add webhook controller |
| 118 | +
|
| 119 | +Configure webhook controller to handle GitHub events. This enables |
| 120 | +real-time pipeline triggering when push events occur, replacing the |
| 121 | +previous polling mechanism. |
| 122 | +
|
| 123 | +Signed-off-by: Developer Name <developer@redhat.com> |
| 124 | +Assisted-by: Claude-3.5-Sonnet (via Claude Code) |
| 125 | +```text |
| 126 | +
|
| 127 | +## Required Footers |
| 128 | +
|
| 129 | +### Signed-off-by |
| 130 | +
|
| 131 | +**Always include**: `Signed-off-by: <name> <email>` |
| 132 | +
|
| 133 | +**Detection priority order**: |
| 134 | +
|
| 135 | +1. Environment variables: `$GIT_AUTHOR_NAME` and `$GIT_AUTHOR_EMAIL` |
| 136 | +2. Git config: `git config user.name` and `git config user.email` |
| 137 | +3. If neither configured, ask user to provide details |
| 138 | +
|
| 139 | +**Common in dev containers**: Environment variables are preferred method |
| 140 | +
|
| 141 | +```bash |
| 142 | +# Check environment variables first |
| 143 | +echo "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" |
| 144 | +
|
| 145 | +# Fallback to git config |
| 146 | +git config user.name |
| 147 | +git config user.email |
| 148 | +```text |
| 149 | +
|
| 150 | +For complete detection logic, see `references/footer-detection.md`. |
| 151 | +
|
| 152 | +### Assisted-by |
| 153 | +
|
| 154 | +**Always include**: `Assisted-by: <model-name> (via Claude Code)` |
| 155 | +
|
| 156 | +**Format examples**: |
| 157 | +
|
| 158 | +```text |
| 159 | +Assisted-by: Claude-3.5-Sonnet (via Claude Code) |
| 160 | +Assisted-by: Claude Opus 4.5 (via Claude Code) |
| 161 | +Assisted-by: Claude Sonnet 4.5 (via Claude Code) |
| 162 | +```text |
| 163 | +
|
| 164 | +Use the actual model name (Claude Sonnet 4.5, Claude Opus 4.5, etc.). |
| 165 | +
|
| 166 | +## User Confirmation Requirement |
| 167 | +
|
| 168 | +**CRITICAL RULE**: Always ask for user confirmation before executing `git commit`. |
| 169 | +
|
| 170 | +### Confirmation Workflow |
| 171 | +
|
| 172 | +1. **Generate** the commit message following all rules above |
| 173 | +2. **Display** the complete message to the user with separator |
| 174 | +3. **Ask**: "Should I commit with this message? (y/n)" |
| 175 | +4. **Wait** for user response |
| 176 | +5. **Commit** only if user confirms (yes/y/affirmative) |
| 177 | +
|
| 178 | +### Example Interaction |
| 179 | +
|
| 180 | +```text |
| 181 | +Generated commit message: |
| 182 | +--- |
| 183 | +feat(SRVKP-456): ensure webhook logs output to stdout |
| 184 | +
|
| 185 | +Configure webhook controller to direct all logs to stdout for |
| 186 | +container compatibility. This resolves logging issues in Kubernetes |
| 187 | +environments where logs are collected from stdout. |
| 188 | +
|
| 189 | +Signed-off-by: Developer Name <developer@redhat.com> |
| 190 | +Assisted-by: Claude Sonnet 4.5 (via Claude Code) |
| 191 | +--- |
| 192 | +
|
| 193 | +Should I commit with this message? (y/n) |
| 194 | +```text |
| 195 | +
|
| 196 | +Wait for user response before proceeding. |
| 197 | +
|
| 198 | +## Commit Execution |
| 199 | +
|
| 200 | +Use heredoc format for proper multi-line handling: |
| 201 | +
|
| 202 | +```bash |
| 203 | +git commit -m "$(cat <<'EOF' |
| 204 | +feat(SRVKP-456): ensure webhook logs output to stdout |
| 205 | +
|
| 206 | +Configure webhook controller to direct all logs to stdout for |
| 207 | +container compatibility. |
| 208 | +
|
| 209 | +Signed-off-by: Developer Name <developer@redhat.com> |
| 210 | +Assisted-by: Claude Sonnet 4.5 (via Claude Code) |
| 211 | +EOF |
| 212 | +)" |
| 213 | +```text |
| 214 | +
|
| 215 | +**Never use**: |
| 216 | +
|
| 217 | +- `--no-verify` (skips pre-commit hooks) |
| 218 | +- `--no-gpg-sign` (skips signing) |
| 219 | +- `--amend` (unless explicitly requested and safe) |
| 220 | +
|
| 221 | +## Complete Examples |
| 222 | +
|
| 223 | +### Feature with Jira Scope |
| 224 | +
|
| 225 | +```text |
| 226 | +feat(SRVKP-789): add GitLab webhook integration |
| 227 | +
|
| 228 | +Implement webhook handler for GitLab push events. This enables |
| 229 | +pipeline triggering from GitLab repositories using the same |
| 230 | +architecture as GitHub integration. |
| 231 | +
|
| 232 | +Signed-off-by: Jane Developer <jane@redhat.com> |
| 233 | +Assisted-by: Claude Sonnet 4.5 (via Claude Code) |
| 234 | +```text |
| 235 | +
|
| 236 | +### Bug Fix with Component Scope |
| 237 | +
|
| 238 | +```text |
| 239 | +fix(controller): resolve concurrent pipeline runs |
| 240 | +
|
| 241 | +Update pipeline reconciliation logic to handle concurrent runs |
| 242 | +correctly. Previously, race condition could cause pipeline state |
| 243 | +corruption when multiple runs started simultaneously. |
| 244 | +
|
| 245 | +Signed-off-by: John Developer <john@redhat.com> |
| 246 | +Assisted-by: Claude Sonnet 4.5 (via Claude Code) |
| 247 | +```text |
| 248 | +
|
| 249 | +### Documentation Update |
| 250 | +
|
| 251 | +```text |
| 252 | +docs(README): update installation steps |
| 253 | +
|
| 254 | +Add section about pre-commit hooks and update Go version |
| 255 | +requirement to 1.20. |
| 256 | +
|
| 257 | +Signed-off-by: Jane Developer <jane@redhat.com> |
| 258 | +Assisted-by: Claude Sonnet 4.5 (via Claude Code) |
| 259 | +```text |
| 260 | +
|
| 261 | +### Breaking Change |
| 262 | +
|
| 263 | +```text |
| 264 | +feat(api)!: change webhook payload format |
| 265 | +
|
| 266 | +Update webhook payload to use standardized event schema. This is a |
| 267 | +breaking change requiring webhook consumers to update their |
| 268 | +parsers. |
| 269 | +
|
| 270 | +BREAKING CHANGE: Webhook payload structure changed from nested |
| 271 | +format to flat event schema. See migration guide in docs/. |
| 272 | +
|
| 273 | +Signed-off-by: John Developer <john@redhat.com> |
| 274 | +Assisted-by: Claude Sonnet 4.5 (via Claude Code) |
| 275 | +```text |
| 276 | +
|
| 277 | +## Jira Issue Lookup |
| 278 | +
|
| 279 | +When no Jira issue is found in branch name: |
| 280 | +
|
| 281 | +1. Ask user: "What Jira issue number should I use for this commit?" |
| 282 | +2. If provided, search issues.redhat.com for issue details |
| 283 | +3. Use issue summary and description to enhance commit message |
| 284 | +4. Suggest creating a new branch with Jira issue in name if desired |
| 285 | +
|
| 286 | +For complete Jira lookup workflow, see `references/jira-lookup.md`. |
| 287 | +
|
| 288 | +## Gitlint Integration |
| 289 | +
|
| 290 | +This project uses gitlint to enforce commit message format. Ensure all commit messages pass gitlint validation. |
| 291 | +
|
| 292 | +**Common gitlint rules**: |
| 293 | +
|
| 294 | +- Conventional commit format required |
| 295 | +- Subject line length limits (50 soft, 72 hard) |
| 296 | +- Required footers (Signed-off-by) |
| 297 | +- No trailing whitespace |
| 298 | +- Body line wrapping at 72 characters |
| 299 | +
|
| 300 | +For complete gitlint rules, see `references/gitlint-rules.md`. |
| 301 | +
|
| 302 | +## Auto-Detection Summary |
| 303 | +
|
| 304 | +When generating commit messages: |
| 305 | +
|
| 306 | +1. Run `git status` (without -uall flag) |
| 307 | +2. Run `git diff` for staged and unstaged changes |
| 308 | +3. Check current branch name for Jira issue pattern `[A-Z]{2,}-[0-9]+` |
| 309 | +4. If no Jira issue in branch, ask user for issue number |
| 310 | +5. Look up issue details on issues.redhat.com if provided |
| 311 | +6. Analyze staged files to determine commit type |
| 312 | +7. Generate appropriate scope and description |
| 313 | +8. Detect author info from environment variables or git config |
| 314 | +9. Ensure subject line is ≤50 characters (max 72) |
| 315 | +10. Wrap body text at 72 characters per line |
| 316 | +11. Add required footers (Signed-off-by and Assisted-by) |
| 317 | +12. Format according to conventional commits standard |
| 318 | +13. **Display message and ask for user confirmation** |
| 319 | +14. Only commit after receiving confirmation |
| 320 | +
|
| 321 | +## Additional Resources |
| 322 | +
|
| 323 | +For detailed information: |
| 324 | +
|
| 325 | +- **`references/commit-types.md`** - Complete commit type reference with descriptions |
| 326 | +- **`references/jira-lookup.md`** - Jira issue lookup workflow and integration |
| 327 | +- **`references/gitlint-rules.md`** - Gitlint validation rules and configuration |
| 328 | +- **`references/footer-detection.md`** - Author detection logic and priority order |
0 commit comments