mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-11-04 07:03:10 +08:00
git-subtree-dir: apps/kilocode-docs git-subtree-mainline:0ab8794512git-subtree-split:79ed21f191
146 lines
4.8 KiB
Markdown
146 lines
4.8 KiB
Markdown
# Generate Commit Messages
|
|
|
|
Generate descriptive commit messages automatically based on your staged git changes. Kilo Code analyzes your staged files and creates conventional commit messages that follow best practices.
|
|
|
|
:::info
|
|
This feature only analyzes **staged changes**. Make sure to stage your files using `git add` or via `VS Code` interface before generating commit messages.
|
|
:::
|
|
|
|
## How It Works
|
|
|
|
The git commit message generator:
|
|
- Analyzes only your **staged changes** (not unstaged or untracked files)
|
|
- Uses AI to understand the context and purpose of your changes
|
|
- Creates descriptive commit messages that explain what was changed and why following the [Conventional Commits](https://www.conventionalcommits.org/) (by default, customizable)
|
|
|
|
## Using the Feature
|
|
|
|
### Generating a Commit Message
|
|
|
|
1. Stage your changes using `git add` or the VS Code git interface
|
|
2. In the VS Code Source Control panel, look for the `Kilo Code` logo next to the commit message field)
|
|
3. Click the logo to generate a commit message
|
|
|
|
|
|
The generated message will appear in the commit message field, ready for you to review and modify if needed.
|
|
|
|
<img src="/docs/img/git-commit-generation/git-commit-1.png" alt="Generated commit message example" width="600" />
|
|
|
|
### Conventional Commit Format
|
|
|
|
By default, generated messages follow the Conventional Commits specification:
|
|
|
|
```
|
|
<type>(<scope>): <description>
|
|
|
|
<body>
|
|
```
|
|
|
|
Common types include:
|
|
- `feat`: New features
|
|
- `fix`: Bug fixes
|
|
- `docs`: Documentation changes
|
|
- `style`: Code style changes (formatting, etc.)
|
|
- `refactor`: Code refactoring
|
|
- `test`: Adding or updating tests
|
|
- `chore`: Maintenance tasks
|
|
|
|
## Configuration
|
|
|
|
### Customizing the Commit Template
|
|
|
|
You can customize how commit messages are generated by modifying the prompt template:
|
|
|
|
1. Open Settings by clicking the gear icon <Codicon name="gear" /> → `Prompts`
|
|
2. Find the "Commit Message Generation" section
|
|
3. Edit the `Prompt` template to match your project's conventions
|
|
|
|
<img src="/docs/img/git-commit-generation/git-commit-2.png" alt="Commit message generation settings" width="600" />
|
|
|
|
The default template creates conventional commit messages, but you can modify it to:
|
|
- Use different commit message formats
|
|
- Include specific information relevant to your project
|
|
- Follow your team's commit message conventions
|
|
- Add custom instructions for the AI
|
|
|
|
### API Configuration
|
|
|
|
You can configure which API profile to use for commit message generation:
|
|
|
|
1. In the `Prompts` settings, scroll to "API Configuration"
|
|
2. Select a specific profile or use the currently selected one
|
|
|
|
:::tip
|
|
Consider creating a dedicated [API configuration profile](/features/api-configuration-profiles) with a faster, more cost-effective model specifically for commit message generation.
|
|
:::
|
|
|
|
## Best Practices
|
|
|
|
### Staging Strategy
|
|
- Stage related changes together for more coherent commit messages
|
|
- Avoid staging unrelated changes in a single commit
|
|
- Use `git add -p` for partial file staging when needed
|
|
|
|
### Message Review
|
|
- Always review generated messages before committing
|
|
- Edit messages to add context the AI might have missed
|
|
- Ensure the message accurately describes the changes
|
|
|
|
### Custom Templates
|
|
- Tailor the prompt template to your project's needs
|
|
- Include project-specific terminology or conventions
|
|
- Add instructions for handling specific types of changes
|
|
|
|
## Example Generated Messages
|
|
|
|
Here are examples of messages the feature might generate:
|
|
|
|
```
|
|
feat(auth): add OAuth2 integration with Google
|
|
|
|
Implement Google OAuth2 authentication flow including:
|
|
- OAuth2 client configuration
|
|
- User profile retrieval
|
|
- Token refresh mechanism
|
|
```
|
|
|
|
```
|
|
fix(api): resolve race condition in user data fetching
|
|
|
|
Add proper error handling and retry logic to prevent
|
|
concurrent requests from causing data inconsistency
|
|
```
|
|
|
|
```
|
|
docs(readme): update installation instructions
|
|
|
|
Add missing dependency requirements and clarify
|
|
setup steps for new contributors
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### No Staged Changes
|
|
If the button doesn't appear or generation fails, ensure you have staged changes:
|
|
```bash
|
|
git add <files>
|
|
# or stage all changes
|
|
git add .
|
|
```
|
|
|
|
### Poor Message Quality
|
|
If generated messages aren't helpful:
|
|
- Review your staging strategy - don't stage unrelated changes together
|
|
- Customize the prompt template with more specific instructions
|
|
- Try a different AI model through API configuration
|
|
|
|
### Integration Issues
|
|
The feature integrates with VS Code's built-in git functionality. If you encounter issues:
|
|
- Ensure your repository is properly initialized
|
|
- Check that VS Code can access your git repository
|
|
- Verify git is installed and accessible from VS Code
|
|
|
|
## Related Features
|
|
|
|
- [API Configuration Profiles](/features/api-configuration-profiles) - Use different models for commit generation
|
|
- [Settings Management](/features/settings-management) - Manage all your Kilo Code preferences |