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>
This commit is contained in:
121
plugins/workflow/commands/sync.md
Normal file
121
plugins/workflow/commands/sync.md
Normal file
@@ -0,0 +1,121 @@
|
||||
---
|
||||
description: Pull, rebase, and push in one command
|
||||
argument-hint: [base-branch] - Optional base branch to sync with (defaults to main)
|
||||
---
|
||||
|
||||
# Sync Branch
|
||||
|
||||
## Pre-computed Context
|
||||
|
||||
**Current Branch:**
|
||||
!`git branch --show-current`
|
||||
|
||||
**Base Branch:**
|
||||
!`git remote show origin 2>/dev/null | grep "HEAD branch" | cut -d: -f2 | tr -d ' ' || echo "main"`
|
||||
|
||||
**Uncommitted Changes:**
|
||||
!`git status --porcelain | head -5`
|
||||
|
||||
**Behind/Ahead:**
|
||||
!`git rev-list --left-right --count origin/main...HEAD 2>/dev/null || echo "Unable to compare"`
|
||||
|
||||
**Last Sync:**
|
||||
!`git log -1 --format="%ar" origin/main 2>/dev/null || echo "Unknown"`
|
||||
|
||||
---
|
||||
|
||||
## Instructions
|
||||
|
||||
You are syncing the current branch with the base branch (fetch + rebase + push).
|
||||
|
||||
### 1. Pre-flight Check
|
||||
|
||||
If there are uncommitted changes:
|
||||
```
|
||||
WARNING: You have uncommitted changes.
|
||||
Options:
|
||||
1. Commit them first: /workflow:commit
|
||||
2. Stash them: git stash
|
||||
3. Discard them: git checkout . (destructive!)
|
||||
```
|
||||
|
||||
### 2. Fetch Latest
|
||||
|
||||
```bash
|
||||
git fetch origin
|
||||
```
|
||||
|
||||
### 3. Rebase on Base Branch
|
||||
|
||||
Determine base branch (argument or default to main):
|
||||
```bash
|
||||
git rebase origin/main
|
||||
```
|
||||
|
||||
Or if argument provided:
|
||||
```bash
|
||||
git rebase origin/$ARGUMENTS
|
||||
```
|
||||
|
||||
### 4. Handle Conflicts
|
||||
|
||||
If conflicts occur:
|
||||
```
|
||||
Rebase conflict detected in: <files>
|
||||
|
||||
Options:
|
||||
1. Resolve conflicts manually, then: git rebase --continue
|
||||
2. Abort rebase: git rebase --abort
|
||||
3. Skip this commit: git rebase --skip
|
||||
```
|
||||
|
||||
Show the conflicting files and help resolve.
|
||||
|
||||
### 5. Push Updated Branch
|
||||
|
||||
After successful rebase:
|
||||
```bash
|
||||
git push --force-with-lease
|
||||
```
|
||||
|
||||
Note: `--force-with-lease` is safe because it only overwrites if remote hasn't changed unexpectedly.
|
||||
|
||||
### 6. Report Status
|
||||
|
||||
```
|
||||
Sync complete:
|
||||
- Rebased X commits on origin/main
|
||||
- Pushed to origin/<branch>
|
||||
- Branch is now up to date
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Common Workflow
|
||||
|
||||
```bash
|
||||
# Start of day: sync your branch
|
||||
/workflow:sync
|
||||
|
||||
# Work on feature...
|
||||
# ...
|
||||
|
||||
# End of day: commit and sync
|
||||
/workflow:commit
|
||||
/workflow:sync
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## If Things Go Wrong
|
||||
|
||||
**Rebase conflicts too complex:**
|
||||
```bash
|
||||
git rebase --abort # Return to pre-rebase state
|
||||
```
|
||||
|
||||
**Pushed wrong thing:**
|
||||
```bash
|
||||
git reflog # Find the commit before the mistake
|
||||
git reset --hard <commit> # Only with user approval!
|
||||
```
|
||||
Reference in New Issue
Block a user