Files
claude-plugins/plugins/workflow/commands/push.md
Claude Agent 45e28e7e94 feat(workflow): Add workflow plugin v1.0.0
Git workflow, code quality, context management and testing commands:
- commit, push, pr, issue - git operations
- simplify, refactor, verify, check - code quality
- catchup, onboard, save, cleanup - context management
- test, format, sync - development utilities

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 15:23:48 +00:00

2.1 KiB

description: Push to remote with safety checks argument-hint: [remote] [branch] - Optional remote and branch (defaults to origin and current branch)

Safe Push

Pre-computed Context

Current Branch: !git branch --show-current

Upstream Branch: !git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null || echo "No upstream configured"

Commits to Push: !git log --oneline @{u}..HEAD 2>/dev/null || echo "No upstream or no commits to push"

Local vs Remote: !git status -sb | head -1

Uncommitted Changes: !git status --porcelain | wc -l | xargs -I{} sh -c 'if [ {} -eq 0 ]; then echo "Working tree clean"; else echo "{} uncommitted changes"; fi'


Instructions

You are pushing commits to the remote repository with safety checks.

1. Pre-flight Checks

Before pushing, verify:

  • No uncommitted changes: Ensure everything is committed
  • Not pushing to protected branch: Warn if pushing directly to main/master
  • Upstream configured: Set upstream if needed

2. Protected Branch Warning

If current branch is main or master:

WARNING: You are pushing directly to the main branch.
Consider creating a feature branch and PR instead.
Continue? [y/N]

3. Set Upstream (if needed)

If no upstream is configured:

git push -u origin $(git branch --show-current)

4. Execute Push

Standard push:

git push

With explicit remote/branch:

git push origin <branch>

5. Verify

After push, show status:

git status -sb

Safety Rules

NEVER run these without explicit user request:

  • git push --force
  • git push --force-with-lease
  • git push -f

If push is rejected:

  1. Run git fetch to see remote state
  2. Explain the divergence
  3. Suggest: git pull --rebase then push again
  4. Only suggest force push if user explicitly asks

Common Scenarios

First push of new branch:

git push -u origin feature/my-branch

Push after rebase (requires user confirmation):

# Only with explicit user approval:
git push --force-with-lease

Push to different remote:

git push upstream main