Skip to content

Commit 997ba50

Browse files
committed
docs: revamp documentation with expanded guides and practical examples
- Rewrite and expand documentation to provide clearer installation and usage instructions - Add step-by-step setup guide and configuration examples for AI providers - Introduce advanced options and custom commit templates with practical usage examples - Provide multiple input/output examples for typical commit scenarios, including multilingual and template-based commits - Add troubleshooting section covering common edge cases such as missing API keys, file exclusions, and network proxies - Remove outdated and redundant sections to improve readability and focus on actionable guidance Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 2abf92e commit 997ba50

File tree

1 file changed

+188
-92
lines changed

1 file changed

+188
-92
lines changed

skills/commit-helper/SKILL.md

Lines changed: 188 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,162 +1,258 @@
11
---
22
name: generating-commit-messages
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.
3+
description: Automatically generates conventional commit messages by analyzing your staged git changes using AI. Use this skill when you need to create well-formatted, meaningful commit messages that follow the Conventional Commits specification, or when you want to save time writing commit descriptions for your changes.
44
---
55

66
# Generating Commit Messages
77

8-
## Description
8+
## Step-by-Step Instructions
99

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.
10+
### Installation
1111

12-
## Installation
12+
1. Run the install script to download and set up CodeGPT:
1313

14-
Run the install script to automatically download and set up the latest release:
14+
```bash
15+
bash < <(curl -sSL https://raw.githubusercontent.com/appleboy/CodeGPT/main/install.sh)
16+
```
1517

16-
```sh
17-
bash < <(curl -sSL https://raw.githubusercontent.com/appleboy/CodeGPT/main/install.sh)
18-
```
18+
2. Configure your AI provider in `~/.config/codegpt/.codegpt.yaml`:
1919

20-
## Usage
20+
```yaml
21+
openai:
22+
provider: openai # or: azure, anthropic, gemini, ollama, groq, openrouter
23+
api_key: your_api_key_here
24+
model: gpt-4o
25+
```
2126
2227
### Basic Usage
2328
24-
Generate a commit message for staged changes (Skip confirmation prompts):
29+
1. Stage your changes:
30+
31+
```bash
32+
git add <files>
33+
```
34+
35+
2. Generate and commit with AI-generated message:
36+
37+
```bash
38+
codegpt commit --no_confirm
39+
```
40+
41+
3. Or preview the message before committing:
42+
43+
```bash
44+
codegpt commit --preview
45+
```
46+
47+
### Advanced Options
48+
49+
- **Set language**: Use `--lang` to specify output language (en, zh-tw, zh-cn)
50+
51+
```bash
52+
codegpt commit --lang zh-tw
53+
```
54+
55+
- **Use specific model**: Override the default model
56+
57+
```bash
58+
codegpt commit --model gpt-4o
59+
```
60+
61+
- **Exclude files**: Ignore certain files from the diff analysis
62+
63+
```bash
64+
codegpt commit --exclude_list "*.lock,*.json"
65+
```
66+
67+
- **Custom templates**: Format messages according to your team's style
68+
69+
```bash
70+
codegpt commit --template_string "[{{.summarize_prefix}}] {{.summarize_title}}"
71+
```
72+
73+
- **Amend commit**: Update the previous commit message
74+
75+
```bash
76+
codegpt commit --amend
77+
```
78+
79+
## Examples of Inputs and Outputs
80+
81+
### Example 1: Adding a new feature
82+
83+
**Input:**
2584

2685
```bash
86+
# After making changes to add user authentication
87+
git add src/auth.go src/middleware.go
2788
codegpt commit --no_confirm
2889
```
2990

30-
### Common Options
91+
**Output:**
92+
93+
```txt
94+
feat: add user authentication middleware
95+
96+
Implement JWT-based authentication system with login and token validation
97+
middleware for protecting API endpoints.
98+
```
99+
100+
### Example 2: Fixing a bug
101+
102+
**Input:**
31103

32104
```bash
33-
# Preview commit message before committing
105+
# After fixing a null pointer error
106+
git add src/handlers/user.go
34107
codegpt commit --preview
108+
```
35109

36-
# Skip confirmation prompts
37-
codegpt commit --no_confirm
110+
**Output:**
38111

39-
# Set output language (en, zh-tw, zh-cn)
40-
codegpt commit --lang zh-tw
112+
```txt
113+
fix: resolve null pointer exception in user handler
41114
42-
# Use specific AI model
43-
codegpt commit --model gpt-4o
115+
Add nil checks before accessing user object properties to prevent crashes
116+
when processing requests with missing user data.
44117
45-
# Amend previous commit
46-
codegpt commit --amend
118+
[Preview shown, waiting for confirmation...]
119+
```
47120

48-
# Display prompt only (no API call)
49-
codegpt commit --prompt_only
121+
### Example 3: Chinese language commit
50122

51-
# Write to specific output file
52-
codegpt commit --file /path/to/commit-msg
123+
**Input:**
53124

54-
# Customize diff context lines
55-
codegpt commit --diff_unified 5
125+
```bash
126+
git add docs/README.md
127+
codegpt commit --lang zh-tw --no_confirm
128+
```
56129

57-
# Exclude specific files from diff
58-
codegpt commit --exclude_list "*.lock,*.json"
130+
**Output:**
59131

