commit-message
Generate clear, conventional commit messages from git diffs. Use when writing commit messages or reviewing staged changes.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Commit Message Generation
This skill generates clear, conventional commit messages from git diffs by analyzing staged changes and recent commit history.
When to Use This Skill
Use this skill when:
- Writing a commit message for staged changes
- Reviewing what to commit
- Need a well-formatted conventional commit message
- Analyzing git diffs to understand changes
How It Works
-
Analyze staged changes - Run
git diff --stagedto see what will be committed -
Review recent commits - Run
git log -5 --onelineto understand commit message style - Generate message - Create a concise, conventional commit message
- Return message - Provide the message for use in commit command
Message Format
Follow this strict format:
<type>: <subject>
[optional body]
Type (required)
Choose the most specific type:
- feat: New feature
- fix: Bug fix
- docs: Documentation only
- style: Formatting, missing semicolons, etc.
- refactor: Code restructuring without behavior change
- perf: Performance improvement
- test: Adding or updating tests
- chore: Build process, dependencies, tooling
- ci: CI/CD configuration
- build: Build system or dependencies
Subject (required)
- Present tense (Add, Fix, Update, not Added, Fixed, Updated)
- No period at the end
- 50 characters or less
- Lowercase after the colon
- Describe what changed and why, not how
Body (optional)
- Use only when the subject needs additional context
- Wrap at 72 characters
- Explain motivation and contrast with previous behavior
Guidelines
Subject Rules:
- ✓
feat: add user authentication with JWT - ✓
fix: prevent race condition in data loader - ✓
docs: update API endpoint documentation - ✗
Added user authentication(not conventional format) - ✗
fix: Fixed the bug(redundant, past tense) - ✗
Update stuff(too vague)
Be Specific:
- ✓
refactor: extract validation logic to separate module - ✗
refactor: improve code
Single Responsibility:
- If changes span multiple types, prefer the most significant one
- If truly mixed, consider suggesting multiple commits
Process
-
Run git commands:
git diff --staged git log -5 --oneline -
Analyze the diff:
- What files changed?
- What's the nature of changes (new feature, bug fix, refactor)?
- Is there a clear single purpose?
-
Check commit history:
- Do they use conventional commits?
- Any special patterns or conventions?
-
Generate message:
- Choose the appropriate type
- Write a concise subject
- Add body only if needed
-
Return: Provide the message as a code block ready to use
Examples
Example 1: Simple feature
Staged: New login component
Message: feat: add JWT-based login component
Example 2: Bug fix with context
Staged: Fix in error handler
Message: fix: prevent null pointer in async error handler
Adds null check before accessing error.stack property to avoid
crashes when error object is malformed.
Example 3: Refactoring
Staged: Extract functions
Message: refactor: extract database queries to repository layer
Example 4: Documentation
Staged: README updates
Message: docs: add installation instructions for Windows
Key Principles
- Atomic commits - One logical change per commit
- Present tense - Always use present tense verbs
- Be concise - Subject line under 50 chars
- Be specific - Avoid vague terms like "update", "fix stuff"
- Conventional format - Always use type prefix
- No redundancy - Don't repeat information from the diff
- Focus on why - Explain motivation, not implementation details
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-01-26
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!