Claude Code Memory Missing in a Worktree? Diagnose It Safely

Claude Code Memory Missing in a Worktree? Diagnose It Safely

Aident AI

A glowing shared memory core branches toward coral and teal worktree paths, with one light path interrupted.

Claude Code Memory Missing in a Worktree? Diagnose It Safely

If Claude Code remembers a correction in your main checkout but forgets it in a Git worktree, first determine which kind of state is missing. Project CLAUDE.md instructions, CLAUDE.local.md, auto memory, and conversation history use different loading and storage rules. Anthropic documents auto memory as shared across worktrees in the same repository, but a fresh July 28 issue reports that some worktree sessions receive no auto-memory content at all.

Do not start by copying hidden project directories, merging session files, or symlinking .claude. Compare the two sessions with /context, /memory, and Git's repository-identity commands. Then put durable team instructions in the tracked project CLAUDE.md while you preserve a minimal reproduction for the open bug.

Quick Diagnosis

What is missing

What it usually means

First check

A tracked project CLAUDE.md

The file did not load, was excluded, or is outside the loaded hierarchy

Run /context and inspect Memory files

CLAUDE.local.md in only the new worktree

The untracked local file was not copied into the fresh checkout

Compare the two worktree files without changing Git state

Auto-memory notes in one worktree session

The session may have resolved or loaded the repository memory incorrectly

Open /memory in both sessions and compare the listed auto-memory folder

A previous conversation in /resume

Session history is path-scoped separately from auto memory

Follow the session-history recovery guide instead

All memory after switching machines or cloud environments

Auto memory is machine-local

Restore only from a trusted backup or rebuild the needed instructions

The most important distinction is that a missing conversation is not proof that auto memory failed. Likewise, seeing the correct CLAUDE.md does not prove that the machine-local auto-memory index loaded.

Prerequisites

Before testing, save current work and record:

  • the Claude Code version and surface, such as CLI, desktop, or IDE;

  • the operating system;

  • whether the worktree came from claude --worktree or git worktree add;

  • the main checkout path and linked worktree path;

  • one harmless, non-secret sentence already present in auto memory that you can use as a probe.

Run this in each checkout:

claude --version
pwd -P
git status --short

Expected result: you know which binary and working directory each session uses, and neither checkout has uncommitted work that your diagnosis could accidentally disturb.

Do not paste private memory contents into a public issue. A sanitized yes-or-no result for one harmless probe is enough.

Step 1: Establish the Main Checkout Baseline

Start a fresh Claude Code session in the main checkout. Run:

/context

Under Memory files, record which project and user instruction files loaded. Then run:

/memory

Record whether auto memory is enabled and which auto-memory folder Claude Code opens. Do not edit the folder yet.

Choose one harmless sentence that exists in the current auto-memory index but nowhere in the repository. Ask Claude to quote that exact sentence and explicitly allow it to answer that the line is unavailable.

Expected result: the main session lists the intended instruction files, points to one auto-memory folder, and can quote the probe without guessing.

Step 2: Repeat the Same Checks in a Worktree

Create an isolated test worktree only if you do not already have one:

claude --worktree memory-probe

Anthropic documents --worktree as creating a fresh checkout under .claude/worktrees/ on its own branch. A manually created linked worktree is also useful if that is where the problem occurs, but record which path you tested.

In the worktree session, run the same /context and /memory checks, then ask for the same harmless auto-memory sentence.

Expected behavior from the current documentation: worktrees in the same Git repository share one auto-memory directory. The project CLAUDE.md should also load when it is stored at the repository root or in ./.claude/CLAUDE.md.

A failure is reproducible when the main session can quote the probe but the worktree session cannot, or when /memory resolves the two sessions to different repository memory folders without an intentional autoMemoryDirectory setting.

Step 3: Confirm Both Checkouts Belong to One Git Repository

Run these read-only commands in the main checkout and the linked worktree:

git rev-parse --show-toplevel
git rev-parse --path-format=absolute --git-common-dir
git worktree list --porcelain

Expected result:

  • --show-toplevel returns a different checkout root in each worktree;

  • --git-common-dir resolves to the same repository metadata directory;

  • git worktree list --porcelain lists both paths and their branches.

This comparison matters because the documented memory scope is the Git repository, not merely the current folder name. Fresh issue reports suggest that some launch paths still key part of the session state to the worktree path even when Git identifies one shared repository.

Step 4: Classify the Missing State

Use the evidence rather than treating every reset as one bug.

Project CLAUDE.md is absent from /context

Confirm the file is at ./CLAUDE.md or ./.claude/CLAUDE.md in the worktree. If the file is tracked, compare it with the main checkout using Git. Also check whether claudeMdExcludes intentionally skips it.

Do not duplicate the same rules into several files. Fix the authoritative tracked file or its loading boundary, then start a fresh session and verify /context again.

CLAUDE.local.md exists only in the main checkout

This can be expected. A worktree is a fresh checkout, so an ignored local file is not automatically present. Keep team rules in tracked project instructions. If a personal rule truly applies to every repository, place it in user instructions rather than copying divergent local files by hand.

The correct auto-memory folder is listed, but the probe is missing

That matches the fresh inconsistent-loading report more closely than a file-location error. Record the session start time, version, worktree path class, and sanitized probe result. Do not force the answer by adding the same sentence to CLAUDE.md, because that would stop testing auto memory.

/resume cannot find the old conversation

Conversation history and auto memory are separate. Use the Claude Code session-history recovery workflow to locate the owning project path without rewriting JSONL files.

Step 5: Preserve Durable Instructions While the Bug Is Open

