---
title: "How to share context between Claude Code sessions · Cork"
description: "Six ways to carry context between Claude Code sessions: CLAUDE.md, auto memory, handoff files, resume and fork, cross-session messaging, SessionStart hooks."
canonical: "https://corkcli.com/blog/share-context-between-claude-code-sessions"
last_updated: "2026-11-14"
published: "2026-10-03"
author: "Kevin Vera"
---

# How to share context between Claude Code sessions

Six ways to carry context between Claude Code sessions: CLAUDE.md, auto memory, handoff files, resume and fork, cross-session messaging, SessionStart hooks.

By Kevin Vera · October 3, 2026 · [Guides](https://corkcli.com/blog/c/guides) · 6 min read

Every Claude Code session starts with a fresh context window, so context only carries over through something you set up. Put durable rules in `CLAUDE.md`, let auto memory hold Claude's own learnings, write a handoff file for work in progress, resume or fork a session when you want the whole conversation, and use cross-session messaging when two live sessions need to tell each other something now. Pick by how long the context must live and whether the other session is running at the same time.

## Choose by lifetime

| What you want to carry | Best mechanism | Lives |
|---|---|---|
| Rules and conventions | `CLAUDE.md` (committed) | Until you change it |
| Things Claude learned from your corrections | Auto memory | On this machine, across sessions and worktrees |
| The state of a task | A handoff file in the repo | Until the task ends |
| An entire conversation | `--resume`, `--continue`, `--fork-session` | As long as the transcript is kept |
| A fact another live session needs now | Cross-session messaging | One message |
| Dynamic facts at every start | A `SessionStart` hook | Recomputed each time |

All behavior below is as documented by Anthropic as of October 2026.

## 1. CLAUDE.md for durable instructions

Claude Code loads `CLAUDE.md` files at the start of every session. A project file lives at `./CLAUDE.md` or `./.claude/CLAUDE.md` and is shared with your team through version control; `CLAUDE.local.md` holds personal notes and should be gitignored. Keep it to facts every session needs: build and test commands, conventions, layout. The docs suggest targeting under 200 lines per file.

You can pull other files in with imports:

```markdown
@AGENTS.md
@docs/architecture.md

## Claude Code
Run `pnpm test` before committing.
```

Relative imports resolve from the file that contains them, and imports can nest up to four hops. For instructions that only matter in part of the codebase, use path-scoped rules in `.claude/rules/` so they load only when Claude works with matching files.

## 2. Auto memory for what Claude learns

Auto memory is on by default in local sessions. Claude saves notes to `~/.claude/projects/<project>/memory/`, with a `MEMORY.md` index whose first 200 lines (or 25KB) load into every session. When you say "remember that the API tests need a local Redis," Claude saves it there. All worktrees of the same repository share one memory directory, which makes it a natural channel between parallel worktree sessions. Two limits: it is machine-local, and the main conversation's auto memory is not loaded into subagents. Run `/memory` to browse or edit it.

## 3. A handoff file for work in progress

For a task that spans sessions, the most reliable channel is a plain file in the repo. Before ending a session, ask Claude to write one:

```text
Write docs/handoff/search-rewrite.md: what is done, what is left, decisions
made and why, and the exact next step. Keep it under 40 lines.
```

The next session starts with "Read docs/handoff/search-rewrite.md and continue." Anthropic's docs use the same pattern for cloud sessions: plan locally, "save the plan to the repo, commit, and push" so the cloud session can read it. A handoff file is explicit, reviewable, and survives compaction, machine changes and tool changes.

## 4. Resume or fork the whole conversation

When you want everything, not a summary:

```bash
claude --continue                 # most recent conversation in this directory
claude --resume auth-refactor     # a named session
claude --continue --fork-session  # a copy, leaving the original intact
```

Inside a session, `/branch` does the same as forking. Name sessions with `claude -n <name>` or `/rename` so they are easy to find. You can also question an old session from a script without opening it:

```bash
claude -p --resume <session-id> --output-format json "summarize what we changed" | jq -r '.result'
```

The cost: a resumed long conversation brings its full history back into context. Resume when the detail matters; use a handoff file when a summary will do.

## 5. Cross-session messaging for sessions running at the same time

When two sessions are live, Claude can list your other sessions and message them (Claude Code v2.1.224 or later on macOS and Linux; on with nothing to enable when a session meets the requirements). Mention the target with `@`:

```text
Let @api-worker know the schema migration finished and tenant_id is the new column
```

The docs give the key use cases: handing over a finding, warning a session when "a change in one session breaks what another is building on," and coordinating parallel worktrees. A message is plain text, never the sender's history or files, and Claude decides when to send one unless you ask. Run `/list-agents` to see which sessions are reachable.

## 6. A SessionStart hook for context that changes

Some context should be computed fresh, such as recent commits or open branches. A `SessionStart` hook's stdout is added to Claude's context:

```json
{
  "hooks": {
    "SessionStart": [
      {
        "hooks": [
          { "type": "command", "command": "git log --oneline -10" }
        ]
      }
    ]
  }
}
```

Add a `compact` matcher to re-inject critical context after compaction, which is when long sessions tend to lose detail.

## How Cork helps

All six mechanisms depend on someone deciding what to write down or send. The context a parallel session most needs, what other agents just changed in the code it is about to touch, is exactly the context nobody thinks to pass on. Cork is the [coordination layer](https://corkcli.com/blog/coordination-layer-ai-coding-agents) for multiplayer coding agents: it keeps Claude Code, Codex and Cursor agents, on one machine or across a team's machines, from overwriting each other on one codebase, and hands each agent what the others already learned.

For sharing context specifically:

- **Briefing:** when a session starts or gets a prompt, Cork's hooks hand it the exact signatures, callers and recent changes of the code it is about to touch, with no extra model calls.
- **Live awareness:** when another session renames or re-signatures code this one depends on, it hears it on its next step.
- **remember and recall:** MCP tools for durable notes anchored to specific code, which later agents can recall.
- **recap:** an MCP tool that answers what happened and what it cost.
- **Agent messaging:** message one agent, all of them, or whoever is working on a given function.

Cork Free runs on one machine with no account; the paid plan shares this across teammates' machines. Install:

```bash
curl -fsSL https://corkcli.com/install.sh | sh
```

## Frequently asked questions

### Do Claude Code sessions share memory?

Sessions in the same repository on the same machine share auto memory, including across worktrees. They do not share conversation history unless you resume or fork.

### How do I pass context to a new Claude Code session?

For durable rules, `CLAUDE.md`. For task state, a handoff file the new session reads first. For the whole conversation, `claude --resume` or `--fork-session`.

### Can one Claude Code session send a message to another?

Yes. Cross-session messaging lets Claude message your other sessions on the same machine, and sessions on other machines or in the cloud through Remote Control.

### Does compaction lose context?

It summarizes the conversation, so details can drop. Re-inject critical facts with a `SessionStart` hook using the `compact` matcher, or keep them in `CLAUDE.md`.

## Sources

- <https://code.claude.com/docs/en/memory>
- <https://code.claude.com/docs/en/sessions>
- <https://code.claude.com/docs/en/cross-session-messaging>
- <https://code.claude.com/docs/en/hooks-guide>
- <https://code.claude.com/docs/en/claude-code-on-the-web>
- <https://code.claude.com/docs/en/sub-agents>

## Related reading

- [How to hand work from one AI coding agent to another](https://corkcli.com/blog/hand-off-work-between-ai-coding-agents): Hand off work between AI coding agents without losing context: commit, write a handoff note, resume or fork sessions in Claude Code and Codex, and verify first.
- [How to share context between Codex and Claude Code](https://corkcli.com/blog/share-context-codex-claude-code): Make Codex and Claude Code work from the same context: one AGENTS.md, shared MCP servers, handoff files, and live awareness when both edit the same repo.
- [Agent-to-agent messaging between coding agents: how it works](https://corkcli.com/blog/agent-to-agent-messaging-coding-agents): How coding agents message each other as of October 2026: Claude Code SendMessage, team mailboxes, cross-session sockets, A2A, and what a useful message holds.
- [Claude Code subagents vs parallel sessions: when to use which](https://corkcli.com/blog/claude-code-subagents-vs-parallel-sessions): Subagents or parallel Claude Code sessions? Compare context, control, file isolation and cost, with a decision checklist and setup for each, as of October 2026.

[All articles](https://corkcli.com/blog.md) · [Cork in Markdown](https://corkcli.com/index.md) · [llms.txt](https://corkcli.com/llms.txt)

This page in HTML: https://corkcli.com/blog/share-context-between-claude-code-sessions
