|
| 1 | +--- |
| 2 | +name: git commit message |
| 3 | +description: This skill provides AI-powered git commit message generation using the `codegpt commit` command. It analyzes git diffs and automatically generates conventional commit messages in multiple languages. |
| 4 | +--- |
| 5 | + |
| 6 | +# Git Commit Message |
| 7 | + |
| 8 | +## Description |
| 9 | + |
| 10 | +The git-commit skill leverages various AI providers (OpenAI, Anthropic, Gemini, Ollama, Groq, OpenRouter) to automatically generate meaningful commit messages that follow the [Conventional Commits](https://www.conventionalcommits.org/) specification. |
| 11 | + |
| 12 | +## Installation |
| 13 | + |
| 14 | +Run the install script to automatically download and set up the latest release: |
| 15 | + |
| 16 | +```sh |
| 17 | +bash < <(curl -sSL https://raw.githubusercontent.com/appleboy/CodeGPT/main/install.sh) |
| 18 | +``` |
| 19 | + |
| 20 | +## Usage |
| 21 | + |
| 22 | +### Basic Usage |
| 23 | + |
| 24 | +Generate a commit message for staged changes: |
| 25 | + |
| 26 | +```bash |
| 27 | +codegpt commit |
| 28 | +``` |
| 29 | + |
| 30 | +### Common Options |
| 31 | + |
| 32 | +```bash |
| 33 | +# Preview commit message before committing |
| 34 | +codegpt commit --preview |
| 35 | + |
| 36 | +# Skip confirmation prompts |
| 37 | +codegpt commit --no_confirm |
| 38 | + |
| 39 | +# Set output language (en, zh-tw, zh-cn) |
| 40 | +codegpt commit --lang zh-tw |
| 41 | + |
| 42 | +# Use specific AI model |
| 43 | +codegpt commit --model gpt-4o |
| 44 | + |
| 45 | +# Amend previous commit |
| 46 | +codegpt commit --amend |
| 47 | + |
| 48 | +# Display prompt only (no API call) |
| 49 | +codegpt commit --prompt_only |
| 50 | + |
| 51 | +# Write to specific output file |
| 52 | +codegpt commit --file /path/to/commit-msg |
| 53 | + |
| 54 | +# Customize diff context lines |
| 55 | +codegpt commit --diff_unified 5 |
| 56 | + |
| 57 | +# Exclude specific files from diff |
| 58 | +codegpt commit --exclude_list "*.lock,*.json" |
| 59 | + |
| 60 | +# Use custom template file |
| 61 | +codegpt commit --template_file ./my-template.tmpl |
| 62 | + |
| 63 | +# Use inline template string |
| 64 | +codegpt commit --template_string "{{.summarize_prefix}}: {{.summarize_title}}" |
| 65 | + |
| 66 | +# Set API timeout |
| 67 | +codegpt commit --timeout 60s |
| 68 | + |
| 69 | +# Configure network proxy |
| 70 | +codegpt commit --proxy http://proxy.example.com:8080 |
| 71 | +codegpt commit --socks socks5://127.0.0.1:1080 |
| 72 | +``` |
| 73 | + |
| 74 | +### Template Variables |
| 75 | + |
| 76 | +When using custom templates, the following variables are available: |
| 77 | + |
| 78 | +- `{{.summarize_prefix}}` - Conventional commit prefix (feat, fix, docs, etc.) |
| 79 | +- `{{.summarize_title}}` - Brief commit title |
| 80 | +- `{{.summarize_message}}` - Detailed commit message body |
| 81 | + |
| 82 | +You can also provide custom variables: |
| 83 | + |
| 84 | +```bash |
| 85 | +codegpt commit --template_vars "author=John,ticket=PROJ-123" |
| 86 | +codegpt commit --template_vars_file ./vars.env |
| 87 | +``` |
| 88 | + |
| 89 | +## Workflow |
| 90 | + |
| 91 | +1. **Diff Analysis**: Analyzes staged changes using `git diff` |
| 92 | +2. **Summarization**: AI generates a summary of the changes |
| 93 | +3. **Title Generation**: Creates a concise commit title |
| 94 | +4. **Prefix Detection**: Determines appropriate conventional commit prefix |
| 95 | +5. **Message Composition**: Combines all elements into a formatted message |
| 96 | +6. **Translation** (optional): Translates to target language if specified |
| 97 | +7. **Preview & Confirmation**: Shows message for review and optional editing |
| 98 | +8. **Commit**: Records changes to the repository |
| 99 | + |
| 100 | +## Configuration |
| 101 | + |
| 102 | +Configure via `~/.config/codegpt/.codegpt.yaml`: |
| 103 | + |
| 104 | +```yaml |
| 105 | +openai: |
| 106 | + provider: openai # or: azure, anthropic, gemini, ollama, groq, openrouter |
| 107 | + api_key: your_api_key_here |
| 108 | + model: gpt-4o |
| 109 | + timeout: 30s |
| 110 | + |
| 111 | +git: |
| 112 | + diff_unified: 3 |
| 113 | + exclude_list: [] |
| 114 | + template_file: "" |
| 115 | + template_string: "" |
| 116 | + |
| 117 | +output: |
| 118 | + lang: en # or: zh-tw, zh-cn |
| 119 | + file: "" |
| 120 | +``` |
| 121 | +
|
| 122 | +## Examples |
| 123 | +
|
| 124 | +### Example 1: Basic commit with preview |
| 125 | +
|
| 126 | +```bash |
| 127 | +# Stage your changes |
| 128 | +git add . |
| 129 | + |
| 130 | +# Generate and preview commit message |
| 131 | +codegpt commit --preview |
| 132 | +``` |
| 133 | + |
| 134 | +### Example 2: Chinese commit message |
| 135 | + |
| 136 | +```bash |
| 137 | +codegpt commit --lang zh-tw --model gpt-4o |
| 138 | +``` |
| 139 | + |
| 140 | +### Example 3: Custom template |
| 141 | + |
| 142 | +```bash |
| 143 | +codegpt commit \ |
| 144 | + --template_string "[{{.summarize_prefix}}] {{.summarize_title}}" \ |
| 145 | + --template_vars "ticket=PROJ-123" |
| 146 | +``` |
| 147 | + |
| 148 | +### Example 4: With file exclusions |
| 149 | + |
| 150 | +```bash |
| 151 | +codegpt commit \ |
| 152 | + --exclude_list "package-lock.json,yarn.lock,go.sum" \ |
| 153 | + --preview |
| 154 | +``` |
| 155 | + |
| 156 | +## Tips |
| 157 | + |
| 158 | +1. **Stage Changes First**: Always run `git add` before using `codegpt commit` |
| 159 | +2. **Use Preview Mode**: Review messages with `--preview` before committing |
| 160 | +3. **Customize Templates**: Create templates that match your team's commit style |
| 161 | +4. **Set Default Language**: Configure your preferred language in config file |
| 162 | +5. **Exclude Generated Files**: Use `--exclude_list` to ignore lock files and generated code |
0 commit comments