/commit
/commit
Section titled “/commit”Smart commit creation with auto-generated messages that follow the Conventional Commits standard.
Purpose
Section titled “Purpose”Creates well-structured commits by:
- Analyzing your staged changes
- Auto-generating descriptive commit messages
- Following Conventional Commits format
- Adding helpful metadata and co-author attribution
Perfect for when you want to commit without creating a PR (use /ship for the full workflow).
/commit [optional hint]Arguments
Section titled “Arguments”| Argument | Description | Example |
|---|---|---|
[hint] | Optional hint for message focus | auth, bugfix, refactor |
The hint helps guide the message generation but isn’t required.
Workflow
Section titled “Workflow”Step 1: Analyze Changes
Section titled “Step 1: Analyze Changes”The command first examines your repository state:
git statusgit diff --stagedgit log --oneline -5This provides context about:
- What files are staged
- What changes were made
- Recent commit history
Step 2: Categorize Changes
Section titled “Step 2: Categorize Changes”Automatically determines the commit type:
| Type | Used For |
|---|---|
feat | New features |
fix | Bug fixes |
docs | Documentation only |
style | Formatting, whitespace |
refactor | Code restructuring without behavior change |
test | Adding or updating tests |
chore | Maintenance (deps, config, etc.) |
Step 3: Generate Message
Section titled “Step 3: Generate Message”Creates a message following this format:
type(scope): subject
body (optional)
footer (optional)Components:
- Type: From categorization above
- Scope: Affected area (auth, api, ui, etc.)
- Subject: Concise description (max 50 chars)
- Body: Detailed explanation with bullet points
- Footer: Issue references, breaking changes
Step 4: Create Commit
Section titled “Step 4: Create Commit”Executes the commit with the generated message:
git commit -m "$(cat <<'EOF'type(scope): subject
- Change 1- Change 2
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>EOF)"Examples
Section titled “Examples”Feature Commit
Section titled “Feature Commit”Staged changes: New authentication files
/commit authGenerated commit:
feat(auth): add password reset functionality
- Add reset token generation- Implement email sending- Add rate limiting for reset requests
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>Bug Fix Commit
Section titled “Bug Fix Commit”Staged changes: Fix in profile endpoint
/commitGenerated commit:
fix(api): handle null user in profile endpoint
The profile endpoint crashed when accessing deleted users.Added null check and proper 404 response.
Fixes #456
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>Refactor Commit
Section titled “Refactor Commit”Staged changes: Database code reorganization
/commit refactorGenerated commit:
refactor(database): extract query builders
Split large database service into focused modulesfor better maintainability and testing.
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>Documentation Commit
Section titled “Documentation Commit”Staged changes: README updates
/commit docsGenerated commit:
docs(readme): update installation instructions
- Add prerequisites section- Update configuration examples- Fix broken links
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>Test Commit
Section titled “Test Commit”Staged changes: New test files
/commit testGenerated commit:
test(auth): add missing login tests
- Add test for invalid credentials- Add test for locked account- Add test for expired session
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>Chore Commit
Section titled “Chore Commit”Staged changes: Package updates
/commitGenerated commit:
chore(deps): update dependencies
- Update React to 18.2- Update TypeScript to 5.3- Remove unused packages
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>Commit Message Guidelines
Section titled “Commit Message Guidelines”Subject Line Rules
Section titled “Subject Line Rules”- Max 50 characters - Keep it concise
- Imperative mood - “Add” not “Added” or “Adds”
- No period at the end
- Capitalize the first letter
- Be specific - Describe what changed, not why
Body Guidelines
Section titled “Body Guidelines”- Wrap at 72 characters for readability
- Explain what and why, not how
- Use bullet points for multiple changes
- Reference issues when applicable
Good vs Bad Examples
Section titled “Good vs Bad Examples”Good:
feat(auth): add OAuth2 support
- Implement Google and GitHub providers- Add token refresh mechanism- Update user model for OAuth data
Closes #123Bad:
Added oauth stuff
I added oauth because we need it. It works now.Output
Section titled “Output”After creating the commit, you’ll see:
## Commit Created
**Hash**: `abc1234`**Branch**: `feature/auth-improvements`
### Messagefeat(auth): add OAuth2 login support
- Implement Google OAuth provider
- Implement GitHub OAuth provider
- Add session token generation
- Update user model for OAuth data
Closes #789
### Files Changed| Status | File ||--------|------|| M | src/auth/providers.ts || A | src/auth/oauth/google.ts || A | src/auth/oauth/github.ts || M | src/models/user.ts || A | tests/auth/oauth.test.ts |
### Stats- 5 files changed- 234 insertions(+)- 12 deletions(-)
### Next Steps```bash# Push to remotegit push -u origin feature/auth-improvements
# Create PRgh pr create## Pre-Commit Checks
Before committing, the command validates:
- [ ] No secrets in staged files- [ ] No debug statements (`console.log`, `debugger`, `print`)- [ ] No unintentional TODO comments- [ ] Code is properly formatted
If issues are found, you'll be prompted to fix them first.
## Amending Commits
If pre-commit hooks modify files automatically (like formatters), the command handles it:
```bash# Stage modified files and amendgit add -Agit commit --amend --no-edit| Flag | Description | Example |
|---|---|---|
--mode=[mode] | Behavioral mode | /commit --mode=token-efficient |
--format=[fmt] | Output format | /commit --format=concise |
--no-verify | Skip pre-commit hooks | /commit --no-verify |
Related Commands
Section titled “Related Commands”- /ship - Full workflow with commit + PR
- /pr - Create PR from commits
- /changelog - Generate changelog from commits
Use descriptive hints: While optional, hints like auth, api, or ui help generate more accurate messages.
Review before committing: The command shows you the message before creating the commit, so you can verify it’s accurate.
Amend if needed: If the generated message isn’t quite right, you can amend it:
git commit --amendCustomize format: Modify commit message format in CLAUDE.md under “Git Conventions”.
Breaking changes: For breaking changes, the footer will include:
BREAKING CHANGE: describe the breaking change