Interrupt and Redirect Early

In the last video, an example run of the list-rooms task went wrong at the planning stage. Step 1 called for a second checker, even though the task said to use checkRoom(). The agent hadn’t built anything yet, so it was the cheapest moment to step in.

In this lesson, you’ll run the same task on your own project and watch its first steps yourself. If your agent heads the wrong way, you’ll stop it and send a correction that names exactly what it should do instead, so it doesn’t have to guess a second time. Start by getting the project and your agent ready for the run.

Set Up a Run You Can Undo

Steering only pays off when you can see what changed and undo it. Start with these four habits, recapped in case you skipped them or started with this course:

  • The project: Use your own escape room builder, as you left it. If you’re starting here, download the reference version and read docs/brief.md and docs/map.md first. They say what the tool does, what it must never do, and where each part lives.
  • A checkpoint: Run git status in your project folder. If it says the folder isn’t a Git repository, which can happen with the download, then run git init, git add -A and git commit -m "Start from the reference version". Otherwise, commit anything left over, so that git status shows nothing to commit apart from any settings files your agent keeps in the project. Everything that changes after this is the run’s doing.
  • A fresh session: Your agent works only from what’s in its session and the files it reads. Start a new session in the project folder, so no earlier work shapes this run.
  • Approval before edits: Start your agent in a mode where it must ask before it changes a file. Then its first edit arrives as a prompt you can read before the file changes. The instructions for your agent below explain how.

Here’s the task from the video, written in the parts you give every task: the goal, where to look, the limits, and a done-when. If your project’s filenames or function names differ, change them to yours:

Language: Text
Add a list-rooms command that prints every room in
rooms/, one line each, with its verdict.

Read docs/map.md, then check-room.js and
src/check-room.js.

Use checkRoom() from src/check-room.js for each
verdict. Add no new dependencies. Don't change
check-room.js or its output, or any file in rooms/.

Done when the command prints one line per room, each
with the verdict check-room.js gives it, and npm test
passes. Then stop, list the files you changed, and
don't commit.

The last line matters if you use the reference version: its instruction file asks the agent to commit after each finished job unless the task says not to. Here you’ll review the changes and commit them yourself.

Your agent has an interrupt key that stops the current turn without ending the session, so the agent keeps everything it has read. Claude Code and Codex CLI also let you type a message while they work. Open the version for your agent to find the command that makes it ask before edits and the keys it uses. These were checked in December 2026 with Claude Code 2.1 and Codex CLI 0.173:

Start the session with claude --permission-mode manual. In this mode, Claude Code asks before every file edit, unless an allow rule in your settings already permits edits. When a prompt comes, approve only that edit. The option that allows all edits for the session stops the prompts for the rest of the run.

Press Esc to interrupt Claude Code. It stops what it’s doing and waits for your next message. You can also type a message and press Enter while it works, and Claude Code passes it on before its next step.

Start the session with codex --sandbox read-only --ask-for-approval on-request. The sandbox and the approval setting are separate. In the workspace-write sandbox, Codex edits project files without asking, whatever the approval setting.

The read-only sandbox blocks every write, so each edit comes to you as a request. Approving it lets that one change through. The option not to ask again for these files stops the prompts for later edits to those files, so approve each change on its own.

Press Esc to interrupt Codex. It stops the current turn and waits for your next message. You can also type a message while it works: Enter sends it into the running turn, which the Codex docs call steering, and Tab queues it for after the turn.

For this lesson, the interrupt key is the safer choice, because it stops the work while you think instead of letting it run on while you type.

Stop at the First Contradiction

You watch a run to catch a wrong turn while it’s still a single step, before it grows into a finished feature. As in the video, watch the files your agent opens, any plan it states, and its first edit. Check each one against the task’s limits, and step in at the first one that contradicts them.

Watch out: Letting a wrong run finish so you can fix it afterward doesn’t save the work it did. Every later step builds on the wrong choice. Stopping at the plan costs you one message, while stopping at the end costs a review and an undo of every file it touched.

Paste the task, send it, and watch. These are some of the ways a run of this task could go:

  • It plans or writes its own function to decide whether a room can be finished, instead of calling checkRoom().
  • It proposes installing a package to find the files in rooms/.
  • It edits a room file to “fix” it, or reformats one.
  • It changes what check-room.js prints.
  • It follows the task all the way through.

Your agent may do one of these, something else, or nothing wrong at all, and every one of those outcomes is normal. If it asks you to approve an edit that breaks a limit, decline it. Otherwise, press the interrupt key as soon as you see the contradiction. Before you type anything, run git status in your own terminal to see whether the run already changed or added files.

