Prompt file imported from yortyrh/resubuild (
.cursor/commands/opsx-parallel-integrate.md). Copyright stays with the author.
Integrate one finished OpenSpec parallel change. After integration, remaining worktrees are rebased onto updated main so the next change starts from current code.
Input (after /opsx-parallel-integrate):
| Flag | Meaning |
|---|---|
| (empty) | Interactive: pick change + mode |
--change <name> |
Integrate this change only |
--next |
First completed, not-yet-integrated change (plan batch order, then name) |
--mode merge |
Merge to main, rebase sibling worktrees |
--mode pr |
Push branch + gh pr create with mermaid diagrams (no merge) |
--rebase-only |
Skip merge/PR; rebase all active sibling worktrees onto current main |
--no-rebase-siblings |
Merge/PR without touching other worktrees |
--delete-worktree |
After successful merge, remove integrated worktree (branch kept unless merged) |
--dry-run |
Print actions, mutate nothing |
Steps
-
Load context
test -f .cursor/agents/state/parallel-plan.json || echo "MISSING_PLAN" git worktree list --porcelain test -f .cursor/agents/state/parallel-integration.json && cat .cursor/agents/state/parallel-integration.jsonIf no worktrees under
.worktrees/, stop: "Nothing to integrate. Run/opsx-launch-parallelfirst." -
Resolve target change
--change <name>→ use it; error if worktree missing--next→ scan.worktrees/*in plan batch order; pick first where:- all
tasks.mdcheckboxes are[x] - branch has at least one commit ahead of
baseRef - change not listed in
parallel-integration.jsonas merged or with open PR merged
- all
- Otherwise → run
/opsx-parallel-status, then AskUserQuestion: which completed change +mergevspr
-
Pre-flight checks (main repo)
git status --porcelain git rev-parse --abbrev-ref HEADMain repo must be clean. On non-
mainbranch, warn and ask to continue.For
--mode mergeor interactive merge choice:cd .worktrees/<change> git status --porcelain grep -cE '^- \[ \]' openspec/changes/<change>/tasks.md # must be 0 git log -1 --oneline -
--rebase-onlyshortcutSkip implementer subagent. From main repo, for each
.worktrees/*except optionally--change:git -C .worktrees/<sibling> rebase mainOn conflict: stop, report file list, suggest resolving in that worktree. Update
parallel-integration.jsonwith rebase results. -
Spawn integrator subagent
Use Task tool with
subagent_type:opsx-parallel-integrator(foreground — block on result).Prompt JSON:
{ "change": "<name>", "branch": "opsx/<name>", "worktreePath": ".worktrees/<name>", "absoluteWorktreePath": "<git rev-parse --show-toplevel>/.worktrees/<name>", "baseRef": "main", "mode": "merge" | "pr", "push": true, "rebaseSiblings": true, "deleteWorktreeAfterMerge": false }Map CLI flags:
--no-rebase-siblings→"rebaseSiblings": false;--delete-worktree→"deleteWorktreeAfterMerge": true. -
Handle integrator result
status Action completed+ mergeShow merge SHA; list rebased siblings; warn on failedRebasescompleted+ prShow PR URL; remind that siblings rebase after PR merges ( --rebase-only)conflictPrint conflicted paths; stop pipeline blockedIncomplete tasks — resume implementer instead failedShow verify/errors -
Suggest next step
## Integration Complete **Change:** <name> **Mode:** merge | pr **Result:** <merge sha or PR URL> ### Siblings rebased onto main - change-b ✓ - change-c ✗ (conflict in cv-sections.tsx — resolve in .worktrees/change-c) ### Next - Integrate next change: `/opsx-parallel-integrate --next --mode merge` - Or open PR instead: `/opsx-parallel-integrate --change <name> --mode pr` - Status: `/opsx-parallel-status` - After all merged: `/opsx-parallel-cleanup --all-merged`
Recommended loop (batch finished → land one-by-one)
/opsx-launch-parallel --batch 1
/opsx-parallel-status
/opsx-parallel-integrate --next --mode merge # repeat until batch empty
/opsx-launch-parallel --batch 2 # siblings already on latest main
PR-first workflow (review before merge)
/opsx-parallel-integrate --change auto-generated-cv-title --mode pr
# after PR merges on GitHub:
git checkout main && git pull
/opsx-parallel-integrate --rebase-only
/opsx-parallel-integrate --next --mode merge
Guardrails
- Integrate one change at a time — never merge two branches in one invocation
- Never auto-resolve merge/rebase conflicts
- Merge mode: never push
mainunless user explicitly asks - PR mode: may push feature branch only; PR body must include ≥1 mermaid diagram
- After merge mode, sibling rebase is default — this keeps parallel work aligned with
main - Read
.cursor/skills/openspec-parallel-integrate/SKILL.mdfor PR template and diagram guidance
