Skip to content

Commit 21ce26d

Browse files
committed
🔧 chore: add commit slash command for Claude Code
Custom slash command that creates well-formatted commits with conventional commit messages and emoji prefixes.
1 parent d214787 commit 21ce26d

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

.claude/commands/commit.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Claude Command: Commit
2+
3+
This command helps you create well-formatted commits with conventional commit messages and emoji.
4+
5+
## Usage
6+
7+
To create a commit, just type:
8+
```
9+
/commit
10+
```
11+
12+
## What This Command Does
13+
14+
1. Checks which files are staged with `git status`
15+
2. If no files are staged, automatically adds all modified and new files with `git add`
16+
3. Performs a `git diff` to understand what changes are being committed
17+
4. Analyzes the diff to determine if multiple distinct logical changes are present
18+
5. If multiple distinct changes are detected, suggests breaking the commit into multiple smaller commits
19+
6. For each commit (or the single commit if not split), creates a commit message using emoji conventional commit format
20+
21+
## Best Practices for Commits
22+
23+
- **Atomic commits**: Each commit should contain related changes that serve a single purpose
24+
- **Split large changes**: If changes touch multiple concerns, split them into separate commits
25+
- **Conventional commit format**: Use the format `emoji <type>: <description>`
26+
- **Present tense, imperative mood**: Write commit messages as commands (e.g., "add feature" not "added feature")
27+
- **Concise first line**: Keep the first line under 72 characters
28+
- **No Claude attribution**: NEVER mention Claude or Claude Code in commit messages
29+
30+
## Commit Types and Emojis
31+
32+
Use ONE emoji per commit based on the primary type of change:
33+
34+
-`feat`: New feature or functionality
35+
- 🐛 `fix`: Bug fix (non-critical)
36+
- 🚑️ `fix`: Critical hotfix
37+
- 📝 `docs`: Documentation changes
38+
- 🎨 `style`: Code structure/formatting improvements
39+
- ♻️ `refactor`: Code refactoring (no behavior change)
40+
- 🚚 `refactor`: Move or rename files/resources
41+
- ⚡️ `perf`: Performance improvements
42+
-`test`: Add or update tests
43+
- 🔧 `chore`: Configuration, tooling, maintenance
44+
- 🔥 `chore`: Remove code or files
45+
- 📦️ `chore`: Update dependencies or packages
46+
-`chore`: Add a dependency
47+
-`chore`: Remove a dependency
48+
- 🚀 `ci`: CI/CD changes
49+
- 💚 `fix`: Fix CI build
50+
- 🔒️ `fix`: Security fixes
51+
- ♿️ `feat`: Accessibility improvements
52+
- 🗃️ `chore`: Database migrations or schema changes
53+
- 🌐 `feat`: Internationalization/localization changes
54+
55+
## Guidelines for Splitting Commits
56+
57+
When analyzing the diff, consider splitting commits based on these criteria:
58+
59+
1. **Different concerns**: Changes to unrelated parts of the codebase
60+
2. **Different types of changes**: Mixing features, fixes, refactoring, etc.
61+
3. **File patterns**: Changes to different types of files (e.g., source code vs documentation)
62+
4. **Logical grouping**: Changes that would be easier to understand or review separately
63+
5. **Size**: Very large changes that would be clearer if broken down
64+
65+
## Examples
66+
67+
**Good commit messages for this Django/Wagtail project:**
68+
- ✨ feat: add speaker bio field to Speaker model
69+
- ✨ feat: implement new StreamField block for video embeds
70+
- 🐛 fix: correct sponsor logo display on homepage
71+
- 🐛 fix: resolve meetup sync timezone issue
72+
- 📝 docs: update CLAUDE.md with new task commands
73+
- ♻️ refactor: simplify SpeakersPage queryset logic
74+
- ♻️ refactor: extract common page mixins to core app
75+
- 🎨 style: improve Wagtail admin panel layout
76+
- 🔥 chore: remove deprecated Meetup API v2 code
77+
- 📦️ chore: update Wagtail to 6.2.x
78+
- 📦️ chore: upgrade Django to 5.0.14
79+
- ➕ chore: add django-extensions for development
80+
- ➖ chore: remove unused celery dependency
81+
- 🚀 ci: update Heroku deployment configuration
82+
- 💚 fix: resolve failing Docker build
83+
- 🔒️ fix: patch Django security vulnerability
84+
- ♿️ feat: improve navigation accessibility for screen readers
85+
- 🗃️ chore: add migration for new Session fields
86+
- 🌐 feat: add French translation for sponsor pages
87+
88+
**Example of splitting commits:**
89+
90+
If you modify both a Wagtail page model AND update a management command, split into:
91+
1. ✨ feat: add session_type field to Session model
92+
2. ♻️ refactor: update import-sessionize command to handle new field
93+
94+
If you fix multiple unrelated issues, split into:
95+
1. 🐛 fix: correct speaker ordering on TalksPage
96+
2. 🐛 fix: resolve Redis connection timeout in dev settings
97+
3. 🗃️ chore: add missing migration for sponsors app
98+
99+
## Important Notes
100+
101+
- If specific files are already staged, the command will only commit those files
102+
- If no files are staged, it will automatically stage all modified and new files
103+
- The commit message will be constructed based on the changes detected
104+
- Before committing, the command will review the diff to identify if multiple commits would be more appropriate
105+
- If suggesting multiple commits, it will help you stage and commit the changes separately
106+
- **CRITICAL**: Never add "Generated with Claude Code" or similar attributions to commits

0 commit comments

Comments
 (0)