/push - Git Workflow Orchestrator
Handles the complete git workflow: commit → push → create/update PR.
Workflow
1. Validate Current Branch (CRITICAL - do first)
git branch --show-current
- If on staging/main/production/master: STOP and error - cannot commit to protected branches
- If on feature branch: Continue
2. Handle Uncommitted Changes
Check for changes:
git status
If changes exist:
- Review what files changed
- Stage appropriate files (prefer specific files over
git add .) - Create commit with conventional format:
feat(scope): description- new featurefix(scope): description- bug fixchore(scope): description- maintenancedocs(scope): description- documentationrefactor(scope): description- code restructuretest(scope): description- tests
Run pre-commit checks:
- No secrets/API keys in code
- No debug console.log statements
- No commented-out code blocks
3. Push to Remote
# Check for unpushed commits
git log origin/$(git branch --show-current)..HEAD
# Push (set upstream if new branch)
git push origin $(git branch --show-current)
# or for new branches:
git push -u origin $(git branch --show-current)
4. Handle Pull Request
Check if PR exists:
gh pr list --head $(git branch --show-current)
If no PR exists: Launch git-pr-manager agent to create PR
- Target staging/develop (not main/master)
- Generate description from commits
- Include summary and test instructions
If PR exists: Report that PR was updated with new commits
5. Provide Summary
Report:
- What was committed
- What was pushed
- PR status (created/updated)
- PR URL
- Next steps
Usage
/push # Commit all changes with auto-generated message
/push "add auth feature" # Commit with specific message
Important Rules
- NEVER commit to protected branches (staging, main, production, master)
- Always validate branch first
- Use conventional commit format
- Target staging/develop for PRs (not main)
- Don't stage sensitive files (.env, credentials)