Work the branch
Hooks, rules, skills, and instructions for use with Claude Code
npx -y skills add chancegraff/rules-for-claude --skill work-the-branchAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
3 things to look at
- 14 days oldThe repository was created 14 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
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, Jira transitioned. Use when the user invokes /work-the-branch.
SKILL.md
38.6 KB, as published. Nobody here has run it
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 transitioned.
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
- 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.
- 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.
- 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.
- 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:
- Is the base stale? Dispatch a quick check:
git fetch origin main && 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. - Has codegen run since the last rebase? Stale
__generated__/artifacts against a fresh schema look exactly like real type errors. If in doubt, dispatchyarn relay:compile(and any package-specific codegen) first, then retry. - 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.
- 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?
- 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, Grep, Glob, 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:
- You are on a feature branch, not
main(checkgit branch --show-current) - You have access to GitHub CLI (
gh) - 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:
- Current branch:
git branch --show-current - Working tree:
git status(uncommitted changes, untracked files),git stash list(stashed work is easy to forget and easy to lose) - Base freshness:
git fetch origin main, thengit log HEAD..origin/main --oneline(how far behind) andgit log origin/main..HEAD --oneline(commits on this branch) - The full branch delta:
git diff origin/main...HEAD --stat, plusgit diff --statfor 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
- Does the branch exist on the remote with unpushed commits? Check the upstream and ahead/behind counts from
git status. - Is there a PR?
gh pr view --json number,title,body,state,isDraft,url,labels,reviewRequests,reviews - If a PR exists:
gh pr checksfor CI status, andgh api repos/{owner}/{repo}/pulls/{number}/commentsfor 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:
- 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. - Linked context. Scan the ticket and PR for external resources and pull them in:
- PRDs, tech specs, RFCs: Google Workspace docs via the
gwsCLI (rungws --helpif unfamiliar); Confluence pages viamcp__plugin_atlassian_atlassian__getConfluencePage. - Figma URLs (figma.com/design/..., figma.com/board/...): Use the Figma MCP tools (invoke the
figma-useskill first, thenget_design_contextorget_screenshot). - Jira attachments: Download and read attached files (images, PDFs, spreadsheets).
- PRDs, tech specs, RFCs: Google Workspace docs via the
- 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:
- 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.
- 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.
- 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.
- Proves the fix actually fixed this bug when the same test flips green. "Looks right now" is not verification; red → green is.
- 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:
- 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.
- 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:
- Explore relevant areas using the Explore agent or Grep/Glob tools. 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.
- 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.
- 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.
- 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 using the
superpowers:code-revieweragent type
5. Verification Steps
Commands to run after all implementation is complete, always from the package directory you made changes in (e.g., libs/crm, mfes/analytics-ui), never from the repo root:
- Generate first: Run
yarn relay:compilein the package directory (and any other generation commands specified in the package's CLAUDE.md or README) before anything else. - Auto-fix: Run
yarn format:writeandyarn lint --fix. - Verify: Run
yarn format:check,yarn lint,yarn check-types,yarn test.
Verification covers the whole branch, not just this session's changes. 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; transition the Jira ticket (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, ticket transitioned. 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."
Create the Team
Use TeamCreate to create a team for this branch (e.g., team name branch-usp-2313-offers). This creates a shared task list that all teammates can access.
Spawn Teammates
For each role in the team roster, spawn a teammate using the Agent tool with the team_name parameter:
- Use a descriptive
namematching 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 - Set
mode: "auto"for implementation teammates - 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
-
Delegate current wave — dispatch in parallel, always. Use TaskCreate to create tasks in the team's task list, then assign them with TaskUpdate (set
ownerto 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. -
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. 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.
-
Advance: When the current wave is fully verified, move to the next wave. Repeat until all waves are complete.
Execute Waves — bug items
-
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.
-
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.
-
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.
-
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.
-
Dispatch Wave B. SendMessage the assigned teammates. If Wave B has multiple independent tasks, send all SendMessage calls in a single turn.
-
Verify Wave B — red → green is the only acceptable signal. Run Wave A's reproducer yourself. It must now pass. "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, cd into the package directory where changes were made and run the exact sequence from the plan's Verification Steps: 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.
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 from the package directory
- 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. Reviewer teammates are spawned fresh for independence; the fix cycle goes through SendMessage to the original implementation teammates.
Layer 1: Cross-Agent Peer Review
For each review assignment in the plan, spawn a reviewer teammate using the Agent tool with team_name and subagent_type: "superpowers:code-reviewer". Give each reviewer a descriptive name (e.g., reviewer-for-frontend-dev).
Each reviewer's prompt must include:
- Files to review: Exact file paths the reviewed teammate modified. Exclude
__generated__/directories. - Read actual source files: The reviewer must open and read each file in full. Diffs are not a substitute.
- Task context: The original task description, acceptance criteria, and the 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.
Launch all initial reviews in parallel.
When a reviewer completes their review:
- If approved: Mark that review complete.
- If changes requested: SendMessage the feedback (exact comments, paths, line numbers) to the original implementation teammate; after fixes, SendMessage the reviewer to re-review with the previous comments attached. Repeat until the reviewer explicitly approves.
All peer reviews must pass before Layer 2.
Layer 2: Final QA Review
Spawn a single QA reviewer teammate (team_name, subagent_type: "superpowers:code-reviewer") with a comprehensive prompt covering:
- All changed files on the branch relative to main — this session's work and the inherited in-flight code ship together in one PR, so the QA pass reads the whole delta.
- Full context: The intent, the state the branch started in, and each teammate's responsibilities.
- Integration focus: 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?
Treat QA feedback the same as peer review: delegate fixes to the appropriate implementation teammate, re-review, repeat until approved. 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
- QA review explicitly approved
- 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
- Run
git statusto see all changed files - Stage files explicitly by name (never
git add -Aorgit add .) - Do NOT stage anything from
__generated__/directories (they are gitignored) - Write the commit message following repo conventions:
Use the ticket number as prefix when one exists (e.g.,<TICKET>: <description>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 (e.g.,Co-Authored-By: Claude Fable 5 <[email protected]>). - Push:
git push -u origin HEAD
Create or Update the PR
If Phase 1 found no PR, create one:
- Read the PR template at
.github/pull_request_template.md - Read the Confluence guide for PR standards: fetch "How to Write a Good Pull Request" at
https://attentivemobile.atlassian.net/wiki/spaces/UI/pages/3172401183/How+to+Write+a+Good+Pull+Requestusingmcp__plugin_atlassian_atlassian__getConfluencePage. - Fill in the PR template:
- Jira Issue:
https://attentivemobile.atlassian.net/browse/<TICKET>(omit if no ticket) - Summary: Clear description of what changed and why, covering the whole branch, not just this session. Do not use em dashes or en dashes in prose.
- 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
- Jira Issue:
- Create it:
gh pr create --title "<TICKET>: <concise description>" --body "<filled template>" --base main --label "opened-by-ai" --label "ci:skip-acceptance-tests" - Trigger automated review with a comment whose body is exactly
@codex Review— no attribution footer, since the bot trigger requires an exact match:gh pr comment --body "@codex Review"
If a PR already exists, bring it up to date:
- Read the current description:
gh pr view --json body --jq '.body', and read the Confluence PR guide (same page as above) for the quality bar. - Evaluate both accuracy and quality. Does the Summary reflect the branch's final state, not a pre-session version? Are quantitative claims still correct? Would a reviewer understand what the PR does and why in under 30 seconds? Is the Summary coherent prose rather than fragments a reviewer must reassemble?
- If it falls short, rewrite it. Do not append an "Additional changes" section. Rewrite the description so it reads as one coherent account of the PR's final state. Preserve the template structure and any content you did not create (user-written Demo sections, screenshots). Update via
gh pr edit {number} --body "<updated body>". - 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:
gh pr comment {number} --body "<summary>"
Transition the Jira Ticket
Only if a ticket was identified in Phase 1 and the branch now covers its full scope:
- Fetch available transitions:
mcp__plugin_atlassian_atlassian__getTransitionsForJiraIssue - Identify the appropriate transition (look for "In Review", "Ready for Review", "Code Review", "PR Submitted")
- Execute it:
mcp__plugin_atlassian_atlassian__transitionJiraIssue - If no obvious review transition exists, inform the user and let them decide
If the session's objective was a partial advance and ticket scope remains, leave the ticket in its current status and say so in the report.
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
- Confirmation of the Jira transition, or why the ticket was left where it was
- 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)
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:
- Send a shutdown request to each teammate:
SendMessage({to: "<name>", message: {type: "shutdown_request"}}) - Wait for all teammates to acknowledge and shut down
- Clean up with TeamDelete