Your list-rooms command is done. When the agent went wrong there, a plan or an edit showed it. Debugging is harder to steer because nobody wrote down what the fix looks like. Each attempt is the agent’s best guess, and asking for one more feels reasonable.
In this lesson, you’ll hand your agent a bug from the play-test weekend and reply the way you naturally would. Then you’ll read your session for a fix loop and get out of it cleanly.
Hand the Bug Over as You Usually Would
To watch a bug hunt, everyone needs the same bug. The play-test weekend pack, the course’s second download, has one. Its playtests/lighthouse-keepers-study.json logs a weekend of play-tests for The Lighthouse Keeper’s Study. Set up a starting point you can come back to:
- Run
git status, and commit anything left over. - Copy the pack’s
playtests/lighthouse-keepers-study.jsoninto your project’splaytests/folder, replacing any file with that name. - Run
git add playtests/lighthouse-keepers-study.json, thengit commit -m "Add the play-test weekend log". - Run your report command, listed in your instruction file, on The Lighthouse Keeper’s Study.
Look for a puzzle whose average is impossible, larger than the time any team took, such as 64.5 minutes when two teams took 12 and 9. If your report shows no such line, your project handles this file differently.
In that case, use the reference version from the course downloads. If its folder has no Git history, run git init and commit all its files, then repeat the steps above in it. If you switch, keep working in the reference version for the rest of the course: copy your list-rooms command and its test across, add your checkRoom() rule to its instruction file, and commit, so one project has every change.
The commit adding the play-test weekend log is your last good commit. It holds the bug’s data and no attempt at a fix. Start a fresh session in the mode that asks before each edit, so every attempt arrives as a change you can see. Open the version for your agent, checked in December 2026 with Claude Code 2.1 and Codex CLI 0.173:
Start the session with claude --permission-mode manual. Claude Code asks before every file edit, unless an allow rule in your settings already permits edits. Approve each edit on its own, not with the option that allows all edits for the session.
Press Esc to interrupt Claude Code. It stops what it’s doing and waits for your next message.
Start the session with codex --sandbox read-only --ask-for-approval on-request. The read-only sandbox blocks every write, so each edit comes to you as a request. Approve each change on its own, not with the option not to ask again for these files.
Press Esc to interrupt Codex. It stops the current turn and waits for your next message.
Describe the bug as you’d first describe it to anyone, in a sentence or two, and send it. Then reply as you naturally would: approve the edits you’d approve, rerun the report if you would, and say what you see. Decline any request to commit. Stop after three attempts, or sooner if the report looks right. Keep the session open.
Read Your Session for a Fix Loop
Compare your session with this example, written for this lesson rather than recorded. Your agent’s wording and fixes will differ:
You: The play-test report for the Lighthouse Keeper's
Study says one puzzle averages 64.5 minutes, but
teams took about 10. Can you fix it?
Agent: The average isn't rounded before it's printed.
I've rounded it in the report. It should be
right now.
You: Still wrong, it says 65.0 now.
Agent: The lines may be sorted on the wrong value. I've
changed the sort to use the rounded average.
The report still says 65.0. You’re about to type “Still 65.0, try again.” Before you open the answer, decide what the agent’s third attempt will be based on:
It works from the same wrong number it had at the start, plus two edits already stacked in your working tree. Your reply says the last guess failed, but not why, and the agent checked nothing itself, so it can only make a different guess.
In this example, the third attempt looks like a success:
Agent: One play-test record looks unusual. I've made
the report skip records it can't read cleanly.
The average is now 9.0.
The number looks believable, but one team’s play-test is no longer in the report. The change hides the symptom without explaining it. Nobody has said why the average was 64.5, and the rounding and sort changes are still in the code.
Each “still failing, try again” feels like a step closer, but it adds no new information. Unless the agent gathers some itself, by reading code, running a test, or printing a value, each attempt is another guess.
Meanwhile, the guesses pile up in your working tree, where later attempts build on earlier ones, and in the session’s context, where they shape what the agent tries next. A loop like this tends to end when a change makes the symptom disappear, not when someone finds the cause.
Now read your own session the same way. A few things could have happened:
- A rounding tweak, so the number changed but is still impossible
- A changed sort, so the lines moved but the average didn’t
- A filter or check that drops a record, so the number looks right
- An edit to the play-test file itself, so this report looks right but the next hand-typed record would break it again
- A clean fix that names a cause and explains the number
Any of these, a mix, or something else is normal. To tell whether it was a loop, read the whole session. Did your replies add anything beyond “it failed”? Did the checks the agent ran between attempts change its next edit? A loop is the same failure, edits stacked on guesses, and no new evidence from either of you.
Then list what changed with git status --untracked-files=all. Stage your agent’s changed and new files with git add, then read git diff --staged, which shows new files in full.
Read the diff for clues, and ask how each change connects to the cause the agent named and the checks it ran. Edits in unrelated places deserve a closer look, as does any change to the play-test file you committed. Code that silently skips a record hides the symptom, while code that rejects one with a message naming it says what’s wrong.
To get feedback on your session, paste your replies with what the agent did after each one, including any checks it ran:
If you’re unsure how your changes affected the report, paste your diff here:
Stop and Go Back to the Last Good Commit
In a loop, the next attempt starts from the same guesses. To get out, stop, clear the guesses away, and only then ask for the cause.
Stop. If your agent is still working, press the interrupt key and send nothing more in this session.
Keep what’s worth keeping. If your agent named a cause and the report now looks right, save the cause as a lead to check later. Copy the explanation and the changed lines from git diff --staged into notes outside your project folder, where the reset can’t touch them.
Go back to the last good commit. Do this even after a clean fix. Hand Over a Bug With Evidence, the debugging lesson after the next exercise, needs everyone to start from the same state. Here are Git’s undo commands, recapped in case you started here:
$ git status --untracked-files=all
$ git restore --source=HEAD --staged --worktree -- <file>
$ git clean -n -d -- <path>
$ git clean -f -d -- <path>
Run git restore for each changed or staged file. It puts tracked files back as your last commit had them and deletes new files you staged. For a new file or folder that’s still untracked, git clean -n shows what would go and -f deletes it. Name each path so Git keeps your other untracked files.
When git status shows nothing to commit apart from your agent’s settings files, you’re back at the last good commit. Rerun the report, and the impossible average will be back.
End the session. Exit your agent. The session’s context still holds every guess, so the next attempt belongs in a fresh session. If your agent loads saved memory, check it as you did when you last started fresh, and delete any note that records one of the loop’s guesses.
Before any more edits, you ask for the cause with evidence, a step Hand Over a Bug With Evidence takes in full. You might say something like “Don’t change any code yet. What could cause this number? List the possible causes, with the evidence for each.” That’s all you need about it for now.
To check your reset, paste your notes and the output of git status and git log --oneline -3:
Check Your Understanding
Try these questions before you open the answers:
- Your list-rooms command says The Harbourmaster’s Office can’t be finished, though
check-room.jssays it can. Your agent changed the order it reads the room files in, but the verdict was still wrong. Then it changed how each line is printed. Still wrong. You’re about to type “still failing, try again.” What will the next attempt be based on, and what do you do instead? - After four attempts, the report’s averages all look believable.
git diffshows a changed sort, a rounding change, and a new line that skips any record with more than 60 minutes on a puzzle. Has the agent fixed the bug?
- The next attempt will be based on the same wrong verdict and two stacked edits, so it’ll be another guess. Stop, go back to the last good commit with
git restoreandgit clean, and end the session. In a fresh one, ask for the cause with evidence before any more edits. - No. The skip line hides the symptom by dropping data, and nothing says why the average was wrong. The sort and rounding changes are leftover guesses. Go back to the last good commit.
You can now spot a fix loop and break it by stopping, going back to the last good commit, and leaving the session behind. Next, in Exercise: Spot the Fix Loop, you’ll read an example session from the play-test weekend and decide where it went wrong and where to go back to.