Loading...
Intelligently analyzes changes and creates well-formatted git commits with conventional commit messages
---
allowed-tools: Bash(git add:*), Bash(git status:*), Bash(git diff:*), Bash(git commit:*)
argument-hint: [type] [message]
description: Create a smart git commit
model: claude-3-5-sonnet-20241022
---
## Context
- Current git status: !`git status --short`
- Staged changes: !`git diff --cached --stat`
- Unstaged changes: !`git diff --stat`
- Recent commits: !`git log --oneline -5`
## Your Task
Analyze the changes and create a git commit following these guidelines:
1. **Conventional Commit Format**:
- feat: New feature
- fix: Bug fix
- docs: Documentation changes
- style: Code style changes (formatting, etc)
- refactor: Code refactoring
- perf: Performance improvements
- test: Test changes
- build: Build system changes
- ci: CI/CD changes
- chore: Other changes
2. **Commit Message Structure**:
```
<type>(<scope>): <subject>
<body>
<footer>
```
3. **Best Practices**:
- Subject line: 50 characters max
- Use imperative mood ("Add" not "Added")
- Body: Wrap at 72 characters
- Explain what and why, not how
- Reference issues if applicable
4. **Smart Analysis**:
- Group related changes
- Suggest splitting if changes are unrelated
- Detect breaking changes
- Identify files that shouldn't be committed
If arguments provided: Use $1 as type and $2 as message.
Otherwise: Analyze changes and suggest appropriate commit.
## Steps
1. Review all changes
2. Identify the commit type
3. Stage appropriate files
4. Create descriptive commit message
5. Commit the changes.claude/commands/git-smart-commit.md~/.claude/commands/git-smart-commit.mdCommand stages unwanted files like .env or credentials.json
Add sensitive files to .gitignore immediately: echo '.env' >> .gitignore. Use git reset HEAD <file> to unstage. Configure global ignore: git config --global core.excludesfile ~/.gitignore_global
Conventional commit message exceeds 50 character limit
Use scope to shorten subject: feat(auth): add OAuth instead of feat: add OAuth authentication system. Put details in body. Run: git commit --amend to rewrite if already committed.
Command fails with 'nothing to commit, working tree clean'
Verify changes exist: git status. Check if files are tracked: git ls-files. Stage new files: git add <file>. For ignored files: git add -f <file> or update .gitignore.
Breaking change not properly indicated in commit message
Add BREAKING CHANGE: footer or ! after type: feat(api)!: remove legacy endpoint. Use git commit --amend to fix recent commit. Format: type(scope)!: subject\n\nBREAKING CHANGE: description
Multiple unrelated changes need separate commits
Stage files selectively: git add src/auth.ts && git commit -m 'feat: add auth'. Then: git add src/logging.ts && git commit -m 'feat: add logging'. Use git add -p for partial staging.
Loading reviews...
Join our community of Claude power users. No spam, unsubscribe anytime.
Orchestrate multi-agent workflows using Microsoft AutoGen v0.4 with role-based task delegation, conversation patterns, and collaborative problem solving
Generate .cursorrules files for AI-native development with project-specific patterns, coding standards, and intelligent context awareness
Advanced debugging assistant with root cause analysis, step-by-step troubleshooting, and automated fix suggestions