Write a Correction That Names Something

Once you’ve stopped the agent, your next message decides whether its second attempt is better than its first. “No, that’s wrong” tells it something failed, but not what to do instead, so it guesses again. A useful correction names at least one concrete thing:

  • A file: Where the work belongs, or which file to leave alone
  • A function: The existing code to use, such as checkRoom()
  • A rule: The limit it broke, quoted from your task or your brief
  • An example: The output you expect for one real room

Here’s an example correction for the run in the video, the one whose plan called for its own checker. It’s written for this lesson, not taken from a recorded session:

Language: Text
Stop. Don't write your own function to decide whether
a room can be finished. The task says to use
checkRoom() from src/check-room.js for each verdict.
Import it, and call it once per room file. Each line
should show the same verdict that
node check-room.js rooms/<file> gives that room.
Keep the rest of your plan.

The correction names the step to drop, the function and file to use, the rule from the task, and a way to check each line against output the project already produces. It also says what to keep, so the agent doesn’t throw away the parts that fit.

Undo before you redirect. If git status lists files from the wrong path, put them back first, so the next attempt doesn’t build on them. Then say in your correction what you put back, for example: “I’ve deleted src/room-list.js and restored package.json, so start from the files as they are now.” The session still holds the agent’s earlier view of the files, so without that sentence it may patch a file that’s gone.

git restore --source=HEAD --staged --worktree -- <file> puts a tracked file back as your last commit had it, dropping both its staged and unstaged changes.

For a new file or folder, git clean -n -d -- <path> shows what would go, and git clean -f -d -- <path> deletes it. Name each path, because without one git clean would also delete untracked files you want to keep, such as local settings. Keep the -d too, since git clean skips new folders without it. Track Your Project With Git covers git restore and git clean in more depth.

Write your own correction now. If your run never went wrong, write the one you’d send to the video’s agent. The button below opens Code Mentor with the question filled in. Paste your task, what the agent did before you stopped it, and your correction. For the video’s agent, use its plan step 1. You’ll get feedback on whether your correction could still be misread:

If you interrupted a wrong run, send your correction, then watch the new attempt’s first steps the same way: check its plan and first edit against the task’s limits, and decline any edit that breaks one. Once it’s on track, let it finish. If your run never went wrong, don’t send the practice correction, because it describes a mistake your agent didn’t make.

Either way, check the result yourself rather than trusting the agent’s final message, then commit:

  1. Run git status --untracked-files=all to list every changed and new file.
  2. Stage the files that belong to the task with git add, then read git diff --staged, which shows new files in full.
  3. Run npm test and the new command, and compare each line with the first line node check-room.js prints for the same room file, its verdict.
  4. When everything belongs to the task, run git commit -m "Add a list-rooms command".

Before you move on, look back at your call during the run. Paste your task and your agent’s first steps, then either where you stopped it and your correction, or why you let it continue:

Check Your Understanding

Answer these before you open the answers:

  1. You ask your agent to add a --json option to check-room.js that prints the same verdict as JSON. Your task says: “Use checkRoom() as it is. Don’t change it or what it returns.” The plan says: “1. Read src/check-room.js. 2. Rewrite checkRoom() so it returns an object. 3. Update check-room.js and the tests to match.” What do you do, and when?
  2. Your agent added a package to find the room files. You interrupt and type: “Don’t do that, keep it simpler.” Rewrite the correction so it names a file, function, rule, or example.
  3. You press the interrupt key after the agent has already created src/room-list.js and changed package.json. What do you do before you send your correction, and why?
  1. Interrupt as soon as you read the plan, before it edits anything. Step 1 fits, but step 2 rewrites checkRoom(), and your task says not to change it or what it returns. Then say what to do instead, for example: “Don’t change checkRoom(). Call it as it is and turn its result into JSON in check-room.js only.”
  2. One version: “Remove the package you added. The task says to add no new dependencies. List the files in rooms/ with readdirSync() from node:fs instead.” The correction names the rule the agent broke and what to use instead, so the agent doesn’t guess at what “simpler” means.
  3. Run git status, then undo the wrong path with the Git commands above: restore package.json and delete src/room-list.js. Otherwise the next attempt starts from a project that already holds the wrong choice, and your diff mixes both attempts. Then open your correction by saying what you put back, so the agent doesn’t work from files that are gone.

Your list-rooms command is committed, and you’ve practiced stopping a run at its first wrong step with a correction your agent can act on. Sometimes, though, you need to repeat a correction in the same session. Next, in Start Fresh With a Better Task, you’ll see why that happens and what to do instead.

Become a Member to join the conversation.