commit command generates intelligent commit messages by analyzing your staged changes using AI.
Usage
Options
Preview the commit message without committing.
Maximum git diff size in bytes (minimum: 5000). Limits the size of the git diff sent to the AI model. Large diffs are truncated to save tokens and reduce API costs.
Additional text to customize the commit message. Provide additional context or instructions for the AI to use when generating the commit message. Multiple words can be provided without quotes.
Examples
Generate and Commit
Generate a commit message and commit changes:Preview Without Committing
Generate a commit message without committing:Provide Context
Add context to customize the message:With Custom Text
Limit Diff Size
For large changes, limit the diff size:Piped Input
You can pipe a git diff directly:Workflow Examples
Standard Workflow
- Make your changes
- Stage changes:
- Preview commit message:
- Commit if satisfied:
Quick Commit
Preview and Edit
With Conventional Commits
AI Analysis
The AI analyzes:- Files changed
- Lines added/removed
- Code context
- Commit patterns in your repository
- Your custom text (if provided)
- Concise summary line
- Detailed description (when appropriate)
- Relevant context about the changes
Best Practices
Use Preview Mode
Always preview first for important commits:Add Context for Clarity
Provide context for better messages:Review Before Committing
Always review the generated message and reject if it’s not accurate.Limit Diff Size for Large Changes
For large changesets, use--max-diff:
Integration with Git
Stage All Changes
Stage Specific Files
Amend Last Commit
Configuration
No additional configuration needed. The command uses your active Forge model and provider.Related Commands
git add- Stage changes before committinggit status- View changes before generating messagegit diff --staged- Preview staged changesforge suggest- Get shell command suggestions
Notes
- Requires staged changes (
git add) - Works with any Git repository
- Uses your configured Forge model
- Respects your repository’s commit message style
--max-diffhelps control API costs for large changes- Multiple words in custom text don’t need quotes
- Preview mode is useful for reviewing before committing