Finalize a completed task by rebasing onto main, fast-forwarding main, updating UNIFIED_PLAN.md, and providing cleanup instructions.
Finalizes completed tasks by rebasing onto main, updating the plan file, and providing cleanup instructions.
/plugin marketplace add cyotee/cyotee-claude-plugins/plugin install cyotee-backlog-plugins-backlog@cyotee/cyotee-claude-pluginsFinalize a completed task by rebasing onto main, fast-forwarding main, updating UNIFIED_PLAN.md, and providing cleanup instructions.
Arguments: $ARGUMENTS
Verify worktree context:
git branch --show-current
git worktree list
Determine task number:
Question: "Which task number is being completed?"
Header: "Task"
Options: List active tasks from UNIFIED_PLAN.md (status = "In Progress" or "Ready for Agent")
Check for uncommitted changes:
git status --porcelain
Fetch latest main:
git fetch origin main
Rebase onto main (unless --no-rebase specified):
git rebase origin/main
Rebase conflicts detected. Please resolve manually:
1. Fix conflicts in the listed files
2. git add <resolved-files>
3. git rebase --continue
4. Re-run /backlog:complete
Fast-forward main to current HEAD:
git branch -f main HEAD
Push main to origin (if --push specified):
git push origin main
Update UNIFIED_PLAN.md:
| Task N | `<branch-name>` | ✅ Complete (merged to `main`) |
../../UNIFIED_PLAN.md or find via git root../../../../UNIFIED_PLAN.md (in IndexedEx root)Get cleanup information:
BRANCH=$(git branch --show-current)
WORKTREE_PATH=$(pwd)
Output completion summary:
# Task N Completed Successfully
## Summary
- Task: N - <title>
- Branch: <branch-name>
- Commits rebased onto main: <count>
- Main updated to: <short-sha>
- Pushed to origin: [yes/no]
- UNIFIED_PLAN.md updated: yes
## Cleanup Required
Run from the main worktree (or any directory outside this worktree):
```bash
git wt -d <branch-name>
Or manually:
cd <parent-directory>
rm -rf <worktree-path>
git worktree prune
git branch -d <branch-name>
## Arguments Reference
| Argument | Description |
|----------|-------------|
| `<task-number>` | Optional task number being completed (prompts if not provided) |
| `--push` | Push main to origin after fast-forward |
| `--no-rebase` | Skip rebase, just fast-forward main (use if already rebased) |
## AskUserQuestion Format
When no task number is provided, ask:
Question: "Which task number is being completed?" Header: "Task" Options: (dynamically built from UNIFIED_PLAN.md)
## Error Handling
- **Not in worktree:** "This command must be run from a feature worktree, not main"
- **Uncommitted changes:** "Uncommitted changes detected. Please commit or stash before completing."
- **Rebase conflicts:** Show resolution steps and abort
- **Push fails:** Show error and suggest manual push
- **Main has diverged:** Warn and suggest `--no-rebase` if intentional
- **Task not found:** Show available task numbers
- **UNIFIED_PLAN.md not found:** Search parent directories or ask user
## Important Notes
- **Cannot self-delete:** An agent cannot delete its own worktree while running inside it. The cleanup must be performed from outside.
- **Task numbers persist:** Do not renumber tasks in UNIFIED_PLAN.md after completion
- **Branch naming:** The branch name should match the task's "Worktree:" field in UNIFIED_PLAN.md
- **Plan file location:** UNIFIED_PLAN.md lives in the main IndexedEx repo, not in submodule worktrees
## Example Session
$ /backlog:complete 3 --push
Verifying worktree context... Current branch: feature/uniswap-v4-utils Worktree: /path/to/crane-wt/feature/uniswap-v4-utils
Task: 3 - Uniswap V4 Utils Library
Checking for uncommitted changes... Working tree clean
Fetching latest main... From origin
Rebasing onto main... Successfully rebased 3 commits
Updating main to current HEAD... main -> abc1234
Pushing main to origin... main -> origin/main
Updating UNIFIED_PLAN.md... Task 3 status: ✅ Complete Worktree status table updated
Run from the main worktree:
git wt -d feature/uniswap-v4-utils
## Example Without Task Number
$ /backlog:complete --push
Verifying worktree context... Current branch: feature/uniswap-v4-utils
[AskUserQuestion: Which task number is being completed?] Options:
User selects: Task 3
Proceeding with Task 3... [rest of completion flow]