/batch-implement — Full Issue Resolution Loop
/batch-implement 4703 4704 4705 # explicit issue numbers
/batch-implement --label bug # all open issues with label
/batch-implement --label bug --limit 9 # cap at N
Core rule: Agents commit locally. Main session always pushes. Batch size: 3 agents max.
Step 0: Umbrella Issue
- Ensure a GitHub umbrella issue exists with a task checklist (one checkbox per batch item).
- As each item lands (PR merged + issue closed), check it off on the umbrella issue.
- Create the umbrella if missing:
gh issue create --title "Batch: <label/description>" --body "- [ ] #N ..." - Attach every batch item to the umbrella as a native sub-issue, not just a checkbox:
gh api -X POST repos/$REPO/issues/$PARENT/sub_issues -F sub_issue_id=$(gh api repos/$REPO/issues/$CHILD -q .id)
Step 1: Pre-Flight
git branch --show-current— must beDev_new_gui. STOP if not.git status --porcelain— must be empty. STOP if not.- Resolve issue list:
gh issue list --label <label> --state open --json number -q '.[].number' - Skip if already in Dev_new_gui:
git log origin/Dev_new_gui --oneline --grep="#<n>" | head -1 - Skip if already closed:
gh issue view <n> --json state -q '.state' - Clean stale worktrees:
git worktree remove .worktrees/issue-<n> --force && git branch -D issue-<n>
Print summary before proceeding:
Pre-flight: To implement: #N, #M | Skipped: #K | Cleaned: N worktrees
Step 2: Worktree Setup (per issue)
git worktree add .worktrees/issue-<n> -b issue-<n> origin/Dev_new_gui
cd .worktrees/issue-<n> && git branch --unset-upstream
- Agents MUST work inside the worktree — NEVER
git checkouton the main tree. - Each issue gets its own branch
issue-<n>.
Step 3: Dispatch Agents (batches of 3)
Track state per issue: PENDING | IN_FLIGHT | SUCCESS | SUCCESS_TESTS_FAILING | RETRY_QUEUED | ESCALATED | SKIPPED
Each agent must:
- Read the issue AND every comment — they routinely carry the decisive
context: criteria agreed after filing, a blocker found later, a prior attempt
parked. Use the
--jsonform; baregh issue viewand--commentsexit 1 on an oldergh(retiredprojectCardsfield in their render query).gh issue view <n> --json title,body,comments \ -q '"# \(.title)\n\n\(.body)\n\n--- comments ---\n" + ([.comments[]|"@\(.author.login): \(.body)"]|join("\n\n"))' - Implement the fix inside the worktree.
git commit -m "<type>(<scope>): <desc> (#<n>)"— commit only, no push.- Report:
RESULT: SUCCESS|FAILURE | COMMIT_SHA: <sha> | TESTS: PASS|FAIL | ERROR: <if any>
Agent prompt must include worktree isolation instructions (NEVER git checkout on main tree).
Self-healing failure table:
| Failure type | Auto-heal |
|---|---|
| API 529 overload | Wait 60s, retry (max 3×) |
| Merge conflict at push | Rebase onto latest Dev_new_gui, retry |
| Already resolved | Mark SKIPPED, close worktree |
| Agent crash / timeout | Retry (max 3×) |
| Tests failing | Mark SUCCESS_TESTS_FAILING — manual review |
| Unresolvable after 3× | ESCALATE — preserve worktree, print manual steps |
Repeat batches until all issues are SUCCESS, SKIPPED, or ESCALATED.
Step 4: Pre-Push Verification (every PR before push)
# Re-fetch and abort if issue already closed during session
git fetch origin Dev_new_gui -q
gh issue view <n> --json state -q '.state' # CLOSED → abort
# Type-check (frontend)
cd autobot-frontend && npx vue-tsc --noEmit -p tsconfig.app.json
# Tests for affected files
npx vitest run src/.../__tests__/<relevant>.test.ts
# or: pytest autobot-backend/<path> -xvs
# Extraction PRs only — behavioral grep audit (before/after; after-count must be 0)
grep -rnE "<behavior-pattern>" autobot-frontend/src --include="*.vue"
Push only after all checks pass: git push -u origin issue-<n>
Step 5: Create & Review PR
gh pr create --base Dev_new_gui --head issue-<n> --title "..." --body "..."
- Syntax/imports:
python -m py_compile <file>for Python;vue-tscfor TS/Vue. - Call-site impact: grep that nothing removed is still called elsewhere.
- Wiring check: any new public module must have ≥1 production caller — HARD BLOCK if 0.
- Linting:
python -m black --check <files>
Fix inline and re-push if validation fails. Never merge a failing PR.
Step 6: Merge
gh pr merge <pr> --squash --delete-branch
git fetch origin && git log origin/Dev_new_gui --oneline --grep="#<n>" | head -1 # confirm
Merge one at a time. Verify before moving to next.
Step 7: Close with Proof
gh issue close <n>
gh issue comment <n> --body "Closed — merged to Dev_new_gui. Commit: <sha>. Criteria met: <evidence>. Discoveries: <#N or none>"
Check off the item on the umbrella issue.
Step 8: Discovery Issues
gh issue create --title "discovery(<area>): <gap found>" --body "<file:line, what's missing>" --label "tech-debt"
# then attach it to the umbrella it was discovered under
gh api -X POST repos/$REPO/issues/$PARENT/sub_issues -F sub_issue_id=$(gh api repos/$REPO/issues/$CHILD -q .id)
File before cleanup. Include in closure comment.
Step 9: Cleanup & Summary
git worktree remove .worktrees/issue-<n> --force # SUCCESS issues only; preserve ESCALATED
gh pr list --state open # should be 0 for this batch
git worktree list # should show only main
Print final table:
| Issue | PR | Status | Discoveries |
| #4703 | #4720 | MERGED | #4725 |
| #4706 | — | ESCALATED | — |
Escalated: preserve worktree, print manual rebase steps for the user.
Invariants
- Main session stays on
Dev_new_gui— never switches branches. - Agents commit only — main session pushes.
- Never merge without review; never close without proof (commit hash + criteria).
- Never leave PRs open overnight; never leave discoveries untracked.
- Escalated worktrees are preserved — never auto-delete.
- Anti-polling: if session must exit before all PRs merged, set issue to
in_review, post one comment listing open PRs, schedule one wake-up — do not spin.