AI-Powered Git Commit Message Generator
Never struggle with commit messages again! Let AI craft perfect conventional commits for you.
| Feature | Manual Commits | Other Tools | catmit |
|---|---|---|---|
| Quality | Inconsistent | Template-based | AI-powered, contextual |
| Speed | Slow thinking | Fast but generic | Fast + intelligent |
| Conventional Commits | Manual effort | Basic support | Perfect compliance |
| Multi-language | N/A | Limited | Chinese + English |
| Context Awareness | Your brain only | Basic | Full git history analysis |
| Customization | Full control | Limited | Flexible with multiple providers |
- AI-Powered: Uses advanced LLM to analyze your changes and generate meaningful commit messages
- Conventional Commits: Follows conventional commit format with proper type, scope, and description
- Beautiful TUI: Interactive terminal interface with real-time progress indicators
- Multi-Language: Supports both English and Chinese output
- Fast & Reliable: Built in Go with robust error handling and timeout support
- Flexible Usage: Works in both interactive and automated (CI/CD) modes
- Smart Analysis: Analyzes git history, file changes, and repository context
- Multiple Providers: Supports DeepSeek, OpenAI, Azure OpenAI, Anthropic, Gemini, Volcengine Ark, Ollama, and any OpenAI-compatible API
# Interactive mode with TUI
catmit
# Auto-commit without confirmation
catmit -y
# Preview message only (dry run)
catmit --dry-run
# Generate in Chinese
catmit -l zh
# Set custom timeout (default: 30s)
catmit -t 60
# Provide seed text for better context (via positional argument)
catmit "fix user authentication"
# Or use the --seed flag (same effect)
catmit --seed "fix user authentication"# Silent mode (no TUI, direct output)
catmit --dry-run -y
# Combine options
catmit -y -l zh -t 60
# Test your configuration
catmit --dry-run
# Get help
catmit --help
# Check version
catmit --version# Consolidate multiple commit messages into one (opens editor)
catmit squash-draft
# Skip confirmation, output directly
catmit squash-draft --yes
# Generate in Chinese
catmit squash-draft --lang zh
# Custom timeout
catmit squash-draft --timeout 60
# Dry run mode to preview without copying
catmit squash-draft --dry-run
# Example workflow:
$ catmit squash-draft
# Opens your default editor to input commit messages
# Enter messages one per line, save and exit
# Generated result (automatically copied to clipboard):
feat: implement complete authentication system
- Add user authentication with JWT support
- Fix login error on mobile devices
- Update authentication documentation
Copied to clipboard# Squash unpushed commits using interactive rebase
catmit squash-history
# Skip confirmation (auto-confirm)
catmit squash-history --yes
# Generate in Chinese
catmit squash-history --lang zh
# Custom timeout
catmit squash-history --timeout 60
# Example workflow:
$ catmit squash-history
# Analyzes unpushed commits
# Generates consolidated commit message using AI
# Performs interactive rebase with backup branch creation
# Rebase completed successfully
# Backup branch: backup-feature-branch-20250122-123456Squash History Features:
- Smart Analysis: Automatically detects unpushed commits
- AI-Generated Messages: Creates meaningful commit messages from multiple commits
- Safety First: Creates backup branches before making changes
- TUI Interface: Interactive terminal UI for confirmation and monitoring
- Base Branch Detection: Auto-detects main/master as base branch
# Create a pull request with AI-generated description
catmit pr
# Create as draft PR
catmit pr --draft
# Specify remote and base branch
catmit pr --remote upstream --base develop
# Skip template usage
catmit pr --template=false
# Check authentication status for all git remotes
catmit check-authSupported PR Platforms:
- GitHub (via
ghCLI) - GitLab (via
glabCLI) - Gitea (via
teaCLI)
Requirements:
- For GitHub:
ghCLI must be installed and authenticated- Install:
brew install ghor visit cli.github.com - Authenticate:
gh auth login
- Install:
- For GitLab:
glabCLI must be installed and authenticated- Install:
brew install glabor visit gitlab.com/gitlab-org/cli - Authenticate:
glab auth login
- Install:
- For Gitea:
teaCLI must be installed and authenticated- Install:
brew install teaor visit gitea.com/gitea/tea - Authenticate:
tea login add
- Install:
catmit supports both repository templates and custom configuration templates:
Repository Template Locations (auto-detected):
.github/pull_request_template.md.github/PULL_REQUEST_TEMPLATE.mddocs/pull_request_template.mdPULL_REQUEST_TEMPLATE.md
Custom Template Support:
catmit automatically detects PR templates from standard repository locations (.github/pull_request_template.md, etc.) and uses them when creating pull requests.
Features:
- Auto-detection of PR template files
- Template variables substitution:
{{.CommitMessage}}- Your generated commit message{{.Branch}}- Current branch name{{.BaseBranch}}- Target base branch{{.Date}}- Current date- Disable with
--pr-template=falseif needed
Example Template:
## Description
{{.CommitMessage}}
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
## Testing
- [ ] Tests pass locally
- [ ] New tests added
Branch: {{.Branch}} β {{.BaseBranch}}catmit provides comprehensive control over pull request creation:
All PR Flags:
# Create PR with all options
catmit pr \
--remote upstream \
--base develop \
--draft \
--provider github
# Generate commit message first, then create PR
catmit --yes # Commit with AI-generated message
catmit pr # Create PR for the committed changesFork Workflow Support:
# Working on a fork? Push to origin and create PR to upstream
git remote -v # origin (your fork), upstream (original repo)
catmit pr --remote upstream
# Or use the shorthand
catmit pr -r upstreamMulti-Remote Scenarios:
# List all remotes and their providers
catmit check-auth
# Create PR to specific remote
catmit pr --remote company
# Create PR for existing branch
catmit pr # Will create PR without pushing if branch existsProvider Detection:
- Auto-detects from git remote URL
- Maps custom hosts via
~/.config/catmit/providers.yaml - Override with
--providerwhen needed - Supports GitHub Enterprise and self-hosted GitLab
$ catmit
Analyzing repository...
Processing 3 staged files...
Generating commit message...
ββ Generated Commit Message ββββββββββββββββββββββββββββββββββ
β feat(auth): implement OAuth2 integration with GitHub β
β β
β - Add GitHub OAuth2 provider with scope configuration β
β - Implement secure token storage with encryption β
β - Add user profile synchronization from GitHub API β
β - Update login flow to support OAuth2 redirect β
β β
β Resolves #145 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Commit this message? [Y/n]: y
Committed successfully!
brew tap penwyp/catmit
brew install catmitgo install github.com/penwyp/catmit@latestDownload the latest release from GitHub Releases for your platform.
catmit --version- Choose your LLM provider (see LLM Provider Configuration below)
- Set environment variables for your chosen provider
- Make some changes and stage them:
git add . - Generate and commit:
catmit
catmit supports multiple LLM providers through three environment variables. Configure them based on your preferred provider:
# Required
export CATMIT_LLM_API_KEY="sk-your-deepseek-api-key"
# Optional (these are the defaults)
export CATMIT_LLM_API_URL="https://api.deepseek.com/v1/chat/completions"
export CATMIT_LLM_MODEL="deepseek-chat"Get your API key: DeepSeek Console
# Required
export CATMIT_LLM_API_KEY="your-volcengine-api-key"
export CATMIT_LLM_API_URL="https://ark.cn-beijing.volces.com/api/v3/chat/completions"
export CATMIT_LLM_MODEL="deepseek-v3-250324"Get your API key: Volcengine Ark Console
# Required
export CATMIT_LLM_API_KEY="sk-your-openai-api-key"
export CATMIT_LLM_API_URL="https://api.openai.com/v1/chat/completions"
export CATMIT_LLM_MODEL="gpt-4"Get your API key: OpenAI API Keys
# Required
export CATMIT_LLM_PROVIDER="azure"
export CATMIT_LLM_API_KEY="your-azure-api-key"
export CATMIT_LLM_API_URL="https://your-resource.openai.azure.com"
export CATMIT_LLM_MODEL="your-deployment-name"Setup:
- Get your API key from Azure OpenAI Service
- Replace
your-resourcewith your Azure OpenAI resource name - Replace
your-deployment-namewith your model deployment name (e.g.,gpt-4,gpt-35-turbo)
- Set
CATMIT_LLM_PROVIDER=anthropic. - Uses
CATMIT_LLM_API_KEY; optionalCATMIT_LLM_API_URL(defaulthttps://api.anthropic.com/v1/messages). CATMIT_LLM_MODELdefaults toclaude-3-sonnet-20240229.- Streaming supported via SSE.
- Set
CATMIT_LLM_PROVIDER=gemini. - Uses
CATMIT_LLM_API_KEY; API URL defaults tohttps://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent. CATMIT_LLM_MODELdefaults togemini-pro.- Streaming supported via
:streamGenerateContent.
- Set
CATMIT_LLM_PROVIDER=ollama. - Local HTTP API, no API key required.
CATMIT_LLM_API_URLdefaults tohttp://localhost:11434/api/chat.CATMIT_LLM_MODELdefaults tollama2.- Ensure the local Ollama server is running.
# Required - adjust for your provider
export CATMIT_LLM_API_KEY="your-api-key"
export CATMIT_LLM_API_URL="https://your-provider.com/v1/chat/completions"
export CATMIT_LLM_MODEL="your-model-name"catmit can use local AI CLI tools instead of API calls. This is useful if you have Claude Code, Gemini CLI, Qwen Code, AIChat, or other AI CLI tools installed:
# Required - both must be set
export CATMIT_LLM_PROVIDER="cli"
export CATMIT_LLM_CLI_TOOL="claude" # or absolute path like /usr/local/bin/claude
# Supported tools (use binary name or full path):
# - claude (Claude Code CLI)
# - cursor-agent (Cursor Agent CLI)
# - gemini (Gemini CLI)
# - qwen, qwen-code (Qwen Code)
# - aichat (AIChat tool)
# - ollama (Ollama with model)
# - Any other CLI tool that accepts prompts via stdin or arguments
# For Ollama, you can specify the model
export CATMIT_LLM_MODEL="llama2" # Optional, defaults to llama2Usage Examples:
# Using Claude Code
export CATMIT_LLM_PROVIDER=cli
export CATMIT_LLM_CLI_TOOL=claude
catmit
# Using Cursor Agent
export CATMIT_LLM_PROVIDER=cli
export CATMIT_LLM_CLI_TOOL=cursor-agent
catmit --timeout 60
# Using Gemini CLI
export CATMIT_LLM_PROVIDER=cli
export CATMIT_LLM_CLI_TOOL=gemini
catmitImportant Notes:
- No fallback: If the CLI tool fails, catmit will exit (no automatic fallback to API)
- User control: You must explicitly set both environment variables
- Tool verification: catmit will verify the tool exists and is executable on startup
- Authentication: CLI tools use their own authentication (no API key needed)
- Timeout: Some CLI tools may need longer timeouts than the default 20 seconds
| Variable | Description | Required | Default |
|---|---|---|---|
CATMIT_LLM_PROVIDER |
LLM provider type (azure, anthropic, gemini, ollama, cli, or leave empty for OpenAI-compatible) |
No | OpenAI-compatible |
CATMIT_LLM_API_KEY |
API key for your chosen provider (not needed for CLI provider) | Yes* | - |
CATMIT_LLM_API_URL |
API endpoint (full URL for OpenAI-compatible, base URL for Azure) | No | https://api.deepseek.com/v1/chat/completions |
CATMIT_LLM_MODEL |
Model name (for OpenAI-compatible) or deployment name (for Azure) | No | deepseek-chat |
CATMIT_LLM_CLI_TOOL |
CLI tool binary name or absolute path (required when PROVIDER=cli) |
Yes** | - |
* Required for API providers (OpenAI-compatible, Azure), not needed for CLI provider
** Required only when CATMIT_LLM_PROVIDER=cli
catmit automatically detects git hosting providers through a configuration file. The default configuration maps common git hosts to their respective platforms:
Configuration File Location: ~/.config/catmit/providers.yaml
This file is automatically created on first run with default mappings. You can customize it to add your own git hosting services:
# Default provider mappings
hosts:
github.com: github
gitlab.com: gitlab
bitbucket.org: bitbucket
# Add custom enterprise hosts
git.company.com: github # GitHub Enterprise
gitlab.internal.com: gitlab # GitLab self-hostedFeatures:
- Auto-detection of PR provider based on git remote URL
- Hot-reload: Changes take effect immediately without restart
- Enterprise support: Map your internal git hosts to supported providers
- Override with
--pr-providerflag when needed
- ** Repository Analysis**: Scans recent commits, branch info, and current staged changes
- ** Smart Context Building**:
- Intelligent file prioritization based on change importance
- Token budget management for large diffs
- Untracked file analysis and inclusion
- Concurrent Git operations for performance
- ** AI Generation**: Sends optimized context to your chosen LLM provider for intelligent message generation
- ** Quality Assurance**: Validates conventional commit format and provides interactive review
- ** Smart Commit**: Executes git commit with the generated message
Intelligent Change Analysis:
- File Priority Scoring: Automatically prioritizes important files (configs, main files, tests) over less critical ones
- Token Budget Management: Smartly truncates large diffs to fit within LLM context limits while preserving key information
- Untracked File Support: Includes new files in analysis for comprehensive commit messages
- Change Magnitude Detection: Categorizes changes as small/medium/large to guide commit message detail level
- Suggested Commit Prefixes: AI suggests appropriate conventional commit types (feat/fix/docs/refactor) based on changes
git commit -m "fix bug"
git commit -m "update stuff"
git commit -m "changes"
git commit -m "wip"fix(auth): resolve token validation race condition
- Add mutex to prevent concurrent token refresh
- Update error handling for expired tokens
- Improve test coverage for edge cases
Closes #123feat(ui): add dark mode toggle with system preference detection
- Implement theme context with localStorage persistence
- Add CSS variables for consistent color management
- Create toggle component with smooth transitions
- Support system preference auto-detection
Resolves #89- Go 1.22+
- Git
- LLM API key (DeepSeek recommended)
git clone https://github.com/penwyp/catmit.git
cd catmit
make build# Run all tests
make test
# Run with coverage
go test -coverprofile=coverage.out ./... && go tool cover -func=coverage.out
# Run E2E tests
make e2e
# Lint code
make lintcatmit/
βββ pkg/ # Public packages
β βββ gitinfo/ # Git operations and data collection
β βββ llm/ # LLM provider clients with OpenAI-compatible support
β βββ prompt/ # Prompt template builder with language support
βββ internal/ # Internal packages
β βββ app/ # Application dependencies and providers
β βββ cli/ # CLI tool detection and management
β βββ config/ # YAML configuration management
β βββ errors/ # Custom error types
β βββ git/ # Git operations (commit, push, stage)
β βββ pr/ # Pull request creation logic
β βββ provider/ # Git provider detection (GitHub, GitLab)
β βββ squash/ # Commit squashing functionality
β βββ template/ # PR template management
β βββ ui/ # Bubble Tea TUI components
β βββ workflow/ # Workflow orchestration
βββ cmd/ # Cobra CLI commands
βββ test/e2e/ # End-to-end tests
βββ docs/ # Documentation
- API Keys: Never commit API keys to repositories. Use environment variables or secure key management.
- Code Privacy: Only git diffs are sent to LLM providers, not your entire codebase.
- Network: All API calls use HTTPS encryption.
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Make your changes and add tests
- Ensure tests pass (
make test) - Commit using catmit (
catmit) - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- DeepSeek for providing excellent AI capabilities
- OpenAI for pioneering the API standards
- Volcengine for reliable cloud AI services
- Bubble Tea for the amazing TUI framework
- Cobra for the CLI framework
- Conventional Commits for the commit standard
If catmit helped you, please consider giving it a β!