This is the complete ordered flow for picking up an issue, implementing it, and shipping a PR. This workflow is designed for AI-assisted development using Claude Code.
Autonomous mode: This workflow can run fully autonomously. The agent should use its own judgment on trade-offs, pick the simpler approach, and keep moving. Interactive gates (plan approval, mark-ready, cleanup) have timeouts — if no human responds within 10 minutes, auto-approve and proceed. When invoked from a cron/background agent, skip all interactive gates entirely.
Before any work begins, ensure you are on the correct branch, synced with upstream, and set up a worktree for the issue.
git branch --show-current
git status
git worktree listShow the user which worktrees exist and which branches they're on. If the user wants to resume work on an existing worktree, cd into it and skip to the relevant step.
If you are NOT on the default branch, STOP and ask the user. Show them:
- Current branch name
- Whether there are uncommitted/staged changes
- Number of commits ahead/behind
- Options:
- Stash changes + switch to default branch
- Commit current work + switch
- Abandon changes
- Continue working on the current branch (skip the rest of Step 0)
Do NOT silently switch branches or proceed — wait for explicit instruction.
Once on the default branch, fetch upstream and rebase:
git fetch $UPSTREAM # "upstream" if fork, "origin" otherwise
git rebase $UPSTREAM/$DEFAULT_BRANCH
git push origin $DEFAULT_BRANCHIf the rebase has conflicts, STOP and ask the user — do not auto-resolve.
Instead of branching in-place, create a git worktree so you can work on multiple issues in parallel without stashing or switching branches.
# Convention: ../<project>-<issue-number> with branch fix/<desc> or feat/<desc>
git worktree add ../<project>-<issue-number> -b <type>/short-description
cd ../<project>-<issue-number>
# Worktrees do NOT inherit submodules — init them explicitly
git submodule update --init --recursive
# Copy env files from main repo if needed
cp ../<project>/.env .env 2>/dev/null
# Install dependencies
<package-manager> installFrom this point forward, all work happens inside the worktree directory.
To start a second issue, open a new terminal and repeat 0c with a different issue number. Each worktree is fully independent.
Ask the user:
"Do you want to work on one of your assigned issues, or pick an unassigned one?"
gh issue list --repo <owner/repo> --assignee <username> --state open
gh issue view <number> --repo <owner/repo>Run the selection funnel:
- Fetch all unassigned open issues
- Filter by complexity — drop hard/large-scope items
- Filter by description quality — drop issues with < ~2k chars body
- Filter by priority — prefer high > medium > low > unlabeled
- Select top candidate and show the user
- User confirms — assign the issue
See: 01-picking-up-an-issue.md
Before implementation, read project instructions and recent history:
CLAUDE.mdfor project rules, patterns, conventions.claude/memory.mdfor institutional knowledge- Recent commits (
git log --oneline -20)
Run /brb-architectobot to read the issue, explore the codebase, and produce an implementation plan. Present the plan and wait up to 10 minutes for user approval. No response = auto-approved.
See: 02-working-on-an-issue.md — Phase 1 & 2
Skip for simple/obvious bugs (missing fields, classifier updates, config fixes, 1-3 file changes). Only run for new features, large refactors, or changes to shared state/UI components.
When running: check for existing code, affected consumers, persistence concerns, test breakage. Use Sonnet to save tokens.
Run /brb-codecrusher to write the code changes per the approved plan.
See: 02-working-on-an-issue.md — Phase 3
< 4 acceptance criteria: skip architectobot — cross-checks in Step 5 are enough. 4+ acceptance criteria: re-run architectobot (Sonnet) to verify each criterion. Complex features have non-code requirements that automated checks miss.
Auto-detect and run available quality checks:
- TypeScript: typecheck, lint, format, build
- Rust:
cargo fmt --check,cargo check(NOTcargo build— too slow, eats disk) - Any project-specific checks from package.json
See: 03-cross-checking.md and 04-pre-commit-checks.md
Before committing, capture learnings from the session into .claude/memory.md (if the project uses it).
git add <specific-files>
git commit -m "type(scope): short description
Closes #N"git fetch origin <default-branch>
git merge origin/<default-branch>Resolve any conflicts. For lockfiles: checkout theirs and regenerate.
Always create PRs as drafts.
git push -u origin <branch-name>
gh pr create --repo <owner/repo> --base <default-branch> --draft \
--title "type: short description" \
--body "..."See: 05-raising-a-pr.md
After PR creation, run through all three sub-steps. Repeat until clean.
Process every comment individually. Verify, fix if valid, reply.
All checks must be green. Fix failures locally, commit, push.
Resolve any conflicts with the default branch.
Keep looping 10a -> 10b -> 10c until the PR is fully clean. Do not stop early.
After the review cycle is complete, ask the user. If no response within 10 minutes, auto-mark as ready. In autonomous mode, mark ready immediately.
Ask the user whether to remove the worktree or keep it. Never auto-remove worktrees — always wait for explicit confirmation.
However, after 10 minutes, automatically clean build artifacts to free disk:
rm -rf <worktree>/target # Rust build artifacts (5-15GB each)
rm -rf <worktree>/node_modules # Node dependencies
rm -rf <worktree>/app/node_modulesThis keeps the source code and git history intact but reclaims disk space immediately. The user can still review code, diffs, and branches — they just need to cargo check / pnpm install again if they want to rebuild.
| Step | Action | Tool |
|---|---|---|
| 0 | Worktree setup + upstream sync | git worktree, git fetch/rebase |
| 1 | Pick issue | gh issue list/view |
| 1.5 | Get context | Read CLAUDE.md, git log |
| 2 | Understand & plan | /brb-architectobot (Sonnet) |
| 2.5 | Deep audit (skip for obvious bugs) | Sonnet, only when needed |
| 3 | Implement | /brb-codecrusher (Opus) |
| 4 | Verify | Cross-checks only (+ Sonnet if 4+ acceptance criteria) |
| 5 | Run checks | /brb-cross-check |
| 6 | Update memory | /brb-memory-keeper |
| 7 | Commit | git add, git commit |
| 8 | Merge default branch | git fetch/merge |
| 9 | Push & draft PR | git push, gh pr create --draft |
| 10 | PR review cycle | comments + CI + conflicts loop |
| 11 | Mark ready (10-min timeout, auto in autonomous) | gh pr ready |
| 12 | Worktree cleanup (ask user, auto-clean builds after 10 min) | git worktree remove |