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
- 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 a
$ARGUMENTSwas provided → use it directly - Otherwise → analyze the diff and generate a message conforming to Conventional Commits
- If a
- 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, first line no more than 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 show the real Bash output from Step 4; do not manually concatenate or simulate.