Skip to content

/commit

Smart commit creation with auto-generated messages that follow the Conventional Commits standard.

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).

Terminal window
/commit [optional hint]
ArgumentDescriptionExample
[hint]Optional hint for message focusauth, bugfix, refactor

The hint helps guide the message generation but isn’t required.

The command first examines your repository state:

Terminal window
git status
git diff --staged
git log --oneline -5

This provides context about:

  • What files are staged
  • What changes were made
  • Recent commit history

Automatically determines the commit type:

TypeUsed For
featNew features
fixBug fixes
docsDocumentation only
styleFormatting, whitespace
refactorCode restructuring without behavior change
testAdding or updating tests
choreMaintenance (deps, config, etc.)

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

Executes the commit with the generated message:

Terminal window
git commit -m "$(cat <<'EOF'
type(scope): subject
- Change 1
- Change 2
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"

Staged changes: New authentication files

Terminal window
/commit auth

Generated 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>

Staged changes: Fix in profile endpoint

Terminal window
/commit

Generated 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>

Staged changes: Database code reorganization

Terminal window
/commit refactor

Generated commit:

refactor(database): extract query builders
Split large database service into focused modules
for better maintainability and testing.
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>

Staged changes: README updates

Terminal window
/commit docs

Generated 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>

Staged changes: New test files

Terminal window
/commit test

Generated 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>

Staged changes: Package updates

Terminal window
/commit

Generated 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>
  • 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
  • Wrap at 72 characters for readability
  • Explain what and why, not how
  • Use bullet points for multiple changes
  • Reference issues when applicable

Good:

feat(auth): add OAuth2 support
- Implement Google and GitHub providers
- Add token refresh mechanism
- Update user model for OAuth data
Closes #123

Bad:

Added oauth stuff
I added oauth because we need it. It works now.

After creating the commit, you’ll see:

## Commit Created
**Hash**: `abc1234`
**Branch**: `feature/auth-improvements`
### Message

feat(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 remote
git push -u origin feature/auth-improvements
# Create PR
gh 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 amend
git add -A
git commit --amend --no-edit
FlagDescriptionExample
--mode=[mode]Behavioral mode/commit --mode=token-efficient
--format=[fmt]Output format/commit --format=concise
--no-verifySkip pre-commit hooks/commit --no-verify
  • /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:

Terminal window
git commit --amend

Customize 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