| name | commit-message |
| description | Generates git commit messages automatically by analyzing your staged changes using AI. Use this skill when you want to save time writing commit messages or need help describing what your code changes do. |
Generating Commit Messages
Step-by-Step Instructions
Installation
Run the install script to download and set up CodeGPT:
bash < <(curl -sSL https://raw.githubusercontent.com/appleboy/CodeGPT/main/install.sh)Configure your AI provider in
~/.config/codegpt/.codegpt.yaml:openai: provider: openai # or: azure, anthropic, gemini, ollama, groq, openrouter api_key: your_api_key_here model: gpt-4o
Basic Usage
Stage your changes:
git add <files>Generate and commit with AI-generated message:
codegpt commit --no_confirmNote: You don't need to manually run
git diffto review your changes. CodeGPT automatically reads the staged changes and analyzes them to generate an appropriate commit message.
Advanced Options
Set language: Use
--langto specify output language (en, zh-tw, zh-cn)codegpt commit --lang zh-tw --no_confirmUse specific model: Override the default model
codegpt commit --model gpt-4o --no_confirmExclude files: Ignore certain files from the diff analysis
codegpt commit --exclude_list "*.lock,*.json" --no_confirmCustom templates: Format messages according to your team's style
codegpt commit --template_string "[{{.summarize_prefix}}] {{.summarize_title}}" --no_confirmAmend commit: Update the previous commit message
codegpt commit --amend --no_confirm
Examples of Inputs and Outputs
Example 1: Adding a new feature
Input:
# After making changes to add user authentication
git add src/auth.go src/middleware.go
codegpt commit --no_confirm
Output:
feat: add user authentication middleware
Implement JWT-based authentication system with login and token validation
middleware for protecting API endpoints.
Example 2: Fixing a bug
Input:
# After fixing a null pointer error
git add src/handlers/user.go
codegpt commit --no_confirm
Output:
fix: resolve null pointer exception in user handler
Add nil checks before accessing user object properties to prevent crashes
when processing requests with missing user data.
[Preview shown, waiting for confirmation...]
Example 3: Chinese language commit
Input:
git add docs/README.md
codegpt commit --lang zh-tw --no_confirm
Output:
docs: 更新專案說明文件
新增安裝步驟說明以及使用範例,讓新使用者能夠快速上手。
Example 4: Custom template with ticket number
Input:
git add src/api/payment.go
codegpt commit --template_string "{{.summarize_prefix}}(JIRA-123): {{.summarize_title}}" --no_confirm
Output:
feat(JIRA-123): integrate payment gateway API
Example 5: Excluding lock files
Input:
git add .
codegpt commit --exclude_list "package-lock.json,yarn.lock,go.sum" --no_confirm
Output:
refactor: reorganize project structure
Move utility functions into separate packages and update import paths
throughout the codebase for better modularity.
(Lock files excluded from analysis)
Common Edge Cases
No staged changes
Issue: Running codegpt commit without staging any changes.
Solution: Stage your changes first:
git add <files>
codegpt commit
API timeout for large diffs
Issue: Large changesets may cause API timeouts.
Solution: Increase timeout or commit changes in smaller batches:
codegpt commit --timeout 60s --no_confirm
Generated files in diff
Issue: Lock files or generated code affecting commit message quality.
Solution: Exclude these files from analysis:
codegpt commit --exclude_list "package-lock.json,yarn.lock,*.min.js,dist/*" --no_confirm
API key not configured
Issue: Error message about missing API key.
Solution: Set up your API key in the config file:
codegpt config set openai.api_key "your-api-key-here"
Custom commit format required
Issue: Team requires specific commit message format (e.g., with ticket numbers).
Solution: Use custom templates:
codegpt commit --template_string "[{{.summarize_prefix}}](TICKET-123): {{.summarize_title}}"
Or save it in config file:
git:
template_string: "[{{.summarize_prefix}}]({{.ticket}}): {{.summarize_title}}"
Network proxy required
Issue: API calls fail due to corporate firewall.
Solution: Configure proxy settings:
codegpt commit --proxy http://proxy.company.com:8080
# Or for SOCKS proxy
codegpt commit --socks socks5://127.0.0.1:1080