Git Workflow
Overview
Complete git workflow covering commit requirements, push automation, safety rules, commit message formatting, and verification integration.
Core Principles
- Commit after each completed task/feature (following verification)
- Push to remote immediately after every commit
- Only non-destructive git operations allowed
- All code commits require verification first
- Never add Claude or agent attribution to commits
Branch Management
When starting new work:
- Check current branch:
git branch --show-current - If on main/master: Create new branch from spec name (e.g.,
04-add-auth-middleware) - Otherwise: Use current branch as-is
Workflows
Code Changes (with Verification)
- Implementation agent completes task/feature and reports to Main Agent
- Main Agent spawns Verification Agent
- Verification Agent runs all checks
- If all pass:
git add [files]→git commit→git status→git push→ verify - If any fail: Create urgent task, do NOT commit
Non-Code Changes
- Make changes
git add [files]→git commit→git status→git push→ verify
Commit Message Format
Brief summary (50 chars max)
Detailed explanation of what and why.
Changes made:
- Change 1
- Change 2
[Verification status for code changes]
Co-Authored-By: Claude <noreply@anthropic.com>
Code example:
git commit -m "$(cat <<'EOF'
Add authentication middleware
Implemented JWT-based authentication middleware to secure API
endpoints. Validates tokens and attaches user info to requests.
Changes made:
- Created auth.js middleware with token validation
- Added JWT verification using jsonwebtoken
- Implemented error handling for invalid/expired tokens
Verified by JavaScript Verification Agent: All checks passed
- Format: PASS (prettier)
- Lint: PASS (eslint, 0 warnings)
- Tests: 12/12 PASS
- Build: PASS
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"
Non-code example:
git commit -m "$(cat <<'EOF'
Update installation instructions
Added Docker setup steps and clarified dependency requirements.
Changes made:
- Added Docker installation section
- Updated prerequisites list
- Fixed typos in quick start guide
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"
Safety Rules
Forbidden Operations
git push --force/-f(except commit correction with--force-with-lease)git reset --hardgit reset --soft HEAD~N(except commit correction)git rebase -igit commit --amend(except specific cases)- Any history-rewriting operations
Allowed Operations
git add,git commit,git status,git push(standard)git pull,git fetch,git log,git diffgit branch,git checkout,git stash,git merge(non-force)
Commit Correction Pattern
For just-committed features needing immediate fix:
git reset --soft HEAD~1(keeps changes staged)- Make the fix
git add [files](re-stage all)git commit -m "..."(recommit complete feature)git pushorgit push --force-with-lease(if already pushed)
Use only when:
- Just committed (1-2 commits ago)
- No other commits after
- On feature branch (not main)
Special Cases
Merge Conflicts
git pullto fetch remote changes- Resolve conflicts
git add [files]→git commit→git push
First Push to New Branch
Use git push -u origin branch-name for first push to set upstream
Network/Protection Issues
Report to user if push fails due to network issues or branch protection. Do not retry indefinitely or use --force.
Main Agent Responsibilities
When receiving completion reports from sub-agents:
- Check if sub-agent pushed
- If not confirmed: Run
git statusto check for unpushed commits - If unpushed: Remind sub-agent and wait for push confirmation
- Then continue workflow
Detection: git status shows "ahead of origin" or git log origin/main..HEAD shows unpushed commits
Version History Management
- All version history goes in
.agents/CHANGELOG.md - Individual files show only current version and link to changelog
- When updating files: Update file + add CHANGELOG entry + commit both together
Enforcement
Must Do
- Commit after task/feature completion (with verification for code)
- Push automatically after every commit
- Use detailed commit messages with bullet points
- Include verification status for code changes
- Verify commit and push succeeded
Must Not Do
- Ask for approval before commit/push
- Commit incomplete tasks/features
- Batch multiple tasks into one commit
- Use forbidden git operations
- Commit code without verification
- Skip push after commit
- Add agent attribution (no "Claude" in commit messages)
Critical Violations
- Committing code without verification
- Committing code with failed verification
- Missing verification status in code commits
- Force push or destructive operations
Corrective Action
Stop immediately → Revert if needed → Run proper verification → Re-commit correctly → Document in Learning Log
Version: 1.1 - Last Updated: 2026-02-27