Skip to content
This repository was archived by the owner on Jan 14, 2026. It is now read-only.

Commit ba5b316

Browse files
committed
refactor(gitcommit): restructure generator prompt
1 parent aad9276 commit ba5b316

1 file changed

Lines changed: 24 additions & 29 deletions

File tree

lua/codecompanion/_extensions/gitcommit/generator.lua

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -248,53 +248,48 @@ function Generator._create_prompt(diff, lang, commit_history)
248248
end
249249

250250
return string.format(
251-
[[You are a commit message generator. Generate exactly ONE complete Conventional Commit message for the provided git diff.%s
252-
253-
CRITICAL FORMAT REQUIREMENTS:
254-
1. MUST generate exactly ONE commit message, never multiple messages
255-
2. MUST analyze ALL changes in the diff as a single logical unit
256-
3. MUST respond with ONLY the commit message, no explanations, markdown code blocks, or extra text
257-
4. DO NOT wrap the output in markdown code blocks (```) or any other formatting
251+
[[You are a commit message generator. Generate exactly ONE Conventional Commit message for the provided git diff.%s
258252
259253
FORMAT:
260-
type(scope): brief description
254+
type(scope): specific description of WHAT changed
261255
262-
[Optional body - only if needed]
256+
[Optional body - only for non-obvious changes]
263257
264258
Allowed types: feat, fix, docs, style, refactor, perf, test, chore
265259
Language: %s
266260
267-
RULES:
268-
- Keep Subject Line under 50 characters, body lines under 72 characters
269-
- DEFAULT TO MINIMAL: prefer fewer bullet points over more
270-
- Body is OPTIONAL: omit if subject line is self-explanatory
271-
- NEVER pad with redundant points - each bullet must add unique value
272-
- If commit history is provided, follow established patterns
261+
CRITICAL RULES:
262+
1. Respond with ONLY the commit message - no markdown blocks, no explanations
263+
2. Description must state WHAT was done, not WHY or the effect
264+
3. AVOID vague verbs: "update", "improve", "clarify", "adjust", "enhance", "fix issues"
265+
USE specific verbs: "add", "remove", "rename", "move", "replace", "extract", "inline"
266+
4. Subject line under 50 chars, body lines under 72 chars
267+
5. Body is OPTIONAL - omit if subject is self-explanatory
268+
269+
BAD (vague):
270+
- refactor(api): improve error handling
271+
- fix(auth): update login logic
272+
- chore(deps): update dependencies
273273
274-
COMPLEXITY GUIDE:
275-
- Single file text change, config tweak, typo fix → NO body
276-
- Single logical change (rename, add one function) → 0-1 bullet
277-
- Multiple related changes → 2-3 bullets MAX
274+
GOOD (specific):
275+
- refactor(api): replace try-catch with Result type
276+
- fix(auth): check token expiry before API call
277+
- chore(deps): bump axios from 0.21 to 1.6
278278
279279
EXAMPLES:
280280
281-
fix(config): update timeout value
281+
docs(readme): add installation section
282282
283283
refactor(api): rename getUserData to fetchUser
284284
285-
- Update all call sites to use new name
285+
feat(auth): add OAuth2 token refresh flow
286286
287-
feat(auth): add OAuth2 support
287+
- Store refresh token in secure storage
288+
- Auto-refresh 5 min before expiry
288289
289-
- Implement token refresh flow
290-
- Add session persistence
291-
292-
Generate a CONCISE commit message:
293290
```diff
294291
%s
295-
```
296-
297-
Return ONLY the commit message.]],
292+
```]],
298293
history_context,
299294
lang or "English",
300295
diff

0 commit comments

Comments
 (0)