| |

Claude Code Fork Explained (Dec 2026): /fork vs /branch vs /subtask vs context: fork, and Which One Works Unattended

Two glowing teal glass paths curving apart on a dark floor with an amber glass sphere where they meet, the cover image for a Claude Code fork explainer

Search Claude Code fork and the top two explainers contradict each other. One says /fork starts a new independent session. The other says it copies your conversation into a background agent, and that the thing it used to do is now called /subtask. They’re both right. They’re describing different versions of the same CLI.

Claude Code uses the word “fork” for at least four different things, and one command, /fork itself, has changed meaning three times since it shipped. This guide pins every one of them to a version number from Anthropic’s own changelog, which I read on 4 December 2026 (the newest release then was v2.1.335). Then it answers the question nobody else covers: which of these forks still work when nobody is at the keyboard.

That last part isn’t theory for me. My agent fleet has made 2,331 scheduled runs since 12 June 2026, every one of them a headless claude --print call from a cron dispatcher. So I tested every fork in that exact mode, on the CLI version my containers really run (v2.1.292), and I’ll show you what came back.

Claude Code Fork: The Short Answer (Four Features, One Word)

Five frosted glass shapes in a row on a dark surface: a sphere, cube and cylinder lit teal, and a cone and square slab lit amber

When someone types “Claude Code fork” into a search bar, they mean one of these. The difference that matters is the same every time: what does the copy inherit, and who keeps working on it?

What you typeWhat it copiesWhere you end upReports back?Own files?
/fork [prompt] (agent view on)The whole conversation, into a new background sessionYou stay put. The copy is its own row in agent viewNoTold to make its own git worktree (v2.1.221+)
/branch [name]The whole conversationYou switch into the copy. The original waits in /resumeNoNo. Same checkout
claude --resume <id> --fork-sessionThe whole conversation, under a new session IDA new process, from the command lineNoNo. Same checkout
/subtask <task> (a “forked subagent”)The whole conversation, plus the same tools and modelYou keep working. It runs in the backgroundYes, its final result onlyNo, unless spawned with isolation: "worktree"
context: fork in a skillNothing. A fresh subagent gets the skill text as its promptYou keep workingYes, when it finishesNo

Two of those surprise people. First, context: fork doesn’t fork your conversation at all. Anthropic’s skills docs say so in as many words, and I’ll come back to it. Second, none of the conversation forks copy your files. Every one of them edits the same project folder unless a worktree gets involved.

There’s also a fifth meaning that has nothing to do with sessions: forking a GitHub repo called claude-code-something. I’ll deal with that in the FAQ so it stops polluting the results.

If you only need one rule: want a second opinion that knows the whole story and reports back? /subtask. Want to try a different direction yourself? /branch. Want a parallel session that runs on its own? /fork.

How /fork Changed Meaning Three Times (and Why Old Tutorials Disagree)

Three frosted glass plates floating and rising left to right, tinted dark teal, light cyan and amber, wrapped in faint looping light ribbons

This is why the search results argue with each other. I pulled every fork-related line out of the official Claude Code changelog. Here’s the timeline that matters:

VersionWhat changed
2.0.73--fork-session already exists. This release lets you pick a custom ID for the forked session with --session-id
2.1.0Skills and slash commands can run “in a forked sub-agent context” with context: fork in the frontmatter
2.1.77“Renamed /fork to /branch (/fork still works as an alias)”. Meaning #1: fork = branch the conversation
2.1.117Forked subagents can be switched on with CLAUDE_CODE_FORK_SUBAGENT=1
2.1.121That env var now works in claude -p and the SDK too
2.1.212“/fork now copies your conversation into a new background session… the in-session subagent it used to launch is now /subtask“. Meaning #2 (fork = forked subagent) ends, meaning #3 (fork = background session) begins
2.1.218context: fork skills run in the background by default (opt out with background: false)
2.1.221Sessions made with /fork create their own worktree instead of editing your checkout
2.1.232Fork mode on by default in the interactive terminal (per the sub-agents docs)
2.1.257/fork keeps the original conversation’s prompt cache in the new session
2.1.302Fork subagents on by default in claude -p, the Agent SDK, the desktop app and VS Code
2.1.330VS Code gets its own /fork “to fork a conversation after its last reply”

So a tutorial written in spring 2026 says /fork branches your chat. One written in late summer says it launches a subagent that reports back. One written after 2.1.212 says it spins off a background session. Same command, three behaviours. I couldn’t find the exact release where /fork stopped being a /branch alias and became the subagent launcher. The changelog only confirms it had happened by 2.1.212. I’d rather tell you that than invent a number.

