METAL LAB

Claude Code Reveals Six Ways to Steer Hours-Long Sessions

In a Claude Academy lesson, Anthropic explains how to manage long coding sessions, from plan mode to worktrees.

Claude Code Reveals Six Ways to Steer Hours-Long Sessions

Summary

  • Anthropic used the first lesson of its "Claude Code in Action" course on Claude Academy to explain how to steer coding tasks that run for hours.
  • It covers using plan mode to define scope before starting, then using compact and rewind to correct context and direction mid-execution.
  • The lesson also introduces goals for specifying completion criteria, interval-based execution loops, and worktrees to prevent conflicts between multiple agents.
Steering Claude Code Through Hours-Long Sessions: Plan Mode, Compact, Rewind, Goals

Losing direction on an hours-long task can make it take even longer

Anthropic official website

On the left, a seed-shaped plan mode node connects with an arrow to a long-running orbit-shaped node on the right. The long-running node links back via a bidirectional dashed arrow to a dotted-orbit steering-tools node, illustrating how tools like rewind, goal, and loop repeatedly correct drift that occurs during execution.On the left, a seed-shaped plan mode node connects with an arrow to a long-running orbit-shaped node on the right. The long-running node links back via a bidirectional dashed arrow to a dotted-orbit steering-tools node, illustrating how tools like rewind, goal, and loop repeatedly correct drift that occurs during execution.

Give Claude a short task and you'll see results fast. But something like refactoring dozens of files or building a new feature — work that can take hours — is a different story. The lesson points out that without proper direction, these longer tasks can end up taking even more time. Claude Code is Anthropic's command-line coding agent, an extension of the conversational AI Claude built for development work.

This video is the first of nine lessons in the "Claude Code in Action" course on Claude Academy. It's titled "Steering Hours-Long Claude Code Sessions: Plan Mode, Compact, Rewind, Goal" and is available on YouTube.

Built on a string of recent Claude Code updates

This lesson didn't come out of nowhere. On August 23, guidance that condensed Andrej Karpathy's critiques of LLM coding into a single CLAUDE.md file drew attention in the developer community. Against a backdrop of Claude Code steadily gaining new tools, this lesson essentially pulls those tools together into a guide for staying on track during extended use.

Define scope before you start, steer once you've begun

The video lays out two habits for handling long tasks. The first is setting scope before Claude starts working. Turning on plan mode has Claude do read-only research without touching code and then produce a plan; the lesson explains that reading that plan carefully and asking for revisions where needed lowers the odds of problems during execution. The core idea is that it's much faster to iterate on the plan itself than to just hope for good results after setting one.

The second habit is steering — guiding direction while the task is already underway. Four specific tools come up here.

How to use them

Compact summarizes the conversation so far and uses that summary as the new context, clearing the old conversation and freeing up the context window (the amount of information the AI can hold and read at once). But if something important gets dropped during summarization, Claude risks veering off course — so when you run the compact command, adding a note about what changes you want gives Claude a standard for deciding what to keep and what to cut. If debugging is done and you only want to keep the API changes, you can instruct it to do exactly that.

Rewind lets you jump straight back to the last checkpoint instead of trying to correct a wrong turn through more prompting. Pressing Esc twice on an empty prompt opens the rewind menu, and a new checkpoint is created each time you enter a prompt. From that menu you can choose to revert just the code, just the conversation, or both, and you can also summarize only what happened after the checkpoint or only what came before it. It's a useful way to drop a long setup phase and keep only the actual implementation.

Goal lets you describe completion criteria in advance, so Claude keeps working across multiple turns and only stops once a fast evaluation model confirms the criteria have been met. If you set a condition like "all tests pass and the type checker reports zero errors," Claude finishes the task when that condition is actually true — not whenever it first feels done. Since the evaluation model only reads the conversation history, though, the criteria need to be things that can be verified from the output. To cancel a goal, you type /goal clear.

Loop repeatedly runs a prompt at fixed intervals or at intervals Claude decides on its own. It's useful for continuously checking something that changes externally — like CI run results or deployment status — and acting once the state changes; pressing Esc stops it.

Finally, when running multiple agents on the same codebase at once, you need worktrees. Just as a car with two steering wheels is dangerous, multiple Claude sessions can't be allowed to collide over the same files, so each session gets its own independent file tree to prevent conflicts. Clean worktrees are deleted automatically once a session ends, and listing files in a .worktreeinclude file at the repository root lets you specify environment variable files or local settings that should be copied into each worktree without being checked into version control.

Six tools, six different moments to use them

ToolWhen to use itWhat it does
Plan modeBefore starting a taskRead-only research, then presents a plan
CompactWhen context fills upFrees context via summary; instructions set what's kept
RewindWhen direction goes wrongReverts code and/or conversation to a checkpoint
GoalWhen completion criteria can be describedRuns multiple turns automatically until criteria are met
LoopWhen monitoring external stateRepeats a prompt at intervals
WorktreeWhen running multiple agents at oncePrevents conflicts with independent file trees

Also covered

Lesson 4 of the Claude Code in Action course, titled "Claude Code Permission Modes: Letting Go with Auto Mode," covers the fact that Claude Code originally had six permission modes before auto mode became the default. The lesson explains that each mode draws a different line for which tasks Claude can carry out on its own and which require user approval. Like the others, this lesson was released with an accompanying text version alongside the YouTube video.

Lesson 6 of the Claude Code in Action course, titled "Automating Claude Code with Routines and Headless Mode," covers two ways to automate Claude Code: routines, which are stored prompts that run in the cloud, and headless mode, which runs Claude Code from a script the user writes.

Lesson 8 of the Claude Code in Action course, titled "Learning to Trust Unwatched Claude Code Runs," covers how to build trust in unattended runs left in auto mode by checking what was done after the run finishes, rather than watching it happen.

Editor's view

What makes this lesson notable isn't a new feature — it's that Anthropic pulled existing capabilities together to answer a practical problem: how to manage long-running work. With auto mode becoming the default last month, Claude Code moved toward acting on its own without approval at every step, and as the amount of unsupervised time grows, having a safety net to reverse course when things go off track matters more. Rewind, goal, and loop function as that safety net, and this lesson looks like the first attempt to lay out, in order, when and how to combine them.

In practice, treating a one-off short prompt the same way you'd treat an hours-long refactor tends to cause the same problems every time. The long version almost always hits a point where context overflows, the wrong files get edited, or it becomes unclear whether the task is actually done. Narrowing scope up front with plan mode and securing rewind points along the way means recovering from that point takes seconds instead of starting over from scratch. Development teams handing off a big refactor might do well to first practice writing completion criteria as verifiable statements — things like "tests pass" or "type check succeeds" — since without that kind of statement, the goal feature can't be used at all.

The eight lessons still to come will likely cover topics like context management and navigating large codebases. If you've only used Claude Code for short tasks so far, this lesson looks like a natural entry point into running it for hours-long automation.

Comments