Git Operator
This skill defines procedures for Git operations.
Staging
Stage only task-related files. Do not use git add . or git add -A without explicit confirmation.
git status # Run this first
git add <file> # Stage specific files
Before staging, verify:
- No secrets (.env, credentials.json, API keys)
- No unrelated changes included
Branch Creation
Branch names must be in kebab-case.
Good: add-user-authentication, fix-login-bug, update-readme
Bad: addUserAuthentication, Add_User_Auth, ADD-USER-AUTH
git switch -c <branch-name>
Commit
Follow Conventional Commits format.
<type>(<scope>): <description>
[optional body]
Types
feat: New featurefix: Bug fixdocs: Documentation only changesstyle: Changes that do not affect the meaning of the coderefactor: Code changes that neither fix a bug nor add a featureperf: Code changes that improve performancetest: Adding or modifying testsbuild: Changes that affect the build system or external dependenciesci: Changes to CI configuration files or scriptschore: Other changes (not modifying src or test)
Procedure
Analyse staged changes to create a message focusing on "why" rather than "what".
git diff --cached # Review staged changes
git commit -m "<type>(<scope>): <description>"
Good example:
fix(auth): prevent session timeout on mobile
Users reported being logged out after 5 minutes on mobile.
Root cause was incorrect token refresh interval.
Bad example:
fixed bug
For multi-line messages, use HEREDOC:
git commit -m "$(cat <<'EOF'
<type>(<scope>): <description>
<body>
EOF
)"
Push
Pre-push Verification
Run these commands before pushing:
git log --oneline -5 # Verify recent commits
git branch -vv # Verify current branch and tracking
git status # Ensure working directory is clean
Proceed only after reviewing the output.
Procedure
For new branches:
git push -u origin <branch-name>
For existing remote tracking branches:
git push