There’s one more trap. If you turn agent view off, /fork goes back to starting a forked subagent and /subtask disappears. The commands reference says this in both rows. So even on today’s version, the answer to “what does /fork do?” starts with “which settings are you on?”

Check yours with claude --version before you trust any guide, this one included. My Claude Code cheat sheet has the rest of the commands, checked against the same docs.

/fork vs /branch vs –fork-session: Copying the Conversation

Two tall frosted glass slabs side by side, the left one grey-teal and the right one glowing warm amber, with a thin cyan line of light behind both

All three of these make a full copy of the conversation. They differ in where the copy runs and who drives it.

/branch: you move into the copy

/branch try-streaming copies the transcript and switches the running process to write to the copy. The original stays on disk and shows up in /resume. If you don’t give it a name, Claude Code names it after the first prompt in the conversation. The confirmation prints both session IDs, so copy the original’s ID somewhere if you plan to go back.

Because it’s the same process, the sessions docs list a few things that follow you into the branch:

  • Your “allow for this session” permission grants carry over.
  • Background subagents and background Bash commands that were already running keep running, and “their output appears in the new branch you switched into, not in the original session.”
  • A phone or browser connected through Remote Control follows you into the branch.

That second point catches people out. Start a long test run, /branch to try something else, and the test results land in the branch, not in the conversation that asked for them.

/fork: the copy runs without you

/fork copies the conversation into a new background session and leaves you where you were. Give it a prompt and the copy starts on it right away. Without one, it sits in agent view waiting for its first instruction. Nothing the copy does flows back into your conversation. It’s a separate session that you check on later.

The docs add one limit worth knowing: sessions started with launch flags the copy wouldn’t inherit (a replaced system prompt, a --tools allowlist) can’t be forked this way.

–fork-session: the same idea from the command line

claude --resume <id> --fork-session (or claude --continue --fork-session) loads an old conversation under a new session ID and leaves the original untouched. It’s the only one of the three that’s a launch flag rather than a slash command, which is why it matters for automation. More on that in the headless section.

One difference from /branch: the new process “starts without” your session permission grants, “and you re-approve there.” And one rule that applies to everyone running parallel terminals: if you resume the same session in two terminals or two claude -p runs at once, both write to one transcript, and messages from one of them can go missing. Anthropic’s fix is to add --fork-session to each command. That’s the single most useful sentence on the sessions page.

Holographic AI playbook glowing teal above a dark surface

Get the AI Playbook

The playbook I use to decide which work goes to an AI agent first, which tool it belongs in, and how to check it actually ran. Free, unsubscribe anytime.

Lead Magnet - AI Playbook

Forked Subagents: /subtask and Fork Mode

A large frosted glass sphere joined to a smaller sphere, with a cyan trail carrying a small amber light from the small sphere into the large one

A normal subagent starts from zero. It gets a task and its own tools, but none of your conversation. That’s great for research and review, where you want a clean pair of eyes and a short summary back. It’s terrible when the task depends on twenty minutes of decisions you’d have to re-explain.

A forked subagent fixes that. In Anthropic’s words from the sub-agents docs, “a fork is a subagent that inherits the entire conversation so far instead of starting fresh.” It gets the same system prompt, tools, model and message history as the parent. Its own tool calls stay out of your conversation, and only its final result comes back as a message.

You start one yourself with /subtask:

/subtask draft test cases for the parser changes we just agreed on

That works “whether or not fork mode is on.” Fork mode is the separate setting that lets Claude decide to spawn forks on its own. It’s on by default from v2.1.302 (v2.1.232 in the interactive terminal), and CLAUDE_CODE_FORK_SUBAGENT=0 turns it off.

When a fork beats a fresh subagent

  • The task needs the backstory. “Write tests for what we just decided” only makes sense if the tester heard the decision.
  • You want to try two approaches from the same starting point. Fork twice, compare the results.
  • Cost. A fork’s system prompt and tool definitions match the parent’s exactly, so its first request reuses the parent’s prompt cache. The docs say this makes a fork “cost less than a fresh subagent for tasks that need the same context.”

When it’s the wrong tool

  • Reviews. A reviewer that inherited all your reasoning will tend to agree with it. For a second opinion, a fresh subagent is more honest.
  • Long, messy sessions. The fork inherits the mess too, including the dead ends.
  • Nested work. “A fork can’t spawn further forks.” Plan the fan-out from the main session.

If you’re deciding between forks and full parallel teams, my Claude Code agent teams guide covers when parallel agents pay for themselves and when they’re just burning tokens.

context: fork in Skills: The Fork That Doesn’t Fork

An open frosted glass box holding one blank glass tablet, with a tangle of glowing amber wire lying on the floor outside the box

