grokkit/docs/user-guide/commit.md

59 lines
2.0 KiB
Markdown
Raw Permalink Normal View History

# ✅ Commit Guide
Grokkit provides two commands to help you generate high-quality, conventional commit messages from your staged changes: `commit-msg` and `commit`.
### Commit-msg
The `commit-msg` command generates a conventional commit message based on your currently staged changes (`git add`). It's perfect for when you want to review the message before using it in your commit.
#### Usage
```bash
git add .
grokkit commit-msg
```
**Output Example:**
```text
feat(git): add support for custom commit message templates
Implemented a new system for defining custom templates for commit messages, allowing for project-specific conventions.
```
### Commit
The `commit` command generates a commit message and commits in one step.
#### Usage
```bash
git add .
grokkit commit # Generate + confirm + commit
```
**Interactive Workflow:**
1. Grokkit analyzes your staged changes.
2. It generates a conventional commit message.
3. It shows you the proposed message.
4. It asks for confirmation: `Commit with this message? (y/n): `.
5. If you confirm, it runs `git commit -m "<message>"`.
### Why use AI for Commits?
- **Conventional Format**: Automatically follows the `type(scope): subject` format.
- **Accurate Descriptions**: Grok analyzes the actual diff to provide a meaningful summary of your changes.
- **Consistency**: Ensures that all commit messages in your project follow the same high standard.
- **Save Time**: No more staring at a blank screen trying to remember everything you changed.
### Options
| Flag | Description |
|------|-------------|
| `--model`, `-m` | Override the default model (e.g., `grok-4`) |
### Best Practices
- **Stage only relevant changes**: For the best commit message, only stage the changes that belong in a single commit.
- **Review before committing**: Always read the generated message to ensure it accurately reflects your intent.
- **Model selection**: For complex changes, use a more powerful model like `grok-4` to get a better summary.