RECIPES / 01
Fix a bug with analysis, fix, and review
A three-stage flow in loja-api, with Claude Code analyzing, Codex fixing with npm test as the verification, and Claude Code reviewing with your approval.
Updated for PrumoGrid 0.5.11
The scenario
In loja-api, the PRIMEIRA coupon (first-purchase discount) applies the discount twice when the cart has two or more items. The current tests pass, because there is no coupon test. The fix will be done in three stages, each with its own agent, its own terminal and its own role:
| Stage | Who runs it | Role | Done when |
|---|---|---|---|
| 1. Analysis | Claude Code | analyst | the agent reports it finished (Automatic) |
| 2. Fix | Codex | implementer | npm test passes (Automatic with verification) |
| 3. Review | Claude Code | reviewer | the agent reports it and you approve (With your approval) |
You step in at two moments: on a permission request and on the final approval. The agents do the rest in sequence.
Watch the video
A bug-fix operation with several agents. A bug fixed from start to finish by three agents: analysis, a fix confirmed by npm test and a review that waits for my approval. Captions and transcript ↗
Before you start
- Register
C:\demo\loja-apiand confirm thatnpm testpasses in a PowerShell for the project. - Check the project verification on the card: Verification: npm test · detected. If it does not appear, open the card's ··· menu, choose Project verification…, enter
npm test, use Test now and Save. See Verification. - In Tools → Rules and roles…, create three rules in For this project: "Always answer in Brazilian Portuguese.", "Do not change package.json without warning first." and "Every change in src comes with a test." See Rules.
- Have Claude Code and Codex installed and authenticated.
Build the flow
All three stages are created with + New stage, using Plan only, so nothing starts before you check the whole set.
Stage 1: analysis
- With
loja-apiselected, click + New stage at the top. In What needs to be done?, write:
Investigate why the PRIMEIRA coupon applies the discount twice in carts with more than one item. Write the cause, the plan, and a case that reproduces it in ANALISE.md. Do not change code.- Runs on: Claude Code. In Where this stage runs, New terminal.
- Open More options. In Role (rules), choose analyst. In How does this stage finish and the next one start?, choose Automatic.
- In On creation, choose Plan only and confirm.
The analysis writes its result to a file because Codex does not see Claude Code's conversation. The file is the handoff between the two.
Stage 2: fix
- Click + New stage again. With a planned flow, the dialog opens to add to the flow, after stage 1.
Task:
Read ANALISE.md, fix the cause, and add a test that reproduces the case. Run npm test.- Runs on: Codex CLI, New terminal, starting after stage 1.
- In More options: role implementer and Automatic with verification. In Check with a command (optional), use the project's command (
npm test), which passes when it exits with success (0). - Plan only and confirm.
Stage 3: review
- + New stage once more: Runs on: Claude Code, New terminal, after stage 2.
Task:
Review the diff of this fix and write up to three findings in REVISAO.md, with file and line. Reply with the findings only.- In More options: role reviewer and With your approval.
- Plan only and confirm.
Before running, open the Flow and read the three cards: each one's agent and role (for example Codex CLI · implementer), its own terminal, the Starts: line, and the Done when: line (Automatic, Automatic with verification with npm test passes, With your approval). In Rules for this project · 3, check the rules that apply to the three stages.
Run and follow along
- Click Run flow and go back to the Grid. The stages' terminals open; only the analysis terminal receives its instruction now.
- The analyst reads
src/cupom.cjsandsrc/carrinho.cjs. When it wants to writeANALISE.md, the CLI asks for permission. The request shows up in four places: on the pane label, on the project card (waiting for you), in the Attention tab, and in the status bar (1 waiting). - In Attention, click See request. The Permission request dialog shows the terminal, the project, the stage, and the requested command. Answer with Allow, Deny or Go to terminal.
- With the analysis done, the fix starts on its own. Switch to Focus and click the Codex thumbnail to follow it.
- Codex reads the analysis, changes the discount calculation in
src/cupom.cjs, adds the two-item test, and runsnpm test. - Stage 2 is done only because
npm testpassed. In the Stages tab, View result shows the command, the output, and the verdict.
Review and approve
- The reviewer reads the diff and writes the findings in
REVISAO.md. - When it finishes, the stage appears in Attention as needing you. Open Review delivery and read the findings.
- If everything is right, click Approve and continue. If something needs to change, use Return for correction… with a clear instruction; the correction goes back to the implementer.
- In the Stages tab, open Sent instructions and the log to see the time of each delivery, report, and approval.
What to check at the end
git status --shortshowssrc/cupom.cjschanged, the new test,ANALISE.mdandREVISAO.md.npm testpasses in a terminal of yours, outside the agent.- The diff does only what the analysis proposed. Use Review changes in the result to read the diff on screen, or use your editor.
Variations
- Without Codex. Use Claude Code for all three stages. For the fix, a new terminal gives you a clean conversation; the same terminal as the analysis continues the conversation with the context it already has.
- Fix in a worktree. If another task is touching the same folder, create the fix stage in an isolated copy (More options, folder in a new worktree). Remember that the worktree starts without installed dependencies. See Worktrees.
- Without approval. For small tasks, the review can be automatic. For changes going to production, keep the approval.