This is the one that trips up skill authors. You’d assume context: fork in a skill’s frontmatter means “run this in a fork of my conversation.” It doesn’t. Straight from the skills docs:

Jon Jones

⚡ GET THE AI EDGE

Weekly AI tips that actually save you time and money. No fluff, no hype — just what works.

Newsletter Signup - Blog CTA

“Despite the name, a skill with context: fork doesn’t run in a fork of the current conversation, which would hand the subagent everything you’ve discussed so far. When the task depends on that history, fork the conversation instead of using context: fork.”

What it actually does: Claude Code starts a new subagent of whatever type you set in the agent field (general-purpose if you leave it out) and hands it the skill’s content as its prompt. The subagent never sees your chat. So the skill has to stand on its own:

---
name: weekly-link-audit
description: Check every internal link in /content and list the broken ones
context: fork
agent: Explore
background: false
---
Crawl every Markdown file under /content. For each internal link,
confirm the target file exists. Return a table of broken links
with the file and line number. Do not edit anything.

A few rules worth knowing:

  • Give it a task, not guidelines. The docs warn that a skill full of conventions (“use these API patterns”) with no actual job returns “without meaningful output.”
  • Background by default since v2.1.218. Set background: false if the next step needs the result. In claude -p and the Agent SDK, Claude Code waits for the result anyway.
  • Interactive tools have been flaky inside it. In April 2026 one open-source team removed context: fork from two skills because AskUserQuestion and other deferred tools weren’t loading in forked skill contexts (upstream issue anthropics/claude-code#54892). Test any skill that needs to ask you something.

Rule of thumb: context: fork is a fresh, isolated worker with a fixed brief. /subtask is a worker who heard everything. If you want templates for the first kind, I audited 423 Claude agent templates and the patterns that hold up are in there.

Conversation Isolation Is Not Filesystem Isolation

Two separate glass bell domes with teal light inside, both standing on one shared glowing amber base

This is the part of Claude Code fork behaviour that costs people real work. Credit where it’s due: Piotr Kaluzny at Cybrec put this in one line, and it’s the most important idea in this whole topic. Every fork above separates conversations. Almost none of them separate files.

The Agent SDK sessions docs are blunt about it: “Forking branches the conversation history, not the filesystem. If a forked agent edits files, those changes are real and visible to any session working in the same directory.”

Here’s who touches what:

  • /branch and --fork-session: same folder, same files. Two branches editing the same file will overwrite each other.
  • /subtask forks: same folder by default. When Claude spawns one through the Agent tool it can pass isolation: "worktree", which writes the fork’s edits to a separate git worktree.
  • /fork background sessions: since v2.1.221 the copy is told to make its own worktree before changing code, unless it’s set to edit in place. Note the word “told”. It’s an instruction to the model, which is why the docs describe it that way.
  • context: fork skills: same folder.

If you want real file isolation, don’t rely on the fork. Start the session in a worktree yourself with claude --worktree (-w), or git worktree add before you launch. And if the work might need undoing, commit before you fork. Git is the undo button that every copy shares.

This is also why I keep my agents’ long-term memory in files rather than in any one conversation. A fork copies the chat. A file is visible from every copy. The reasoning is in my Claude Code memory breakdown.

Which Claude Code Fork Works Unattended? What I Ran in claude -p

A long row of frosted teal-lit glass cubes on a dark rail, with one empty clear glass cube at the front of the line

Every guide on Claude Code fork assumes you’re sitting at a terminal. Mine mostly aren’t. My fleet runs on a schedule inside Docker containers, so the real question for me is what survives claude -p with nobody there to type.

On 4 December 2026 I tested each one on v2.1.292, the version in my containers, using Haiku and throwaway prompts. The whole test cost a few cents in tokens. Results:

Test in claude -pResult
Prompt /fork summarize nothing/fork isn't available in this environment. 0 turns, $0
Prompt /branch/branch isn't available in this environment.
Prompt /subtask list files/subtask isn't available in this environment.
Session A: “remember codeword AMBER-7”. Then --resume A --fork-session: “new codeword TEAL-3, list all”New session ID. Answer: AMBER-7, TEAL-3. It inherited the history
Then plain --resume A: “list all codewords”Same ID as A. Answer: AMBER-7. The original never saw TEAL-3
Ask for valid subagent_type values (default env)claude, Explore, general-purpose, Plan, statusline-setup, web-fetch. No fork
Same, with CLAUDE_CODE_FORK_SUBAGENT=1Same list plus fork

So, for any Claude Code fork in headless and scheduled work:

  • The slash-command forks don’t exist. /fork, /branch and /subtask are interactive features. In -p they return a one-line refusal and do nothing.
  • --resume <id> --fork-session works and does exactly what the docs say: a new ID, the old history, and the original left untouched. If you run two scheduled jobs off the same base session, this is how you stop them writing into one transcript.
  • Forked subagents depend on your version. Before v2.1.302 they’re off in -p unless you set CLAUDE_CODE_FORK_SUBAGENT=1. From 2.1.302 they’re on. My containers are 43 releases behind v2.1.335, so they still get the old default. If you upgrade a pipeline across 2.1.302, its subagent behaviour can change without you touching a line.
  • context: fork skills work headless. Claude Code just waits for the result instead of running it in the background.
  • The Agent SDK has the same thing in code: resume=session_id, fork_session=True in Python, forkSession: true in TypeScript.

What my fleet actually uses instead

None of the above, on purpose. All 2,331 run logs since 12 June come from the same dispatcher line: one fresh claude --print per job. Zero of them use --resume or --fork-session. Each job reads its state from files and Airtable when it starts and writes its results back before it exits. No job depends on a conversation that might have been compacted, branched or overwritten.

That’s the honest takeaway for unattended work. Forking is a tool for a human juggling ideas in a live session. A scheduled agent is better off starting clean and keeping its memory somewhere every run can read. I cover the rest of that setup in Claude Code best practices from four months of unattended runs, and why the fancy interactive features never fire in a cron fleet in my Ultracode breakdown.

Claude Code Fork FAQ

What’s the difference between /fork and /branch in Claude Code?

Both copy the whole conversation. /branch switches you into the copy and parks the original in /resume. /fork leaves you where you are and runs the copy as a separate background session in agent view. Neither reports back into your conversation. On versions before 2.1.77, /fork was what is now /branch.

What does /subtask do?

It starts a forked subagent: a background worker that inherits your full conversation, does one task, and sends back only its final result. Before v2.1.212 this was what /fork did. With agent view turned off, /subtask isn’t available and /fork does this job instead.

Does context: fork give the skill my conversation history?

No. Despite the name, it starts a fresh subagent (type set by the agent field) with the skill’s text as its prompt. If the skill needs your conversation, use /subtask instead.

Can I merge a fork back into the original session?

Not as a merge. The docs describe creating branches and returning to either one, but nothing that combines two sessions. A /subtask fork is the exception in spirit: its final result arrives as a message in your conversation. For everything else, copy the conclusion into a file both sessions can read.

Do forks copy my files or give me a separate git branch?

Mostly no. Forks copy the conversation, not the project folder. Only /fork background sessions (told to create a worktree since v2.1.221) and forks spawned with isolation: "worktree" keep their edits separate. Everything else edits your working copy.

Does Claude Code fork work in claude -p or cron jobs?

The slash commands don’t: /fork, /branch and /subtask all reply “isn’t available in this environment.” claude -p --resume <id> --fork-session works, and so does the Agent SDK’s fork_session. Forked subagents are on by default in -p from v2.1.302.

Is “claude-code-fork” on GitHub the same thing?

No. Repos with names like claude-code-fork are forks of code by third parties, not the session feature, and they aren’t Anthropic’s. Codex CLI also has its own /fork command, which is a different product. And in the Claude chat apps, editing an earlier message branches that chat, which again is a separate thing from Claude Code.

Final Thoughts: Pick the Fork by What It Inherits

“Claude Code fork” is one phrase covering four features, and the changelog shows it’s still moving. Don’t memorise the commands. Ask two questions instead: should the copy know everything I know, and who keeps working on it?

  • Knows everything, reports back to me: /subtask.
  • Knows everything, I take it in a new direction: /branch.
  • Knows everything, runs on its own: /fork, or --fork-session from a script.
  • Knows nothing but its brief: context: fork or a plain subagent.

Then remember the line from Cybrec: conversation isolation is not filesystem isolation. If two copies can touch the same files, give them separate worktrees or expect collisions. And if it has to run at 3am with nobody watching, skip the slash commands entirely. Start clean, keep the state in files, and use --fork-session only when two jobs really need the same history.

If you’re running Claude Code unattended and want a second pair of eyes on how your sessions, permissions and state are wired, that’s the kind of build I do. Start with the Claude Code harness walkthrough to see what mine looks like, and the –dangerously-skip-permissions guide for the safety side.

Holographic AI playbook glowing teal above a dark surface

Get the AI Playbook

Every week: one real job my agents ran unattended, what it cost, and what broke anyway. Receipts, not predictions. Unsubscribe anytime.

Lead Magnet - AI Playbook
The AI Playbook — Free Download

📥 FREE: THE AI PLAYBOOK

The exact tools and workflows I use to run a one-person agency. 25 years of marketing experience distilled into an actionable guide. Yours free.

Lead Magnet - AI Playbook

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *