When a side task shows up in the middle of a Claude Code session, you can keep it out of the main conversation in several ways. They differ in who drives the side task, whether its file edits are isolated, how much context it starts with, and where its result ends up. Each command is explained in Branching a session.
/branch | /fork | /subtask | /btw | Fresh session or /clear | |
|---|---|---|---|---|---|
| What you get | A copy of the conversation, and you switch into it | A copy running as a separate background session | A background subagent that inherits the conversation | One answer in an overlay | An empty conversation |
| Who drives it | You | The copy, on its own; you can attach | The subagent | Nobody, single response | You |
| Starts with | The whole conversation | The whole conversation | The whole conversation | The whole conversation, read-only | Only CLAUDE.md and memory |
| Tools | All | All | Same tool pool as the main session | None | All |
| File edits | Same files as the original | Its own git worktree (in a git repo) | Same working directory as the session | None | Same files |
| Result goes | Stays in the branch; /resume the original | Stays in the copy; nothing comes back on its own | Arrives as a message in your conversation | Never enters the history | Stays there |
| Main context | Untouched (you left it) | Untouched | Only the final result is added | Untouched | Gone, unless you go back with /resume |
When to pick which
- You want to steer the side task, give input and test by hand:
/branch. You work in the copy and come back with/resume. Keep in mind the files are shared. - The side task can run unattended and should leave its own commits:
/forkwith a prompt. It works in its own worktree; check on it inclaude agents. - You need the answer here, in the current task (tests for code you just changed, a quick investigation):
/subtask. Only the result lands in your context. - You just want to ask something about the session:
/btw. Nothing is added to the history; pressfin its overlay to turn the question into a forked subagent if it needs tools. - The session is full of noise or failed attempts: start fresh with
/clearor a new session and a short summary. Every copy above inherits that noise. The Claude Code best practices suggest clearing after two failed corrections on the same issue.
All copies spend their own tokens from the same usage limits, though their first request reads the original’s prompt cache.
Related
- Branching a session: each command in detail, with examples and gotchas.
- One task per session: the rule these commands help you keep.
- Managing context: everyday habits for a lean session.