Auto memory is useful for machine-local learnings, but it should not be the only copy of a rule the team must follow. Put stable build commands, architecture facts, testing rules, and review conventions in one tracked project CLAUDE.md. Use the CLAUDE.md audit guide to keep those instructions concise and testable.

Keep current task state in a normal project handoff or issue that humans can review. Treat that as task continuity, not as a replacement auto-memory store.

For parallel work, follow the Git worktree isolation guide so branches and generated files do not collide. A clean worktree boundary makes a memory-loading reproduction much easier to trust.

Expected result: a new worktree can recover mandatory project rules from version control even if its optional auto-memory load is inconsistent.

Unsafe Fixes to Avoid

Avoid repairs that destroy evidence or mix unrelated state:

  • deleting ~/.claude/projects/ before preserving a sanitized comparison;

  • copying or merging session JSONL files to repair auto memory;

  • symlinking .claude or .claude/worktrees, which current worktree creation explicitly rejects;

  • setting one global autoMemoryDirectory for unrelated repositories;

  • committing machine-local memory or secrets into the repository;

  • assuming a successful /resume proves auto memory loaded;

  • disabling auto memory without confirming that it is the failing layer.

If you need a temporary test with auto memory disabled, use the documented /memory toggle or CLAUDE_CODE_DISABLE_AUTO_MEMORY=1, record the scope, and restore the previous setting after the comparison. Disabling the feature can isolate behavior, but it cannot repair a missing load.

Step 6: Report a Minimal Reproduction

If the main checkout succeeds and a fresh worktree fails, add the smallest sanitized reproduction to the matching Anthropic issue. Include:

  • Claude Code version, operating system, and surface;

  • built-in or manual worktree creation;

  • whether both paths share the same absolute Git common directory;

  • the Memory files difference from /context;

  • whether /memory displayed the same folder;

  • whether the harmless probe was available in each fresh session;

  • the UTC start times of the two sessions.

Do not include repository names, usernames, secrets, full transcripts, or the memory text itself. The result can be written as main: available; worktree: unavailable.

Why This Diagnosis Works

The checks separate four state layers before changing any of them. Git establishes repository identity. /context proves which instruction files entered the session. /memory shows the configured auto-memory surface. The harmless probe tests whether content actually loaded rather than whether a folder merely exists.

This follows the useful structure behind Aident's Ollama networking guide: use the exact symptom, change one boundary at a time, state the expected result, and explain what the result proves.

Verify One External Action With Aident Loadout

Once project instructions load consistently, verify one read-only external Action without storing a provider credential in auto memory or the repository.

Give Claude Code this instruction:

Follow https://aident.ai/SETUP.md

Then run:

aident account auth status
aident vault vault --action status
aident capabilities search \
  --targetEnv staging \
  --query "find a connected read-only GitHub Action that searches issues" \
  --types '["action"]'
aident capabilities get --name "<canonical-action-name>"

Use Aident Loadout to inspect one live read-only Action schema. Measure success as one current schema inspected, zero provider secrets pasted, and zero repository files changed.

For a smaller tool context after setup, compare local and remote MCP servers.

Sources

This guide reflects the official documentation and open issue evidence available on July 29, 2026. Recheck the linked documentation and issue status before changing Claude Code's private state.

Home

Home

Home

Integrations

Integrations

Integrations

Vault

Vault

Vault

Audit

Audit

Audit

Arana Grande

Arana Grande

Arana Grande

Free

Free

Free

30-day audit summary

30-day audit summary

30-day audit summary

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

View Audit

View Audit

View Audit

Loadout usage

Loadout usage

Loadout usage

617 action calls in the last 30 days

617 action calls in the last 30 days

617 action calls in the last 30 days

May 19 - Jun 17

May 19 - Jun 17

May 19 - Jun 17

10 active days

10 active days

10 active days

Less

Less

Less

More

More

More

Recent activity

Recent activity

Recent activity

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Shopify

Shopify

Shopify

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Success

Success

Success

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Success

Success

Success

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Failed

Failed

Failed

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Connected integration coverage

Connected integration coverage

Connected integration coverage

162

162

162

of 753 accessible connected

of 753 accessible connected

of 753 accessible connected

Callable actions

Callable actions

Callable actions

1,126

1,126

1,126

Vault credentials

Vault credentials

Vault credentials

8

8

8

Explore what's possible

Explore what's possible

Explore what's possible

See all Integrations

See all Integrations

See all Integrations

Google Ads

Google Ads

Google Ads

All available Goolge Ads tools via...

All available Goolge Ads tools via...

All available Goolge Ads tools via...

X (twitter)

X (twitter)

X (twitter)

All available X tools via...

All available X tools via...

All available X tools via...

Github

Github

Github

All available Github tools via...

All available Github tools via...

All available Github tools via...

Notion

Notion

Notion

All available Notion tools via...

All available Notion tools via...

All available Notion tools via...

Slack

Slack

Slack

All available Slack tools via...

All available Slack tools via...

All available Slack tools via...

Firecrawl

Firecrawl

Firecrawl

All available Firecrawl tools via...

All available Firecrawl tools via...

All available Firecrawl tools via...

753 integrations are available for loadouts.

753 integrations are available for loadouts.

753 integrations are available for loadouts.

Plug your entire stack into your AI agents.

Plug your entire stack into your AI agents.

Plug your entire stack into your AI agents.

Skip the integration headache. Plug 750+ tools into Claude Code, Codex, and OpenClaw in one go, and let your agents execute today.

Skip the integration headache. Plug 750+ tools into Claude Code, Codex, and OpenClaw in one go, and let your agents execute today.