60-
# Use custom template file
61-
codegpt commit --template_file ./my-template.tmpl
132+
```txt
133+
docs: 更新專案說明文件
62134
63-
# Use inline template string
64-
codegpt commit --template_string "{{.summarize_prefix}}: {{.summarize_title}}"
135+
新增安裝步驟說明以及使用範例,讓新使用者能夠快速上手。
136+
```
65137

66-
# Set API timeout
67-
codegpt commit --timeout 60s
138+
### Example 4: Custom template with ticket number
68139

69-
# Configure network proxy
70-
codegpt commit --proxy http://proxy.example.com:8080
71-
codegpt commit --socks socks5://127.0.0.1:1080
140+
**Input:**
141+
142+
```bash
143+
git add src/api/payment.go
144+
codegpt commit --template_string "{{.summarize_prefix}}(JIRA-123): {{.summarize_title}}" --no_confirm
72145
```
73146

74-
### Template Variables
147+
**Output:**
75148

76-
When using custom templates, the following variables are available:
149+
```txt
150+
feat(JIRA-123): integrate payment gateway API
151+
```
77152

78-
- `{{.summarize_prefix}}` - Conventional commit prefix (feat, fix, docs, etc.)
79-
- `{{.summarize_title}}` - Brief commit title
80-
- `{{.summarize_message}}` - Detailed commit message body
153+
### Example 5: Excluding lock files
81154

82-
You can also provide custom variables:
155+
**Input:**
83156

84157
```bash
85-
codegpt commit --template_vars "author=John,ticket=PROJ-123"
86-
codegpt commit --template_vars_file ./vars.env
158+
git add .
159+
codegpt commit --exclude_list "package-lock.json,yarn.lock,go.sum" --preview
87160
```
88161

89-
## Workflow
162+
**Output:**
90163

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
164+
```txt
165+
refactor: reorganize project structure
99166
100-
## Configuration
167+
Move utility functions into separate packages and update import paths
168+
throughout the codebase for better modularity.
101169
102-
Configure via `~/.config/codegpt/.codegpt.yaml`:
170+
(Lock files excluded from analysis)
171+
```
103172

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
173+
## Common Edge Cases
110174

111-
git:
112-
diff_unified: 3
113-
exclude_list: []
114-
template_file: ""
115-
template_string: ""
175+
### No staged changes
116176

117-
output:
118-
lang: en # or: zh-tw, zh-cn
119-
file: ""
177+
**Issue**: Running `codegpt commit` without staging any changes.
178+
179+
**Solution**: Stage your changes first:
180+
181+
```bash
182+
git add <files>
183+
codegpt commit
120184
```
121185

122-
## Examples
186+
### API timeout for large diffs
187+
188+
**Issue**: Large changesets may cause API timeouts.
123189

124-
### Example 1: Basic commit without preview
190+
**Solution**: Increase timeout or commit changes in smaller batches:
125191

126192
```bash
127-
# Stage your changes
128-
git add .
193+
codegpt commit --timeout 60s
194+
```
129195

130-
# Generate commit message without confirmation
131-
codegpt commit --no_confirm
196+
### Generated files in diff
197+
198+
**Issue**: Lock files or generated code affecting commit message quality.
199+
200+
**Solution**: Exclude these files from analysis:
201+
202+
```bash
203+
codegpt commit --exclude_list "package-lock.json,yarn.lock,*.min.js,dist/*"
132204
```
133205

134-
### Example 2: Chinese commit message
206+
### API key not configured
207+
208+
**Issue**: Error message about missing API key.
209+
210+
**Solution**: Set up your API key in the config file:
135211

136212
```bash
137-
codegpt commit --lang zh-tw --model gpt-4o --no_confirm
213+
codegpt config set openai.api_key "your-api-key-here"
138214
```
139215

140-
### Example 3: Custom template
216+
### Custom commit format required
217+
218+
**Issue**: Team requires specific commit message format (e.g., with ticket numbers).
219+
220+
**Solution**: Use custom templates:
141221

142222
```bash
143-
codegpt commit \
144-
--template_string "[{{.summarize_prefix}}] {{.summarize_title}}" \
145-
--template_vars "ticket=PROJ-123"
223+
codegpt commit --template_string "[{{.summarize_prefix}}] TICKET-123: {{.summarize_title}}"
146224
```
147225

148-
### Example 4: With file exclusions
226+
Or save it in config file:
227+
228+
```yaml
229+
git:
230+
template_string: "[{{.summarize_prefix}}] {{.ticket}}: {{.summarize_title}}"
231+
```
232+
233+
### Multilingual team
234+
235+
**Issue**: Need commit messages in different languages for different repositories.
236+
237+
**Solution**: Set language per command or configure per repository:
149238
150239
```bash
151-
codegpt commit \
152-
--exclude_list "package-lock.json,yarn.lock,go.sum" \
153-
--preview
240+
# Per command
241+
codegpt commit --lang zh-cn
242+
243+
# Or set in repository's .codegpt.yaml
244+
output:
245+
lang: zh-cn
154246
```
155247
156-
## Tips
248+
### Network proxy required
249+
250+
**Issue**: API calls fail due to corporate firewall.
157251
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
252+
**Solution**: Configure proxy settings:
253+
254+
```bash
255+
codegpt commit --proxy http://proxy.company.com:8080
256+
# Or for SOCKS proxy
257+
codegpt commit --socks socks5://127.0.0.1:1080
258+
```

0 commit comments

Comments
 (0)