context: fork

Claude Code

Definition

A skill frontmatter option in Claude Code that launches the skill inside a fresh, isolated context window — separate from the parent session's conversation history. The forked context accumulates its own tool calls and intermediate reasoning without touching the parent window; only the skill's final output is returned. The forked history is discarded when the skill completes.

Example Usage

Add `context: fork` to any skill that performs broad exploration (reading dozens of files, iterating over search results) so that its intermediate work does not accumulate inside the main session's context window.

Why It Matters for the CCA-F Exam

The exam tests whether candidates understand what `context: fork` isolates (conversation history / context window), what it does NOT isolate (filesystem writes — those persist), and how it differs from `context: current` and `context: none`. Expect a scenario question asking which frontmatter setting prevents a skill's verbose intermediate output from inflating the parent session's token usage.

In Depth

What `context: fork` controls

Every Claude Code session maintains a growing conversation window — every message, tool call, and tool result accumulates there. Long skills that read many files or iterate over search results can push hundreds of thousands of tokens into that window before returning a useful answer. That bloat consumes context space and dilutes the signal the model needs to continue the main task.

context: fork addresses this directly. It tells Claude Code to spin up a fresh, isolated context for the skill run. The forked context starts with no prior conversation history and accumulates its own intermediate work there. When the skill completes, its final output is passed back to the parent session as a single return value; the entire forked history is discarded. The parent window grows by exactly one message: the skill's answer.

Context modes compared

ValueWhat the skill sees on entryIntermediate work
context: current (default)Full parent historyAppended to parent window
context: forkFresh empty historyDiscarded on completion
context: noneNo historyDiscarded on completion

fork is the right choice when the skill needs its own working space but should return a result to the caller. none is stricter — use it for fully stateless, fire-and-forget tasks.

The subprocess analogy

Think of context: fork as spawning a child process with a clean environment: it runs, writes its result to stdout, and exits. The parent receives that stdout; whatever the child did internally stays local to it.

Critical gotcha: filesystem writes are not rolled back. If a forked skill calls Write or Edit, those changes persist on disk after the fork ends. Context isolation covers conversation history only — it is not a transaction boundary. Use allowed-tools to restrict which tools the skill may invoke.

The parent-history gotcha

A forked skill starts with an empty conversation history, not a copy of the parent's. It cannot read prior user messages or earlier tool results. If the skill needs parent-session context, pass it explicitly in the invocation prompt via $ARGUMENTS — the fork does not inherit it automatically.

When to reach for `context: fork`

  • Skills that read many files or iterate over large result sets
  • Reusable team skills where context-cleanliness guarantees matter across diverse parent sessions
  • Any skill whose intermediate reasoning is implementation detail, not user-facing signal

Example

A skill using `context: fork` in its YAML frontmatter. The skill reads freely via Read and Glob, but its entire working context — all intermediate tool calls and reasoning — is discarded when it finishes. The parent session receives only the final 300-word summary.

markdown
# .claude/skills/summarize-module/SKILL.md
---
description: "Summarize a module's public API and dependencies"
context: fork
allowed-tools:
  - Read
  - Glob
---

Analyze the module in $ARGUMENTS. Return:
1. Public exports (functions, types, constants)
2. External dependencies
3. Key design patterns observed

Keep the summary under 300 words.

How It's Tested & Common Confusions

On the CCA-F exam, context: fork appears in scenario questions asking candidates to choose the correct frontmatter for a skill with specific isolation requirements. Common distractors: confusing context: fork with plan-mode (different purpose — plan mode prevents writes; fork prevents context bloat), or assuming a fork rolls back filesystem changes (it does not).

Frequently Asked Questions

Does `context: fork` roll back file writes made by the skill?

No. Context isolation applies to conversation history only. Any files the skill writes or edits during its run persist on disk after the fork ends. To prevent writes, restrict the `allowed-tools` field to read-only tools like `Read` and `Glob`.

Can a forked skill see the parent session's conversation history?

No. A forked skill starts with a completely empty conversation history — it does not inherit the parent's prior messages or tool results. If the skill needs context from the parent session, pass it explicitly in the invocation prompt or as an argument via $ARGUMENTS.

What is the difference between `context: fork` and `context: none`?

Both give the skill a clean context window with no parent history. The distinction is intent and lifecycle: `fork` implies the skill operates within the session and its result is returned to the parent; `none` signals a fully stateless invocation. For most isolation use cases — skills that explore, analyze, and report back — `context: fork` is the correct choice.

Does `context: fork` replace the need for `allowed-tools`?

No — they solve different problems. `context: fork` prevents the skill's working context from inflating the parent session's window. `allowed-tools` restricts which tools the skill can call. A skill with `context: fork` but no `allowed-tools` restriction can still write files and run shell commands; those side effects persist even though they happened in an isolated conversation thread. Use both together when you need clean context AND restricted tool access.