You're 40 minutes into a complex refactoring session with Claude Code when a thought strikes: "What if I tried a completely different approach?" But you don't want to lose everything you've built up — the files read, the decisions made, the tradeoffs discussed. One command solves this: /fork.

TL;DR
Build context /fork to duplicate Experiment in the copy Original stays intact Compare and choose

What Is It?

/fork is a command that copies your entire conversation history into an independent new session. Conceptually, it works exactly like git branch. The original branch (conversation) stays untouched, and from the fork point onward, each session can go in a completely different direction.

From the CLI, you can achieve the same thing with the --fork-session flag. Load an existing session with --resume or --continue, add --fork-session, and you get a brand new session ID with the full conversation history up to that point.

Key Analogy

--continue = writing on the same notebook (same session ID)
--fork-session = photocopying the notebook and writing in the new one (different session ID, same content)

According to the official docs, forked sessions don't inherit session-scoped permissions. This is an intentional security design — sensitive operations require re-approval in the new session.

What Changes?

The "I want to try a different approach" moment comes up more often than you'd think in Claude Code. Until now, you had two options: start a brand new session and rebuild all context from scratch, or push forward in the current session and hope for the best. Both are expensive.

New Session/rewind/fork
Existing ContextLost entirelyPartial rollbackFully preserved
Original SessionSeparateRolled backCompletely preserved
Experiment SafetySafe (isolated)Risky (hard to undo)Safe (isolated + preserved)
Token CostHigh (rebuild)LowMedium (history copied)
A/B ComparisonDifficultImpossibleNatural

The "Context Pre-Warming" pattern from the Trigger.dev blog illustrates this perfectly. Load 40K+ tokens of heavy context — architecture docs, API specs, coding conventions — into a master session once, then fork it for each feature. You completely eliminate the cost of rebuilding context every time.

How to Get Started

  1. Create a master session
    Launch Claude Code and load your project's core context. Have it read architecture docs, explore key files, and set coding rules. Then name it with /rename master-context.
  2. Interactive fork: /fork
    Inside a session, use /fork refactor-attempt to create a named fork. The original conversation stays intact while you experiment freely in the forked session.
  3. CLI fork: --fork-session
    Run claude --resume master-context --fork-session to fork directly from the terminal. Open new terminal tabs and fork the same master multiple times for parallel experiments.
  4. Compare and choose
    Try different approaches in each fork, compare the results, and continue with whichever direction you prefer. Discard the rest.

Warning: Never use the same session in multiple terminals

If you --resume the same session ID in multiple terminals, messages from both get interleaved. The conversation becomes jumbled when you resume later. For parallel work, always use --fork-session.

Real-World Patterns

Here are practical /fork patterns used by the community.

Pattern 1: Implementation A/B Testing

Fork the same master session twice and try different implementations in each. For example, one fork uses Redis caching while the other uses in-memory caching, then compare performance. Since the context is identical, any differences are purely from the approach.

Pattern 2: Review Response Session

Fork the session that created your PR to address review comments. You retain all the original context — why certain decisions were made, what alternatives were considered — while making the requested changes.

Pattern 3: Skills with context: fork

In Claude Code Skills, setting context: fork in the frontmatter runs the skill in an isolated sub-agent context. This lets you perform complex analysis without cluttering your main conversation.

/fork vs /btw vs /rewind — When to use what?

• Quick question without breaking flow → /btw (doesn't enter history)
• Try a different approach → /fork (preserves original, creates new session)
• Undo what you just did → /rewind (rolls back current session)