Agent protocol: Generate commit message
Goal: Draft a commit message that adheres to Conventional Commits specification and project standards, then present it for user approval.
When: Use when the agent needs to generate a commit message for staged changes.
NOTE: Use this skill only for generating a commit message, but
not for making commits.
Primary directives
Follow these rules when crafting, formatting, and presenting the commit message:
- •
ALWAYSstudyreferences/conventional-commit.mdbefore drafting. - •Aim for brevity and precision, but don't sacrifice clarity.
- •Use bullet points to list changes; optionally precede with brief "why" summary.
- •Character limits: Subject ≤50 chars (hard limit: 72); body/footer wrap at 72.
- •Use plain text, not markdown.
NEVERuse backticks (causes shell errors). - •Don't use line numbers or code blocks.
Presentation directives
- •
NEVERuse shell commands, likeecho,cat, or similar, when presenting the commit message. - •Present the commit message directly as plain text in a formatted code block within the agent's response.
Confirmation directives
After presenting the commit message, offer 4 options:
- •Approve and commit - Proceed with commit
- •Edit staged files -
Unstageand return to staging - •Regenerate message - Generate new message
- •Abort commit process - Cancel workflow
Make option 1 the default response. Assume "Approve and commit" if the user gives an empty response.
Git directives
Git commands (use --no-pager and --no-ext-diff for diffs):
For staged changes
git --no-pager diff --staged --no-ext-diff --stat --minimal --patience \
--histogram --find-renames --summary --no-color -U10
For unstaged changes
git --no-pager diff --no-ext-diff --stat --minimal --patience --histogram \
--find-renames --summary --no-color -U10 <file_group>
For repository status
git status --porcelain=v2 --branch
Efficiency directives
- •Optimize all operations for token and context efficiency
- •Batch git operations on all files simultaneously, avoid individual file processing
- •Use parallel execution when possible
- •Reduce token usage
Workflow
- •Study
references/conventional-commit.md - •Analyze staged changes via git directives
- •Draft and format complete commit message
- •Verify formatting rules and NO BACKTICKS
- •Present message and prompt for confirmation with 4 options
- •Await user response before further action
Output
Files created:
- •None (message generation only)
Status communication:
First line of output indicates user's decision:
- •
APPROVED: [commit message follows]- user approved message - •
REJECTED_EDIT_FILES: user wants to modify staged files- User wants to re-stage - •
REJECTED_REGENERATE: user wants new message- User wants message regenerated - •
REJECTED_ABORT: user cancelled commit- User aborted process - •
ERROR: [message]- Failed to generate message
Following lines (when APPROVED): complete commit message text