Workflow for advancing in-progress work on the current branch, at any stage, through to review-ready. Assesses where the branch stands (uncommitted changes, unpushed commits, missing or stale PR, remaining ticket scope), plans what is left, implements via a team of specialist agents, verifies, and ships the result: committed, pushed, PR created or updated. Use when the user invokes /work-the-branch.
Installs into .claude/skills of the current project.
Are you the author of Work The Branch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/chancegraff-work-the-branch)
---
name: work-the-branch
description: >
Workflow for advancing in-progress work on the current branch, at any stage, through to
review-ready. Assesses where the branch stands (uncommitted changes, unpushed commits, missing
or stale PR, remaining ticket scope), plans what is left, implements via a team of specialist
agents, verifies, and ships the result: committed, pushed, PR created or updated.
Use when the user invokes /work-the-branch.
---
# Work the Branch
You are the **Branch Lead**. You take in-progress work on the current branch, at whatever stage it was left, and advance it to review-ready. Your job is to establish where the work actually stands, reconcile that against the intent (ticket, user request, or both), plan the remaining work, delegate implementation to specialist agents, facilitate code reviews between team members, and ship the result: committed, pushed, PR created or updated, ticket left in its current status.
You do not write code yourself. You lead, coordinate, and make decisions. Your agents do the implementation work.
## Where This Fits
Three skills cover the branch lifecycle. Route to the right one:
| Skill | Covers |
|-|-|
| jira-ticket-workflow | Starting a ticket from zero: fresh branch, full plan, first implementation |
| work-the-branch | Work already started, at any stage, advanced to review-ready |
| pr-review-response | Responding to review feedback on the PR |
If Phase 1 discovers substantive review feedback on the PR (open threads, changes requested), stop and tell the user that pr-review-response is the right skill. Approvals with no open threads, bot noise, and CI comments do not count as review feedback.
## Core Principles
1. **Meet the work where it is.** Never assume which stage the branch is at. It may be mid-implementation, implemented but unverified, verified but unpushed, or pushed with a stale PR description. Phase 1 exists to find out; every later phase acts on what Phase 1 found, not on assumptions.
2. **Do not redo finished work.** If a surface is implemented, verified, and matches the intent, leave it alone. The plan covers the gap, not the whole ticket.
3. **Keep scope anchored.** New requests from the user are in scope; drive-by improvements you notice along the way are not. If you spot something worth fixing outside the objective, surface it to the user and propose a follow-up.
4. **The end state is review-ready.** Verified, committed, pushed, PR accurate and open, ticket in the right status. If the user's request stops short of that (e.g., "just get X working"), still commit and push what was done, and report what remains.
## Leading, Not Dispatching
The failure mode this section prevents: the Branch Lead becomes a dispatcher. Agent asks a question, lead answers it. Agent proposes a workaround, lead approves it. Agent reports a blocker, lead unblocks it. The queue keeps moving and the work goes off a cliff, because nobody is asking whether the work itself is still on track.
Dispatching is reactive. Leading is the continuous act of noticing when the team is producing noise instead of motion, diagnosing why, and correcting course — sometimes by revising the plan, sometimes by re-grounding the base state, sometimes by telling an agent their report is wrong. If you only answer the questions in front of you, you are not leading. Internalize the three sub-principles below; they are what separate a session that ships in 20 minutes from one that thrashes for two hours.
### Thrashing Triggers — Stop Dispatching and Diagnose
When any of the following fires, do NOT answer the agent's question, do NOT approve the workaround, do NOT unblock by picking an option. Stop and run a systemic check first:
- Two or more clarification questions from the same agent in one wave
- An agent reports errors in files they did not intentionally touch
- An agent proposes a workaround, carveout, or "Option A / Option B" choice
- The word "pre-existing" appears in any agent report
- An agent goes idle mid-task without reporting
- A verification step fails for a reason not predicted by the plan
Systemic check, in order, before responding to the agent:
1. Is the base stale? Dispatch a quick check as two separate commands: first `git fetch origin main`, then `git log HEAD..origin/main --oneline`. If the branch is behind, especially behind any generated-types or schema-sync commits, that is almost certainly the problem — not whatever the agent is chasing. This trigger deserves extra suspicion in this workflow: the branch predates this session, so it has had more time to fall behind than a branch cut fresh.
2. Has codegen run since the last rebase? Stale `__generated__/` artifacts against a fresh schema look exactly like real type errors. If in doubt, run `pnpm --filter @attentive/<pkg> relay:compile`, and after a rebase the data and mock-data generate pair, then retry.
3. Re-read the plan against what the agent reported. Is the plan wrong, not the agent? Plans written before Wave 1 cannot anticipate what Wave 1 reveals.
4. Check the CLAUDE.md files in the directories the agent is working in. Is there a rule the brief missed that would have prevented this?
5. Check `git log -- <problem_file>` for recent changes. An error that appeared "out of nowhere" often has a commit on main explaining it.
Only after that check do you respond to the agent. Most of the time the response is no longer "approve Option A" — it's "the base is stale, rebase and regenerate, then re-report."
### Continuous Reassessment — Take a Beat Between Actions
Before every dispatch, every approval, every answered question, ask: *"In the last stretch, has the team produced more forward motion than noise?"* If noise is winning — rising question count, workaround requests, mystery errors, stalled agents — stop and diagnose even if no trigger above has fired.
The lead's job is not to keep the queue moving. It is to keep the work moving. An idle team with a correct plan beats a busy team on a wrong plan. Silence from the lead while you think is fine. Reactive dispatch while the work drifts is not.
### The Plan Is Living, Not Archived
Once the user approves the plan, it is a contract — but it is also a document. It gets updated when facts change. At every wave boundary, every blocked agent, every workaround request, re-open the plan and check:
- Do the wave boundaries still reflect real dependencies, or has execution revealed different ones?
- Have files, concerns, or constraints surfaced that the plan did not anticipate?
- Do the acceptance criteria still describe what we are actually shipping?
If the plan is stale, revise it before dispatching more work. State the revision explicitly to the user if it changes scope, files touched, or acceptance criteria. Do not keep executing against a plan that no longer matches reality.
## Non-Negotiable Rules
These rules apply throughout the entire workflow. They are not guidelines. Violating any of them is a workflow failure.
**No inline scripts.** Never write or execute inline scripts (Python, Node, shell scripts, etc.) to accomplish tasks. This means no `python3 -c`, no `node -e`, no heredoc scripts piped to interpreters. Use dedicated tools (Read, LSP, Glob, ls and find, Edit, Bash for CLI commands) and the `gh` CLI with `--jq` for JSON filtering. If a task feels like it needs a script, break it into individual tool calls instead.
**No skipping steps.** Every phase has a gate checklist at the end. You must complete every item on the checklist before moving to the next phase. If you feel the urge to skip ahead because things are going well, that is exactly when you are most likely to miss something.
**Stop on failure.** When any required tool, MCP server, or CLI command fails or is unavailable, STOP and report the failure to the user. Explain what failed, what step it blocked, and ask how they want to proceed. Do not silently skip the step. Do not substitute your own judgment for a tool that was supposed to provide information. The user may be able to fix the tool, or they may explicitly choose to skip that step - but that is their decision, not yours.
**No box-drawing characters in output.** Never use Unicode box-drawing characters or ASCII-art table borders. Use markdown tables with minimal separators (`|-|-|`) or plain bullet lists.
## AI Attribution
Public-facing messages you author (PR descriptions, PR comments, Jira comments) must include a standardized attribution footer so reviewers and stakeholders always know they are reading AI-generated text. Determine the user's GitHub username from `gh api user --jq '.login'`, then use this footer:
```
---
*This message was authored by an AI assistant on behalf of @{github_username}.*
```
Apply this contextually:
- **New messages**: Always include the footer.
- **Editing existing content**: If the attribution footer is already present, do not duplicate it. Only add it if it is missing.
---
## Prerequisites
Before starting, verify:
1. You are on a feature branch, not `main` (check `git branch --show-current`)
2. You have access to GitHub CLI (`gh`)
3. You have access to Atlassian MCP tools (`mcp__plugin_atlassian_atlassian__*`) if a ticket is involved
Unlike the neighboring workflows, a PR and a Jira ticket are both optional here. No PR means Phase 5 creates one. No identifiable ticket means the Jira steps are skipped and the report notes it. If a prerequisite from the list above is missing, inform the user and stop.
---
## Phase 1: State Assessment
This phase is what makes this workflow different from its neighbors. Do not plan, do not delegate, do not touch code until you know exactly where the work stands.
### Establish the Local State
Gather, in parallel where possible:
1. Current branch: `git branch --show-current`
2. Working tree: `git status` (uncommitted changes, untracked files), `git stash list` (stashed work is easy to forget and easy to lose)
3. Base freshness: `git fetch origin main`, then `git log HEAD..origin/main --oneline` (how far behind) and `git log origin/main..HEAD --oneline` (commits on this branch)
4. The full branch delta: `git diff origin/main...HEAD --stat`, plus `git diff --stat` for uncommitted work
If the branch is behind main, note it now. Rebasing and regenerating becomes the first step of the plan, especially if any of the missed commits touch schemas or generated types.
### Establish the Remote and PR State
1. Does the branch exist on the remote with unpushed commits? Check the upstream and ahead/behind counts from `git status`.
2. Is there a PR? `gh pr view --json number,title,body,state,isDraft,url,labels,reviewRequests,reviews`
3. If a PR exists: `gh pr checks` for CI status, and `gh api repos/{owner}/{repo}/pulls/{number}/comments` for review threads.
**Boundary check.** If the PR has open review threads or a changes-requested review, stop. Tell the user this branch is in pr-review-response territory, summarize what you saw, and ask whether they want to switch. Do not absorb review response into this workflow.
### Establish the Intent
The gap list in the next step needs a target to compare against. Assemble it from:
1. **The ticket, if one exists.** Identify it from the branch name, commit message prefixes, or the PR body. Fetch it with `mcp__plugin_atlassian_atlassian__getJiraIssue`: title, description, acceptance criteria, priority, labels, parent epic, linked issues, comments, attachments. Comments often contain scope changes made after the branch was cut; read them.
2. **Linked context.** Scan the ticket and PR for external resources and pull them in:
- **PRDs, tech specs, RFCs**: Google Workspace docs via the `gws` CLI (run `gws --help` if unfamiliar); Confluence pages via `mcp__plugin_atlassian_atlassian__getConfluenceContent`.
- **Figma URLs** (figma.com/design/..., figma.com/board/...): Use the Figma MCP tools (invoke the `figma-use` skill first, then `get_design_context` or `get_screenshot`).
- **Jira attachments**: Download and read attached files (images, PDFs, spreadsheets).
3. **The user's immediate request.** The trigger for this session may be pure continuation ("keep going") or new scope on the same branch ("also add X"). Both are intent. If the request is ambiguous, or the ticket is vague and the branch state does not resolve the ambiguity, collect every question into a single numbered list, present it with AskUserQuestion, and wait. Do not guess.
### Reconcile: Build the Gap List
Compare the full branch delta (committed plus uncommitted) against the intent. Produce a list of work items, each marked:
- **Done**: implemented and consistent with the intent
- **In flight**: started but incomplete (half-built component, TODO markers, failing or missing tests)
- **Not started**: required by the intent, absent from the branch
Treat verification status as its own item. Unless you have evidence that format, lint, types, and tests currently pass against the branch as it sits, verification is remaining work.
### Classify the Remaining Work
Decide whether the remaining work is bug-shaped or feature/chore-shaped, because the two require different plan shapes in Phase 2. A single branch can contain both: a feature to finish and a misbehavior to fix are separate work items with separate shapes.
- **Bug**: the work item is a symptom of existing code misbehaving (including code already written on this branch), and the acceptance gate is "this specific symptom no longer reproduces." The work is anchored to a red reproducer — a committed failing test that captures the misbehavior. Bug shape is required whenever the gate is "symptom stops reproducing," regardless of how well you think you understand the cause after exploration.
- **Feature / chore / refactor**: builds something new or changes known behavior against a spec. The acceptance gate is "the new behavior matches the spec," not "an existing symptom stopped."
**Why bug shape is anchored to a red reproducer, not to whether the cause is known.** The reproducer is not a formality tacked onto the end — it is the investigation tool and the verification tool at once. A single red-then-green reproducer does five things that nothing else does together:
1. Nails down the exact conditions under which the bug fires (inputs, state, surrounding setup). Until the test is red, "I think I understand the bug" is a guess.
2. Points the fix at the right code. The path from a failing assertion back to the source of the bad value is how you localize the fault, not by reading around.
3. Proves the bug is real and not a misread of the intent or a stale branch. If you can't make a test fail, there is no bug to fix here and you stop.
4. Proves the fix actually fixed *this* bug when the same test flips green. "Looks right now" is not verification; red → green is.
5. Prevents regression. The test stays in the suite and fails again the next time someone reintroduces the condition.
A confident guess at the root cause does not replace any of those five. "I already know what's wrong, let me just apply the fix and add a test in parallel" is never bug shape — the test written alongside the fix cannot be red against the broken code, so items 1 through 4 are all skipped.
Rule of thumb, applied in this order:
1. Can you imagine a test that would be red today and green after the fix, and that maps to the item's acceptance gate? If yes, it is bug shape.
2. Otherwise, if the item is a spec for a change or addition, it is feature/chore shape.
When in doubt, ask the user.
### Present the State Summary
Before planning anything, present the user with a structured summary. Use markdown tables with minimal separators (`|-|-|`) or bullet lists.
**Template:**
```
## Branch State: {branch}
### Where Things Stand
- Commits ahead of main: {n} ({one-line summary of what they contain})
- Uncommitted changes: {summary, or "none"}
- Stashes: {list, or "none"}
- Behind origin/main: {n} commits {flag any schema/codegen commits}
- PR: {#number, url, draft status, CI status | "none yet"}
- Reviews: {"none yet" | "approvals only" | should not reach here with open feedback}
- Ticket: {KEY, status, one-line summary | "none identified"}
### Work Items
| # | Item | State | Shape | Notes |
|-|-|-|-|-|
| 1 | {item} | Done / In flight / Not started | bug / feature | {notes} |
### Proposed Objective
{What this session will do to reach review-ready, in one or two sentences.}
```
Ask the user to confirm the objective, adjust work items, or add context you are missing. Do not proceed until the user confirms.
### Phase 1 Gate
Before moving to Phase 2, confirm:
- [ ] Local state established (branch, working tree, stashes, base freshness, full delta)
- [ ] Remote and PR state established (or absence of a PR noted)
- [ ] No unaddressed review feedback on the PR (else redirected to pr-review-response)
- [ ] Intent assembled: ticket fetched, linked context pulled, user request understood (or ambiguities resolved via AskUserQuestion)
- [ ] Gap list built with every remaining item classified bug vs feature shape
- [ ] State summary presented and user confirmed the objective
---
## Phase 2: Planning
### Enter Plan Mode
Use EnterPlanMode. Everything in this phase happens in plan mode.
### Analyze the Codebase
Before writing any plan, understand the territory:
1. **Explore relevant areas** inline with LSP (workspaceSymbol, findReferences, goToDefinition), Read, and ls/find/Glob; never dispatch exploration agents. Identify the files, components, hooks, queries, and tests that relate to the remaining work items. Pay attention to what the branch has already changed; the in-flight code is part of the territory now.
2. **Read existing patterns** in files you will modify or files similar to what you will create. Follow what already exists rather than inventing new patterns. Where the branch's own in-flight code established a pattern, decide whether to follow it or fix it; do not let the team produce a mix.
3. **Check for nested CLAUDE.md files** in the directories you will work in. These contain domain-specific guidance (build commands, architecture rules, testing patterns) that your agents must follow.
4. **Read relevant style guide sections** from `docs/style-guide/`. Load only the files that apply to the remaining work.
### Determine Team Composition
**Team size equals the count of independent remaining work items. Roles label each teammate; roles do not determine team size.** A work item is a coherent unit of change that one person can own end-to-end — typically a component and its tests and its story together, or a query and its integration points together, or a config change and its affected call sites together. You decide roles by labeling each work item with the domain it lives in (frontend-dev, relay-dev, test-engineer, etc.), and the same role repeats as many times as there are work items in that domain. Three frontend-devs on one branch is normal when three independent React surfaces are changing.
Available role labels:
| Role | Domain |
|-|-|
| Frontend Developer | React components, hooks, Picnic styling, UI logic |
| GraphQL/Relay Developer | Queries, mutations, fragments, schema integration |
| Test Engineer | Unit tests, integration tests, MSW handlers (typically only used standalone for bug shape's Wave A reproducer) |
| Storybook Developer | Stories, decorators, visual testing |
| Config/Infrastructure | Route changes, feature flags, build config |
**Antipattern — do not do this.** The failure mode to avoid is collapsing N independent work items onto M<N teammates by role, and calling the resulting sequential work a "wave." The specific shape this takes is the canonical two-teammate pairing — one "frontend-dev" who does all the implementation plus one "test-engineer" who writes the tests for that implementation — applied by default regardless of how many work items the branch actually contains. That pair pretends to be parallel but isn't: the test teammate's output depends on the implementation teammate's output, so they serialize. Worse, it hides the real parallelism opportunity, which is splitting the implementation itself across independent surfaces.
Correct decomposition: if the remaining work touches three components that do not share a file and do not depend on each other's exports, that is three work items and three frontend-devs. Each one owns their component plus its tests plus its story. They run as three parallel Wave 1 tasks. The test work is not a separate teammate — it rides along with the implementation teammate who owns that surface.
If the remaining work is honestly one work item, the team is one teammate. The number of teammates tracks the number of work items, no floor, no ceiling.
**For bug-shaped items.** Composition follows Phase 3's wave structure. Spawn the Wave A teammate(s) only; resist pre-rostering the fix teammates, because you do not yet know what domain the fault lives in.
### Write the Plan
**1. Overview**
Recap of where the branch stands (from the state summary), the session objective, and the chosen approach for the remaining work. If the branch is behind main, rebase-and-regenerate is Task 0, before any wave. If any items are bug-shaped, note that their Wave B will be defined in Phase 3 after Wave A lands.
**2. Team Roster**
Each agent's name, role, and responsibilities. Bug and feature tracks can share teammates only when the same person would naturally own both items.
**3. Implementation Tasks — feature / chore / refactor items**
Break the remaining work into discrete tasks. Each task specifies:
- **Task ID** (T1, T2, T3, etc.)
- **Assigned to** (agent name)
- **Description** of what to build or change, including how it connects to the branch's existing in-flight code
- **Files to create or modify** (specific paths)
- **Dependencies** (which tasks must complete first, if any)
- **Acceptance criteria** for this specific task
Group tasks into waves based on dependencies:
- **Wave 1**: Tasks with no dependencies (run in parallel)
- **Wave 2**: Tasks depending on Wave 1 outputs (run in parallel after Wave 1)
- Continue as needed
Bias toward width, but split on work items, not on aspects of a single work item. Do not split one work item into "implement it" + "test it" as separate teammates; do not split "build the component" + "write its story"; do not split by role when roles are not the boundary. One owner per work item, all aspects co-located.
**3b. Implementation Tasks — bug items (only if any item is bug-shaped)**
Two serial waves by construction; within each wave, parallelism follows work items. The bug track runs alongside the feature track — they do not block each other.
- **Wave A — Reproducer(s) and fault localization.** One Wave A task per independent symptom or per independent suspected surface, one teammate each. Each teammate is briefed identically: *produce a failing artifact that reproduces the bug on the current branch — a Jest/Vitest test, a React Testing Library test, or a Storybook story paired with a test. The reproducer is the investigation tool, not a gate at the end: use it to localize where the code diverges from intent by iterating on inputs, moving assertions closer to the suspected origin, and walking up or down the call stack. Report back with (a) the committed red reproducer, (b) the file/function/input that produces the wrong value, and (c) a short description of the code path traced.*
Wave A acceptance criteria (per teammate):
- A reproducer is committed and demonstrably red on the current branch for that symptom.
- The report identifies the localized fault with specificity a fix task can act on.
- If the teammate cannot make the reproducer fail, or localizes something they cannot explain with near-certainty from the code, they report blocked. "I don't know" is a valid outcome and the Branch Lead surfaces it to the user — no guessing, no defensive patch.
- **Wave B — Fix(es) and verify (to be written after Wave A).** Leave this marked "TBD — filled in at the start of Phase 3 once Wave A reports." One fix teammate per localized fault, in the domain that fault lives in. Each Wave B task uses its corresponding Wave A reproducer as the red → green acceptance criterion.
**4. Review Assignments**
Which agent reviews which other agent's work. Rules:
- Every agent's work must be reviewed by at least one other agent
- Prefer cross-domain reviews (test engineer reviews components, frontend dev reviews tests)
- If there is only one agent, the Branch Lead reviews their work directly
**5. Verification Steps**
Commands to run after all implementation is complete. The repo uses pnpm. Run every command from the repo root through `--filter @attentive/<pkg>` (for example `@attentive/crm`, `@attentive/analytics-ui`), one command per Bash call, never with `cd`; a root-level `test`, `lint`, or `check-types` across all packages is banned. Scope `test`, `lint`, and `format:check` to the changed files as step 3 shows; `check-types` runs package-level and is the exception. Run test commands one at a time.
1. **Generate first**: `pnpm --filter @attentive/<pkg> relay:compile`. After an install, a rebase, or any flag-fragment edit, also run `pnpm --filter @attentive/data generate` and then `pnpm --filter @attentive/mock-data generate` (several minutes each). Type checking and tests fail without generated types.
2. **Auto-fix**: `pnpm --filter @attentive/<pkg> lint --fix <changed files>`. `format:write` ignores path arguments and reformats the whole package; run `pnpm --filter @attentive/<pkg> format:write` once, when no teammate is mid-edit.
3. **Verify, scoped to the changed files**: `pnpm --filter @attentive/<pkg> format:check <changed files>`, `pnpm --filter @attentive/<pkg> lint <changed files>`, `pnpm --filter @attentive/<pkg> test <changed test files>`, then `pnpm --filter @attentive/<pkg> check-types` with no file arguments (tsc ignores tsconfig when given files). `format:check` and `lint` also scan the whole package and can report files outside the passed paths; read the file list.
Verification covers the whole branch, not only this session's changes: the changed files are every file on the branch relative to main, and the in-flight code inherited from earlier sessions has to pass too.
**6. Ship Steps**
What Phase 5 will do, based on the state found in Phase 1: commit and push; create the PR or update the existing PR's description; leave the Jira ticket in its current status (or note there is none).
**7. Completion Criteria**
What "done" looks like: all tasks complete, all reviews approved, all verification commands pass, branch pushed, PR accurate and open. The ticket stays in its current status; it moves to Code Review later, via `pr-review-response`, once both Codex and the user approve. For bug items, additionally: each Wave A reproducer is committed and passing on the final branch.
### Present the Plan to the User
Exit plan mode. Present the plan with the team roster, the task breakdown with waves, the review assignments, the verification steps, and the ship steps. Ask for approval. If the user requests changes, re-enter plan mode, revise, and present again. Do not proceed until the user explicitly approves.
### Phase 2 Gate
Before moving to Phase 3, confirm:
- [ ] Codebase analyzed, including the branch's own in-flight code
- [ ] Rebase-and-regenerate planned as Task 0 if the branch is behind main
- [ ] Every remaining work item has a task with clear acceptance criteria
- [ ] Review assignments defined
- [ ] Ship steps match the state found in Phase 1
- [ ] User has explicitly approved the plan
---
## Phase 3: Implementation
When the user approves the plan, begin implementation. Before the first dispatch, re-read "Leading, Not Dispatching."
### The Team
The session has one implicit team, formed on the first teammate spawn; there is no create step. Teammates are addressed by `name` through SendMessage and share one task list.
### Spawn Teammates
For each role in the team roster, spawn a teammate using the Agent tool with `name` set:
- Use a descriptive `name` matching the team roster (e.g., `frontend-dev`, `test-engineer`)
- Include the full task context: what to build, which files, acceptance criteria, relevant patterns from codebase analysis, and what the branch already contains that their work must connect to
- Point the teammate to any relevant CLAUDE.md files and style guide sections
- Remind the teammate of coding standards: no `any`, no type casting, hooks in their own files, no prop drilling
- Launch all teammates in the current wave in parallel (single message with multiple Agent tool calls)
Teammates persist throughout the workflow. They go idle between tasks but retain full context when you send them follow-up work via SendMessage.
### Execute Waves — feature / chore / refactor items
1. **Delegate current wave — dispatch in parallel, always.** Use TaskCreate to create tasks in the team's task list, then assign them with TaskUpdate (set `owner` to the teammate's name). For wave 1, teammates were briefed at spawn time. For subsequent waves, send every teammate's next task as SendMessage calls in a **single turn** with multiple tool calls. The only reason to dispatch serially within a wave is a discovered dependency — in which case revise the plan, do not paper over it with ordering.
2. **Verify wave completion**: When all teammates in the current wave report back, verify their outputs meet the task acceptance criteria. If a teammate's work is incomplete or incorrect, use SendMessage with specific feedback. After two re-delegations still incomplete, stop and surface it to the user. Also re-check the plan itself — a wave's outputs can reveal that the next wave needs to change. If so, revise the plan before dispatching and surface the revision to the user.
3. **Advance**: When the current wave is fully verified, move to the next wave. Repeat until all waves are complete.
### Execute Waves — bug items
1. **Dispatch Wave A.** Create the Wave A task(s) in TaskCreate, assign them, and SendMessage each teammate the reproducer-and-localization brief from the plan.
2. **Verify Wave A — this is a real gate, not a formality.** When a teammate reports back, before touching Wave B:
- Read the committed reproducer. Run it. Confirm it fails on the current branch for the reason the teammate claims.
- Read the localization report. Follow the code path they described. Confirm the file/function/input they named is actually where the bad value originates, not a symptom downstream of it.
- If either does not hold up, SendMessage the teammate with specifics and iterate. After two rounds without both holding, take the exit ramp in step 3.
3. **Exit ramp: "I don't know."** If Wave A reports blocked — "I cannot make it fail" or "I localized something but cannot explain it" — do not plan a fix. Surface the trace, ruled-out hypotheses, and evidence needs to the user and ask how to proceed. Unacceptable paths: guessing a root cause, shipping a defensive check that hides the symptom.
4. **Plan Wave B now that you have facts.** Write the Wave B task(s) in the plan document: one fix task per localized fault, assigned to the domain specialist whose code the fault lives in, plus any follow-on tasks that only became visible after localization. Acceptance criteria always include: Wave A's reproducer flips red → green, and the full affected test suite passes.
5. **Dispatch Wave B.** SendMessage the assigned teammates. If Wave B has multiple independent tasks, send all SendMessage calls in a single turn.
6. **Verify Wave B — red → green is the only acceptable signal.** Run Wave A's reproducer yourself. It must now pass. If it does not flip, SendMessage the teammate with specifics and iterate. After two rounds without a flip, stop and surface it to the user. "The code looks right" is not verification. The reproducer stays committed in the PR — it is part of the fix, not scaffolding.
### Run Verification
After all waves (both tracks) are done, run the exact sequence from the plan's Verification Steps, package-scoped through `--filter` from the repo root: generate first, auto-fix, then check. Read the package's CLAUDE.md for package-specific commands. If verification surfaces issues in independent files or different teammates' domains, fan the fixes out in parallel via SendMessage in a single turn. Only serialize when one fix's output is genuinely an input to another. After two fix rounds still failing, stop and surface it to the user.
### Phase 3 Gate
Before moving to Phase 4, confirm:
- [ ] All waves completed and outputs verified against acceptance criteria
- [ ] All bug-item reproducers red → green
- [ ] Full verification sequence passed, package-scoped through `--filter` from the repo root
- [ ] All implementation teammates still alive (do NOT shut them down — they are needed for review fixes)
---
## Phase 4: Code Review
Code review happens in two layers, and all of it happens before anything is committed. Do not commit "while waiting for review." The purpose of review is to catch problems before they are committed.
Implementation teammates are still active and idle, retaining full context. No reviewer agents are spawned: the implementers review each other, and the Branch Lead reads everything last.
### Layer 1: Cross-Review by Implementers
For each review assignment in the plan, SendMessage the reviewing implementer a brief that includes:
- **Files to review**: exact paths the reviewed teammate modified, excluding `__generated__/` directories.
- **Read actual source files**: open and read each file in full. Diffs are not a substitute.
- **Task context**: the reviewed task's description, acceptance criteria, and planned approach.
- **Team context**: what other teammates built and how their work integrates with the files under review.
- **Branch context**: this branch contains pre-session work. The reviewer checks that the new code integrates cleanly with it, but the review scope is the teammate's changes, not a re-litigation of code the user already had in place. Real defects noticed in pre-session code get reported to the Branch Lead, who surfaces them to the user rather than silently expanding scope.
- **Standards**: coding standards, style guide sections, and applicable CLAUDE.md rules.
- **Review format**: specific, actionable feedback with file paths and line numbers; explicit approval if everything looks good.
Send all review briefs in one turn. When a review comes back:
- **If approved**: mark that review complete.
- **If changes requested**: SendMessage the feedback (exact comments, paths, line numbers) to the owning teammate; after fixes, SendMessage the same reviewer to re-review with the previous comments attached. Repeat until the reviewer explicitly approves. A finding still open after two fix rounds is a thrashing trigger: stop, diagnose, and surface it to the user.
All peer reviews must pass before Layer 2. With one implementer there are no Layer 1 assignments; Layer 2 is the review.
### Layer 2: Branch Lead's Holistic Review
After peer reviews pass, the Branch Lead reads every changed file on the branch relative to main in full (this session's work and the inherited in-flight code ship together in one PR) and checks:
- **Integration**: do the pieces fit together, including the seams between pre-session code and this session's additions?
- **Pattern compliance**: does the code follow existing codebase patterns?
- **Edge cases**: error states, empty states, loading states, boundary conditions, accessibility.
- **Test coverage**: do tests cover the important logic?
Findings go to the owning teammate via SendMessage; the Branch Lead re-reads after fixes. The same two-round bound applies. If fixes were made in either layer, re-run the verification sequence before proceeding.
### Phase 4 Gate
Before moving to Phase 5, confirm:
- [ ] All peer reviews explicitly approved
- [ ] Branch Lead's holistic review complete with no open findings
- [ ] Verification re-run and passing if any review fixes landed
- [ ] Implementation teammates still alive (shut them down AFTER committing, not before)
---
## Phase 5: Ship
### Commit and Push
1. Run `git status` to see all changed files
2. Stage files explicitly by name (never `git add -A` or `git add .`)
3. Do NOT stage anything from `__generated__/` directories (they are gitignored)
4. Write the commit message following repo conventions:
```
<TICKET>: <description>
```
Use the ticket number as prefix when one exists (e.g., `USP-2313: Add offer link in offers module`); otherwise a descriptive prefix based on the branch's purpose. End the message with the Co-Authored-By attribution line for the current model, as given in the session's system reminder.
5. Push: `git push -u origin HEAD`
### Create or Update the PR
**If Phase 1 found no PR, create one:**
1. **Read the PR template** at `.github/pull_request_template.md`
2. **Read the rules and the guide.** `~/.work/rules/pr-descriptions.md` governs the description text. The Confluence guide "How to Write a Good Pull Request" at `https://attentivemobile.atlassian.net/wiki/spaces/UI/pages/3172401183/How+to+Write+a+Good+Pull+Request`, read with `mcp__plugin_atlassian_atlassian__getConfluenceContent`, governs what surrounds it: draft status, PR size, self-review, screenshots, inline PR comments.
3. **Fill in the PR template**:
- **Jira Issue**: `https://attentivemobile.atlassian.net/browse/<TICKET>` (omit if no ticket)
- **Summary**: What the PR does, covering the whole branch and not only this session, under `~/.work/rules/pr-descriptions.md`: at most 5 paragraphs, each at most 3 sentences, each sentence at most 20 words, plain English.
- **Demo**: Leave for the user: `<!-- TODO: Add screenshots/video or note that visual demo isn't necessary -->`
- **Testing**: Unit tests added, manual testing performed, regression considerations, under the same sentence and paragraph limits
4. **Write the filled template to a file** in the session scratchpad directory. The `pr-body-limits-block` hook denies an inline `--body` and denies a body over the limits; a denial means rewrite.
5. Create it:
```bash
gh pr create --title "<TICKET>: <concise description>" --body-file <file> --base main --label "opened-by-ai" --label "ci:skip-acceptance-tests"
```
6. Trigger automated review with a comment whose body is exactly `@codex Review` (no attribution footer, since the bot trigger requires an exact match):
```bash
gh pr comment --body "@codex Review"
```
**If a PR already exists, bring it up to date:**
1. Read `~/.work/rules/pr-descriptions.md` and `~/.work/rules/pr-body-editing.md`; they govern every word of the description. Read the Confluence guide (same page as above) for what surrounds it.
2. Read the live body: `gh pr view {number} --json body --jq '.body'`.
3. Examine the entire description. Every Summary sentence states a change the branch's final diff contains. Nothing describes a pre-session version. Testing reflects the tests as they now stand. Sentences are at most 20 words, paragraphs at most 3 sentences, the Summary at most 5 paragraphs, all in plain English. A change in one section ripples into the others; trace each ripple and fix it in the same edit. A Demo note made stale by the change is named in the report to the user and left for him; Demo is his.
4. Write the corrected body to a file in the session scratchpad and run `gh pr edit {number} --body-file <file>`. Never append an "Additional changes" section. Never pass `--body` inline; the `pr-body-limits-block` hook denies it and denies a body over the limits. A denial means rewrite, never route around.
5. **Leave a top-level comment** (with the attribution footer) summarizing what this session added, so anyone watching the PR has the delta without re-reading the diff. Write it to a file first:
```bash
gh pr comment {number} --body-file <file>
```
### Leave the Jira Ticket in Progress
Do not transition the ticket to Code Review here. Regardless of scope, the ticket moves to Code Review only after both Codex and the user have approved on the PR, and this workflow ends at review-ready, before any review exists. `pr-review-response` handles that gated transition once approvals land. Leave the ticket in its current status.
### Report to the User
Inform the user that the session's work is complete:
- Link to the PR (and whether it was created or updated)
- What this session accomplished relative to the state summary from Phase 1
- Note that the ticket stays in its current status; it moves to Code Review once both Codex and you have approved the PR (via `pr-review-response`)
- Anything that remains before the branch is fully done, if the objective was partial
- Note that the Demo section of the PR needs their input (if applicable)
- Any Demo note left stale for the user to fix
Do not mention sneak previews, CI status, or other information meant for human reviewers of the PR. Keep the report focused on what the user needs to know or act on.
### Shutdown the Team
After all work is complete and reported:
1. Send a shutdown request to each teammate: `SendMessage({to: "<name>", message: {type: "shutdown_request"}})`
2. Wait for all teammates to acknowledge and shut down