Skip to content

Commit 4ef3503

Browse files
committed
docs: update task instructions in commit message generation prompt
- Simplify task steps from numbered list to clearer step-by-step format - Reorganize instructions for better readability and understanding - Update context and efficient strategies sections for consistency - Remove redundant recommendations section in favor of integrated guidance This is a documentation update to the internal prompt used by the AI to generate commit messages, making the instructions clearer and more structured.
1 parent e339caa commit 4ef3503

File tree

1 file changed

+32
-36
lines changed

1 file changed

+32
-36
lines changed

src/claude_commit/main.py

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -237,51 +237,47 @@ async def generate_commit_message(
237237
</context>
238238
239239
<task>
240-
1. **FIRST**: Check the recent commit history (e.g., `git log -3 --oneline` or `git log -3 --pretty=format:"%s"`) to understand the commit message format/style used in this project
241-
- Does it use gitmoji? (emojis like ✨, 🐛, ♻️, etc.)
242-
- What language? (Chinese, English, etc.)
243-
- What format? (conventional commits, custom format, etc.)
244-
- **IMPORTANT**: You MUST follow the same style/format/language as the existing commits
240+
Follow these steps to generate an excellent commit message:
245241
246-
2. Investigate the changes thoroughly. Use whatever tools and commands you need.
242+
1. **Check commit history style** (choose ONE approach):
243+
- Run `git log -3 --oneline` to see recent commits
244+
- This shows you: gitmoji usage, language (Chinese/English), format (conventional commits, etc.)
245+
- **MUST follow the same style/format/language as existing commits**
247246
248-
3. Understand the INTENT and IMPACT of the changes, not just the surface-level diff.
247+
2. **Analyze the changes**:
248+
- Run `git status` to see which files changed
249+
- Run `git diff --stat` first to get an overview (shows file names and line counts)
250+
- Only run full `git diff` if you need to see detailed changes
251+
- **IMPORTANT**: If diff is large (>{max_diff_lines} lines), use targeted strategies below instead
249252
250-
4. Read relevant files to understand context and purpose.
253+
3. **Understand the context** (use efficiently):
254+
- For significant changes, READ modified files to understand their purpose
255+
- Use GREP to understand code relationships WITHOUT reading entire files
256+
- Use GLOB to find related files if needed
251257
252-
5. Generate a commit message in **MULTI-LINE FORMAT** with:
253-
- First line: brief summary (< 50 chars)
254-
- Empty line
255-
- Bullet points (starting with "-") for detailed changes
256-
Example:
258+
4. **Generate the commit message** in MULTI-LINE FORMAT:
257259
```
258-
fix: correct formatting issue
260+
type: brief summary (< 50 chars)
259261
260-
- Preserve empty lines in commit messages
261-
- Update prompt to require multi-line format
262-
- Add examples showing proper structure
262+
- First change detail
263+
- Second change detail
264+
- Third change detail
263265
```
264266
</task>
265267
266-
<recommendations>
267-
Use your judgment on what's necessary:
268-
269-
- Start with `git log -3 --oneline` to check the commit message style
270-
- Then use `git status` and `git diff {"--cached" if staged_only else ""}` to see what changed
271-
- **If diff output is large (>{max_diff_lines} lines)**, use these strategies:
272-
* Run `git diff --stat` for an overview of changed files
273-
* Use `git diff <specific_file>` to analyze files individually
274-
* Use `grep` to search for specific patterns instead of reading full diff
275-
* Focus on the most significant changes first
276-
- For non-trivial changes, READ the modified files to understand their purpose
277-
- **USE GREP extensively** to understand impact and context:
278-
* If a function was modified, grep for its usage: `grep -n "function_name("`
279-
* If a class was added/changed, find related classes: `grep -n "class.*Base"` or similar patterns
280-
* If imports changed, see where they're used: `grep -n "imported_module"`
281-
* To understand scope, count usages: `grep --output_mode count "pattern"`
282-
* Get context around matches: `grep -C 3 "pattern"` (3 lines before/after)
283-
- Consider the broader context of the codebase
284-
</recommendations>
268+
<efficient_strategies>
269+
**For large diffs** (>{max_diff_lines} lines):
270+
- Use `git diff --stat` for overview, then `git diff <specific_file>` for key files only
271+
- Use `grep` to search for specific patterns instead of reading full diff
272+
- Focus on the most impactful changes first
273+
274+
**Use GREP extensively** to understand code relationships:
275+
- Modified function `process_data()`? → `grep -n "process_data("` to see where it's called
276+
- New class `UserManager`? → `grep -n "class.*Manager"` to find similar patterns
277+
- Imports changed? → `grep -n "from new_module import"` to see usage
278+
- Want context? → `grep -C 3 "function_name"` to see surrounding code
279+
- Count usage? → `grep --output_mode count "pattern"` to understand scope
280+
</efficient_strategies>
285281
286282
<output>
287283
When you're confident you understand the changes, output your commit message in this exact format:

0 commit comments

Comments
 (0)