Standalone tool skill. Anyone can call it. When to commit, which files to commit, and the key points of the commit message are given by the caller; this skill is only responsible for how to commit.
Goal
Complete the Git commit according to the mode. In interactive mode, you may ask again whether to push; in auto mode, only do a local commit.
Mode
- Interactive(default): the user explicitly requests a commit or push.
- auto: the caller specifies auto. Local
git add+git commit,push prohibited, do not ask whether to push.
Unified tool definition
交互式提问: a type of tool built into most Agents, a tool by which the Agent asks the user questions and provides options and custom input; its name varies across different Agents, and it may be calledAskUserQuestionorAskQuestion, etc. In auto mode, do not use it to ask whether to push.
Interactive mode
- Check
git status/git diff/git log, understand the intent of the changes. - Determine whether it contains secrets or content that should not be committed, and use the
交互式提问tool to confirm with the user. - Organize the changes into one or more logical commits; do not cram unrelated changes into one commit.
- Follow the commit specification to write the Chinese commit message.
- After confirming it is safe,
git addandgit commit. Do not--no-verify。 - use the
交互式提问tool to ask whether to push; only if neededgit push。
auto mode
git status: no tracked changes and no new files that should be committed → report "no commit", end.- If
.env, secrets, credentials, or files that clearly should not be committed are found → stop, do not commit, list them to the user. Do not ask a question to pass the risk by. - Staging scope: if the caller specifies paths, stage only those paths; if not specified, stage only the files that should be committed in this round. Do not casually include unrelated dirty files. Do not force-add paths that are already gitignored.
- One logical commit; follow the commit specification to write the Chinese message. If the caller provides key points for the commit message, use them; otherwise write according to the actual diff.
git addspecified path +git commit. Do not--no-verify. Do notgit push。- Report the commit hash, and state clearly that it has not been pushed.
Commit specification
<类型>(<范围>)!: <描述>
[可选的正文]
[可选的脚注]
Core specification
- Commit messages must be written in Chinese
Title
- Use the imperative mood or a concise verb phrase
- Describe "what was done", avoid vague descriptions
- Try to keep it within 50 characters
Body
- Explain why it was changed, not just what was changed
- Explain important implementation trade-offs
- Mention behavior changes, compatibility impacts, and migration matters
- Try to keep each line within 72 characters
Footer
For breaking changes use:
破坏性变更: <描述破坏性变更的内容>
Commit type
| Type | Description |
|---|---|
feat |
New feature |
fix |
Bug fix |
docs |
Documentation changes |
style |
Code formatting changes, no logic impact |
refactor |
Refactoring, no new features and no bug fixes |
perf |
Performance optimization |
test |
Test-related |
build |
Build system or dependency changes |
ci |
CI/CD configuration changes |
chore |
Routine maintenance, miscellaneous |
revert |
Revert commit |