Commit Message Generator
Help the user generate a conventional commit message for their current changes.
Instructions
Analyze Changes:
- Run
git diff --cachedto see staged changes. - If no output, run
git diffto see unstaged changes. - If still no output, inform the user there are no changes to commit.
- Run
Determine Language:
- Check the user's request for language preference (e.g., "commit English", "commit 中文").
- If explicitly requested, use that language.
- If not specified, default to English.
Generate Message:
- Create a single-line commit message following the Conventional Commits format:
<type>: <description> - Types:
feat: New featurefix: Bug fixdocs: Documentation onlystyle: Code style changes (formatting, missing semi-colons, etc.)refactor: Code change that neither fixes a bug nor adds a featureperf: A code change that improves performancetest: Adding missing tests or correcting existing testschore: Changes to the build process or auxiliary tools and libraries
- Description:
- Use imperative, present tense (e.g., "change" not "changed" or "changes").
- Be concise but descriptive.
- For Chinese, use natural technical Chinese (e.g., "feat: 新增登录功能").
- Create a single-line commit message following the Conventional Commits format:
Output:
- Present the commit message clearly.
- Optionally, provide the
git commit -m "..."command for easy copying or execution.
Examples
User: "commit" (Default English) Agent:
git commit -m "feat: add user authentication module"
User: "commit 中文" Agent:
git commit -m "fix(auth): 修复令牌过期时的无限重定向问题"
User: "commit style changes" Agent:
git commit -m "style: format code with prettier"