Plans, Goals & Checkpoints
Beyond one prompt and one answer, pw code can plan before it changes anything, keep working until a condition you set is met, repeat a prompt on a schedule, and roll code and conversation back to an earlier prompt.
Plan Mode
In plan mode the agent researches and writes a plan instead of changing your code. It can read and search files and run shell commands that do not modify anything, and the only file it may write is its plan. See Plan Mode for exactly what is allowed.
Enter plan mode in any of these ways:
- Press Shift+Tab until the permission line shows
⏸ plan mode. - Start with
pw code --permission-mode plan. - Run
/plan, or/plan <description>to switch and start planning that task in one step.
| Command | Effect |
|---|---|
/plan | Switch to plan mode, and show the session's plan if it has one. |
/plan <description> | Switch to plan mode and send the description as the next prompt. |
/plan open | Open the plan file in your editor. |
Plans are saved as markdown files under ~/.local/state/pw/plans/, named after your request. The plan stays with the session, so /plan shows it again after you resume. /plan works from the main session, not from a subagent's window.
Approving a Plan
When the plan is ready, the agent asks you to approve it. The prompt shows the plan and three choices:
- Yes, clear context and auto-accept edits: Clear the conversation and start building the plan in
accept-editsmode, with the plan as the starting point. - Yes, auto-accept edits: Keep the conversation and switch to
accept-editsmode. - Tell the agent what to change: Type feedback and press Enter to send it back; the agent revises the plan and asks again.
| Key | Action |
|---|---|
| ↑/↓ or k/j | Move between choices. |
| 1-3 | Jump to a choice. |
| Enter | Confirm the highlighted choice. |
| Shift+Tab | With feedback typed, approve the plan and pass the feedback along as a note. |
| Ctrl+G | Edit the plan in your editor ($VISUAL, then $EDITOR); your edits become the plan. Not available in an attached session. |
| PgUp/PgDn, Home/End | Scroll the plan. |
| Esc | Decline; the agent stays in plan mode. |
In a non-interactive run, approval is always declined and the run prints where the plan was saved.
Goals
/goal <condition> keeps the agent working until a condition is met. The agent starts right away, and after every turn a separate check reads the conversation and decides whether the condition holds. If it does not, the agent takes another turn, guided by what the check found missing.
/goal all tests in ./parser pass and go vet is clean, or stop after 20 turnsThe check cannot run commands or read files: it judges only what the agent showed in the conversation, so state the condition in terms the agent can prove, such as a command's exit status. Bound the loop in the condition itself, with a turn or time limit; the check honors it even when the work is unfinished. Conditions are limited to 4,000 characters.
| Command | Effect |
|---|---|
/goal <condition> | Set the goal and start working toward it. Replaces any current goal. |
/goal | Show the current goal, or the one most recently achieved. |
/goal pause | Stop the loop but keep the condition. hold also works. |
/goal resume | Pick a paused goal back up. continue also works. |
/goal clear | Stop working toward the goal. stop, off, reset, none, and cancel also work. |
/goal takes effect immediately, even while a turn is running. Interrupting a turn with Esc or Ctrl+C pauses the goal; run /goal resume or send a prompt to continue. While a goal is set, ◎ /goal active (elapsed) or ◎ /goal paused shows above the composer, and when the check passes the transcript reports the time, turns, and tokens it took.
The goal is saved with the session and survives a resume. Each check is an extra model request. To run a goal from a script, see Running a Goal.
Loops
/loop repeats a prompt in the session:
/loop 10m check the deploy and report any failed pods
/loop run the flaky test again and dig into any failure
/loop- With an interval (
30s,5m,2h,1d, or a trailingevery 2 hours), the agent creates a recurring scheduled task for the prompt. Intervals are converted to a cron schedule, so seconds round up to one minute. - Without an interval, the loop paces itself: after each pass, the agent picks a delay from 1 to 60 minutes before the next one, and stops when the work is done.
- Without a prompt, a maintenance prompt runs: continue unfinished work from the conversation, then tend to the current branch's pull request (review comments, failed CI runs, merge conflicts), and otherwise do a focused cleanup pass. To replace it, write your own prompt in
.claude/loop.mdin the workspace, or in~/.claude/loop.mdfor every workspace.
Ask the agent to list or cancel scheduled tasks at any time. A session holds up to 50 scheduled tasks, and recurring tasks expire after 7 days. Tasks fire while the session is hosted by the background daemon, so they keep running after you quit pw code. Set the CLAUDE_CODE_DISABLE_CRON environment variable to 1 to turn off /loop and scheduled tasks entirely.
Rewinding to a Checkpoint
pw code takes a checkpoint each time you send a prompt in the main session, keeping the 100 most recent. To go back to one, run /rewind, or press Esc twice at an empty prompt. Pick a prompt from the list, newest first, then choose what to restore:
| Choice | Effect |
|---|---|
| Restore code and conversation | Undo file changes made since that prompt, and remove that prompt and everything after it from the conversation. |
| Restore conversation | Remove that prompt and everything after it, leaving files as they are. |
| Restore code | Undo file changes made since that prompt, keeping the conversation. |
The code choices appear only when files changed after that prompt. When the conversation is restored, the prompt is put back in the composer so you can edit and resend it.
What code restore covers
Code restore undoes changes the agent made with its file-editing tools. Changes made by shell commands, by you, or by other programs are not tracked.
/rewind is available only from the main session, and waits for a running turn to finish.
Related Documentation
- pw code Overview: Feature overview and quick start
- Permissions: Permission modes, including plan mode
- Slash Commands: All built-in commands
- Non-Interactive Mode: Goals and plans in scripts
- Interface & Shortcuts: Keyboard shortcuts
- Remote Control & Agents: The background daemon that runs scheduled tasks