Create a git commit, supporting a specified message or automatic generation.
Current repository status
!`git status`
Staged diff
!`git diff --staged`
Steps
- Based on the above
git statusoutput, determine:- If there are no staged changes → prompt the user to first
git add,end immediately - Strictly prohibitedto execute without the user's explicit request
git add(in any form), includinggit add .、git add -A、git add <file>
- If there are no staged changes → prompt the user to first
- Based on the above
git diff --stagedoutput, generate a commit message (pure reasoning, do not call any commands):- If
$ARGUMENTSis provided → use it directly - Otherwise → analyze the diff and generate a message conforming to Conventional Commits
- If
- Must call the Bash toolExecute:
git commit -m "<message>"(simulated output is prohibited) - Must call the Bash toolExecute:
git show --stat --pretty=format:"✓ Committed: %s (%h)" -1, show the real output to the user
Commit Message Format
Format:<type>[optional scope]: <description>
Common types:
feat— new feature (triggers a minor version)fix— Bug fix (triggers a patch version)docs— documentation changesstyle— code formatting (does not affect logic)refactor— refactoring (not feat/fix)perf— performance optimizationtest— test-relatedbuild— build system/dependenciesci— CI configurationchore— other miscellaneousrevert— revert
Rules:
- Concise but descriptive, the first line must not exceed 72 characters
- scope is optional:
feat(auth): add OAuth2 login - Breaking change: add after the type
!or write in the footerBREAKING CHANGE: <描述>
Example:
feat: add user authentication with JWTfix(api): handle null response from upstreamfeat!: remove deprecated /v1/users endpoint
Output
Directly display the real Bash output from Step 4; do not manually concatenate or simulate it.