Skip to content

Commit 2b3e517

Browse files
committed
docs: Added Conventional Commits specifications to the commit command.
- Introduced a type system based on the Conventional Commits v1.0.0 specification (feat/fix/docs/chore, etc.) - Added guidance on when to use each type and SemVer impact. - Clarified the criteria for distinguishing between fix and chore (user impact vs. developer impact). - Added a method for handling breaking changes. - Added Claude execution instructions and token optimization guide.
1 parent 05052a3 commit 2b3e517

File tree

1 file changed

+149
-54
lines changed

1 file changed

+149
-54
lines changed

.claude/commands/commit.md

Lines changed: 149 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
2-
allowed-tools: Bash(git status:*), Bash(git diff:*), Bash(git log:*), Bash(git branch:*)
3-
description: Generate concise commit messages in both Korean and English - you choose one to use
2+
allowed-tools: Bash(git status:*), Bash(git diff:*), Bash(git log:*), Bash(git branch:*), Write
3+
description: Generate Conventional Commits-compliant messages (feat/fix/docs/chore) in Korean and English
44
---
55

6-
# Smart Git Commit Message Generator
6+
# Conventional Commits Message Generator
77

8-
Generate commit messages in both Korean and English. **You will choose one version to use for your commit.**
8+
Generates commit messages following [Conventional Commits v1.0.0](https://www.conventionalcommits.org/) specification in both Korean and English. **Choose one version for your commit.**
99

10-
## Current Repository State
10+
## Repository State Analysis
1111

1212
- Git status: !git status --porcelain
1313
- Current branch: !git branch --show-current
@@ -20,84 +20,119 @@ Generate commit messages in both Korean and English. **You will choose one versi
2020
1. Checks current branch name to detect issue number (e.g., develop/shlee/32 → #32)
2121
2. Checks which files are staged with git status
2222
3. Performs a git diff to understand what changes will be committed
23-
4. Generates concise commit messages in both Korean and English
23+
4. Generates commit messages in Conventional Commits format in both Korean and English
2424
5. Adds "fix #N" at the end if branch name ends with a number
2525
6. **Saves to commit_message.md file for easy copying**
2626

27-
## Commit Message Format Guidelines
27+
## Conventional Commits Format (REQUIRED)
2828

29-
**Core Principle: Focus on what problem was solved rather than what was done**
29+
```
30+
<type>[(optional scope)]: <description>
3031
31-
**Title Writing Principle: Prioritize user-facing problems**
32+
[optional body]
3233
33-
- ❌ "Fix empty login form submission error" (code perspective)
34-
- ✅ "Fix login button not responding to clicks" (user perspective)
35-
- ❌ "Handle null pointer exception" (technical perspective)
36-
- ✅ "Fix app crash when accessing profile page" (user perspective)
34+
[optional footer: fix #N]
35+
```
3736

38-
Keep it simple and concise. Use appropriate format based on complexity:
37+
### Available Types
3938

40-
### Very Simple Changes
39+
Analyze staged changes and suggest the most appropriate type:
40+
41+
| Type | When to Use | SemVer Impact |
42+
|------|-------------|---------------|
43+
| **feat** | New feature or capability added | MINOR (0.x.0) |
44+
| **fix** | Bug fix or problem resolution | PATCH (0.0.x) |
45+
| **docs** | Documentation only changes (README, comments, etc.) | None |
46+
| **style** | Code formatting, missing semicolons (no logic change) | None |
47+
| **refactor** | Code restructuring without changing behavior | None |
48+
| **perf** | Performance improvements | PATCH |
49+
| **test** | Adding or fixing tests | None |
50+
| **chore** | Build config, dependencies, tooling updates | None |
51+
| **ci** | CI/CD configuration changes | None |
4152

53+
**BREAKING CHANGE**: MUST use both type! format (exclamation mark after type) AND BREAKING CHANGE: footer with migration guide for major version bump.
54+
55+
Example:
4256
```
43-
[Problem description] Title
57+
feat!: change API response format from JSON to MessagePack
58+
59+
Migrated response format to MessagePack binary for 40% packet size reduction.
60+
61+
BREAKING CHANGE: Client code update required
62+
- Install MessagePack library: npm install msgpack5
63+
- Update response parsing: response.json() → msgpack.decode(response.body)
64+
- Update type definitions: API_RESPONSE_FORMAT constant changed
4465
```
4566

46-
### Simple Changes
67+
### Type Selection Decision Tree
68+
69+
Analyze git diff output and suggest type based on file patterns:
4770

4871
```
49-
[Problem description] Title
72+
Changed Files → Suggested Type
5073
51-
What problem occurred and how it was resolved in one or two lines
74+
src/**/*.{ts,js,tsx,jsx} + new functions/classes → feat
75+
src/**/*.{ts,js,tsx,jsx} + bug fix → fix
76+
README.md, docs/**, *.md → docs
77+
package.json, pnpm-lock.yaml, .github/** → chore
78+
**/*.test.{ts,js}, **/*.spec.{ts,js} → test
79+
.github/workflows/** → ci
5280
```
5381

54-
### Standard Changes
82+
If multiple types apply, prioritize: `feat` > `fix` > other types.
5583

56-
```
57-
[Problem description] Title
84+
### Confusing Cases: fix vs chore
5885

59-
Description of the problem that occurred
60-
(Brief reproduction steps if applicable)
86+
**Key distinction**: Does it affect **users** or only **developers**?
6187

62-
How it was solved and the reasoning behind the solution
63-
```
88+
| Scenario | Type | Reason |
89+
|----------|------|--------|
90+
| Backend GitHub Actions test workflow not running | `chore` | Only affects CI/CD, users don't experience this |
91+
| API returns 500 error for valid requests | `fix` | Users experience error responses |
92+
| Page loading speed improved from 3s to 0.8s | `perf` | Users directly feel the improvement |
93+
| Internal database query optimization (no user impact) | `refactor` | Code improvement, no measurable user benefit |
94+
| Dependency security patch (CVE fix) | `chore` | Build/tooling update |
95+
| App crashes when accessing profile page | `fix` | Users experience crash |
6496

65-
### Complex Changes (rarely needed)
97+
**User perspective priority:**
98+
- ✅ "fix: app crashes when deleting items" (user problem)
99+
- ❌ "fix: null pointer exception in ItemService" (code problem)
66100

67-
```
68-
[Problem description] Title
101+
## Commit Message Format Guidelines
69102

70-
Problem:
71-
- Specific problem description
72-
- Reproduction steps (brief if available)
103+
**Core Principle: Focus on what problem was solved rather than what was done**
73104

74-
Solution:
75-
- Approach taken and why that method was chosen
76-
- Additional solutions applied and their rationale
77-
```
105+
**Title Writing Principle: Prioritize user-facing problems**
78106

79-
**Important formatting rules:**
107+
- ❌ "Fix empty login form submission error" (code perspective)
108+
- ✅ "Fix login button not responding to clicks" (user perspective)
109+
- ❌ "Handle null pointer exception" (technical perspective)
110+
- ✅ "Fix app crash when accessing profile page" (user perspective)
80111

81-
- First line (title): Clearly express the user-facing problem
82-
- Prefer user perspective > code/technical perspective when possible
83-
- Except for very simple cases, don't just list changes - explain with sentences
84-
- Include reasoning and justification when explaining solutions
85-
- Keep descriptions concise - avoid verbose explanations
86-
- If branch name ends with number (e.g., develop/32, develop/shlee/32), add "fix #N" at the end
87-
- **When multiple changes/reasons exist, use bullet points (-) for better readability**
112+
Keep it simple and concise. Use appropriate format based on complexity:
88113

89-
## Examples
114+
### Very Simple Changes
90115

91-
### Very Simple
116+
```
117+
type: brief description
118+
```
92119

120+
**Example:**
93121
```
94-
Fix typo in README
122+
docs: fix typo in README
95123
```
96124

97-
### Simple
125+
### Simple Changes
126+
127+
```
128+
type: problem description
129+
130+
What problem occurred and how it was resolved in one or two lines
131+
```
98132

133+
**Example:**
99134
```
100-
Fix login button not responding with empty fields
135+
fix: login button not responding with empty fields
101136
102137
Login attempts with empty input fields showed no response
103138
Added client-side validation and error message display
@@ -106,16 +141,28 @@ Added client-side validation and error message display
106141
**For multiple changes/reasons, use list format:**
107142

108143
```
109-
Backend architect agent role redefinition
144+
refactor: backend architect agent role redefinition
110145
111146
- Changed focus from API design to system structure design
112147
- Modified to concentrate on domain modeling, layered architecture, and modularization strategy
113148
```
114149

115-
### Standard
150+
### Standard Changes
151+
152+
```
153+
type: problem description
154+
155+
Description of the problem that occurred
156+
(Brief reproduction steps if applicable)
157+
158+
How it was solved and the reasoning behind the solution
159+
160+
fix #N
161+
```
116162

163+
**Example:**
117164
```
118-
Fix user list page failing to load
165+
fix: user list page failing to load
119166
120167
User list page showed continuous loading spinner with 1000+ users
121168
(Reproduction: User List > View All click)
@@ -126,10 +173,25 @@ response time from 30+ seconds to under 2 seconds
126173
fix #32
127174
```
128175

129-
### Complex (rare)
176+
### Complex Changes (rarely needed)
177+
178+
```
179+
type: problem description
180+
181+
Problem:
182+
- Specific problem description
183+
- Reproduction steps (brief if available)
184+
185+
Solution:
186+
- Approach taken and why that method was chosen
187+
- Additional solutions applied and their rationale
130188
189+
fix #N
131190
```
132-
Fix users being logged out after service updates
191+
192+
**Example:**
193+
```
194+
fix: users being logged out after service updates
133195
134196
Problem:
135197
- All users forced to log out with each new deployment
@@ -140,6 +202,17 @@ Solution:
140202
- Implemented JWT refresh tokens for automatic re-authentication to provide seamless service
141203
```
142204

205+
**Important formatting rules:**
206+
207+
- First line (title): `type: clearly express the user-facing problem`
208+
- description must start with lowercase, no period at end, use imperative mood
209+
- Prefer user perspective > code/technical perspective when possible
210+
- Except for very simple cases, don't just list changes - explain with sentences
211+
- Include reasoning and justification when explaining solutions
212+
- Keep descriptions concise - avoid verbose explanations
213+
- If branch name ends with number (e.g., develop/32, develop/shlee/32), add "fix #N" at the end
214+
- **When multiple changes/reasons exist, use bullet points (-) for better readability**
215+
143216
## Output Format
144217

145218
The command will provide:
@@ -157,3 +230,25 @@ The command will provide:
157230
- Keep messages concise - don't over-explain what's obvious from the code
158231
- Branch issue numbers (e.g., develop/32) will automatically append "fix #N"
159232
- Copy message from generated file and manually execute `git commit`
233+
- **Spec compliance**: All messages MUST follow Conventional Commits format
234+
- **Type is mandatory**: No type = invalid commit for semantic-release
235+
- **Case sensitivity**: Types must be lowercase (except `BREAKING CHANGE`)
236+
237+
## Execution Instructions for Claude
238+
239+
1. Run git commands to understand changes (staged or all if none staged)
240+
2. Analyze file patterns and suggest appropriate commit type
241+
3. Determine if scope is needed (e.g., `fix(api):`, `feat(ui):`)
242+
4. Draft commit message following format:
243+
- Title: `<type>[(scope)]: <user-facing description>`
244+
- Body: Choose appropriate format based on complexity (very simple/simple/standard/complex)
245+
- Footer: Auto-add `fix #N` if branch name ends with number
246+
5. Generate both Korean and English versions
247+
6. Write to `/workspaces/ai-config-toolkit/commit_message.md`
248+
7. Present suggested type with reasoning
249+
250+
**Token optimization**: Focus git diff analysis on:
251+
- New/deleted files → likely `feat` or `refactor`
252+
- Modified files in src/ → check if bug fix or feature
253+
- Modified docs/README → `docs`
254+
- Modified package.json → `chore`

0 commit comments

Comments
 (0)