Prompt file imported from knative/func (
.claude/commands/func-commit-message.md). Fill in{{arguments}}before use. Copyright stays with the author.
Git Commit Message Guidelines
Create a git commit message following these rules:
The Seven Rules
- Separate subject from body with a blank line
- Limit the subject line to 50 characters
- Use conventional commit spec for subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line
- Wrap the body at 72 characters
- Use the body to explain what and why vs. how
Format
<type>: <subject - max 50 chars total, imperative mood, conventional commit spec> <Body - wrapped at 72 chars, explains what and why> <Optional bullet points for clarity> <Optional "Issue {{arguments}}" if provided>
Conventional Commits
- Use conventional commits spec with types: feat, fix, refactor, docs, test, chore, style, perf, ci, build
- Format:
<type>: <description> - Examples: "feat: add user authentication", "fix: resolve memory leak in cache"
- Use "feat" only on user-facing changes
Subject Line
- Write as if completing: "If applied, this commit will..."
- Include type prefix (conventional commits)
- Total length max 50 chars including type
- Examples: "refactor: simplify cache handling", "fix: prevent race condition"
- NOT: "refactored cache", "fixed the race"
Body
- Explain the motivation for the change
- Explain the "what" and "why" vs. "how" which means:
- the way things worked before the change (and what was wrong with that),
- the way they work now,
- and why the contributor decided to solve it the way they did,
- and if you're not sure about the "why" then ask the contributor.
- Focus on context, not implementation details
- Find a balance for message length, i.e. analyze the diff and decide if a shorter message is enough or more explanation is needed
- Don't overuse bullet points (-, *, +), add them only in bigger commits if (and only if) they are helpful
- Keep it short if there aren't many changes
Example
Here is a good example from a commit to the Bitcoin core.
refactor: simplify serialize.h's exception handling
Remove the 'state' and 'exceptmask' from serialize.h's stream
implementations, as well as related methods.
As exceptmask always included 'failbit', and setstate was always
called with bits = failbit, all it did was immediately raise an
exception. Get rid of those variables, and replace the setstate
with direct exception throwing (which also removes some dead
code).
As a result, good() is never reached after a failure (there are
only 2 calls, one of which is in tests), and can just be replaced
by !eof().
fail(), clear(n) and exceptions() are just never called. Delete
them.
Context
- Current git status: !
git status - Current git diff (staged and unstaged changes): !
git diff HEAD - Current branch: !
git branch --show-current
Task
- Analyze the staged changes from git diff
- New added features and fixes are more important than other types like refactoring, etc.
- Draft a commit message following all seven rules
- Use conventional commits spec
- If {{arguments}} is provided, add "Issue {{arguments}}" at the bottom
- Show me the final message - DO NOT commit it