Skip to content

Commit 1a5270d

Browse files
committed
refactor(config): update commit message generation instructions
The commit introduces several improvements to the commit message generation instructions: - Added a detailed `<type-table>` with comprehensive guidance on when to use each commit type - Enhanced the existing instructions with more nuanced explanations - Improved readability and formatting of the instructions - Added a note about "customInstructions" potentially overriding default instructions - Maintained the core principles of generating concise and meaningful commit messages The changes provide clearer guidance for generating conventional commit messages while preserving the original intent of the configuration.
1 parent ab9dda7 commit 1a5270d

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed

src/commitMessageGenerator.ts

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,40 @@ export class CommitMessageGenerator {
1414
"You are a seasoned software engineer with more than 25 years of experience with an extraordinary ability for assessing and interpreting git diffs and writing detailed conventional commit messages and following 'instructions' and 'customInstructions' when generating them."
1515

1616
const prompt = `
17-
<task>
18-
Generate a detailed conventional commit message for the following Git diff:
17+
<task>
18+
Generate a detailed conventional commit message for the following Git diff:
1919
20-
${diff}
21-
</task>
22-
<instructions>
23-
- Use ONLY ${config.allowedTypes.map((val) => `'${val}'`).join(" | ")} as appropriate for the type of change.
24-
- When assessing the commit type, consider the real impact of the change on the codebase and reserve 'feat' for significant changes or true feature additions.
25-
- Always include a scope.
26-
- Never use '!' or 'BREAKING CHANGE' in the commit message.
27-
- Avoid excessive adjectives like 'enhance', 'comprehensive' etc
28-
- Output will use markdown formatting for lists etc.
29-
- Output will ONLY contain the commit message.
30-
- Do not explain the output.
31-
</instructions>
32-
${config.customInstructions ? `<customInstructions>\n${config.customInstructions}\n</customInstructions>` : ""}
33-
`.trim()
20+
${diff}
21+
</task>
22+
<instructions>
23+
- Use ONLY ${config.allowedTypes.map((val) => `'${val}'`).join(" | ")} as appropriate for the type of change.
24+
- When assessing the commit type, consider actual impact of the commit. Refer to the "type-table" below for further guidance on the default commit types.
25+
- Always include a scope.
26+
- Never use '!' or 'BREAKING CHANGE' in the commit message.
27+
- Avoid excessive adjectives like 'enhance', 'comprehensive' etc
28+
- Output will use markdown formatting for lists etc.
29+
- Output will ONLY contain the commit message.
30+
- Do not explain the output.
31+
- "customInstructions" override these instructions if they are provided and conflict.
32+
33+
<type-table>
34+
\`\`\`markdown
35+
| Commit Type | Typical Use Case | When to Use |
36+
| ----------- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
37+
| chore | Routine maintenance or updates | Use when updating configs or non-code changes. (eg updating dependencies, modifying configs, updating types, etc.) |
38+
| ci | Continuous integration adjustments | Use when updating CI/CD config files. (eg GitHub Actions, Workflows, Pipelines, etc.) |
39+
| docs | Documentation-only changes | Use only when updating or adding documentation, comments, or README files. (Do NOT use when adding or updating page content in web apps. eg Astro content collections.) |
40+
| feat | New feature | Use only when adding new, user-facing feature or functionality or a fundamental change in an existing feature's functionality. |
41+
| fix | Bug fix | Use when fixing a bug or issue in code that may or may not affect functionality. |
42+
| perf | Performance improvement | Use when improving performance. (eg by optimising code.) |
43+
| refactor | Code restructuring | Use when restructuring code without changing functionality or fixing bugs. (This can include significant code changes like abstracting code to its own component.) |
44+
| style | Code formatting or styling | Use when code changes do not affect functionality. (eg linting, formatting adjustments, colour, margin, padding, etc.) |
45+
| test | Adding or updating tests | Use when adding, updating, or removing tests. |
46+
\`\`\`
47+
</type-table>
48+
</instructions>
49+
${config.customInstructions ? `<customInstructions>\n${config.customInstructions}\n</customInstructions>` : ""}
50+
`.trim()
3451

3552
let message: Anthropic.Message | undefined = undefined
3653
try {

0 commit comments

Comments
 (0)