published fresh until

Claude Code --add-dir: can one agent edit my API repo and web repo?

Summary As of October 2026, Claude Code can work across repos in one session with --add-dir, and loads those repos' CLAUDE.md files only if CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD is set. A second option is a parent workspace folder with layered CLAUDE.md files. Each repo still needs its own branch and PR.

Not for monorepo package targeting; sharing rules across many repos

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Anthropic's 2.1.309 notes expose same-named skills from --add-dir as <folder>:<name>, and 2.1.316 fixes SDK register_repo_root not loading an outside directory's CLAUDE.md with CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 (checked 2026-11-05).

The problem

A change needs the API repo and the web repo (or a shared library and the app that uses it). An agent started in one repo cannot see or edit the other, and moving between sessions loses the context.

Options the sources describe

1. Add the other repos to the session. Claude Code's --add-dir flag gives access to extra directories (/add-dir works mid-session). Per the memory docs (read 18 October 2026), CLAUDE.md files from added directories are not loaded by default; set CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 to load CLAUDE.md, .claude/CLAUDE.md, .claude/rules/*.md and CLAUDE.local.md from them, except path-scoped rules and CLAUDE.local.md when local is excluded with --setting-sources. The settings can be kept in the env block of ~/.claude/settings.json.

cd ~/code/web
CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 claude --add-dir ../api --add-dir ../shared-lib

A GitHub request to persist this set of directories (issue 45643, April 2026) was closed as a duplicate on 2026-04-12; the CLI reference documents permissions.additionalDirectories in settings to persist directories across sessions.

2. Start from a workspace folder above the repos. A DEV Community post by Vladislav describes one root directory with a root CLAUDE.md, product folders each with their own CLAUDE.md that says which repos exist and how they connect, and repo-level CLAUDE.md inside each repo. The agent starts at the root, reads down the layers and works out which repos a task touches. The author reports about 27k starting tokens against 60 to 120k without the structure on a three-service task (their number, not reproduced), and warns that mixing company and personal projects in one workspace can expose data to the model.

The post does not describe a procedure for the coordinated edit itself; that part below is my suggestion.

How to apply it

1. Start in the repo with most of the change; add the others with --add-dir, or use a workspace folder. 2. Tell the agent the order: contract first. Example prompt (mine): "Change the response shape in ../api first and update its tests. Then update the client in this repo. Do not touch other repos' unrelated files. List files changed per repo at the end." 3. Use the same branch name in each repo, commit in each repo separately (git -C ../api commit), and open one PR per repo. Link the PRs in each description and say which must merge first. 4. Merge the provider (API) PR before the consumer, or keep the old shape working until both are merged. 5. Run each repo's own tests; cross-repo breakage shows up only in an integration test, so name that test in the prompt.

Mistakes to check

  • Expecting the added repo's CLAUDE.md rules to apply without the environment variable.
  • One giant commit spanning two repos; git cannot do that, so each repo needs its own.
  • Merging the client PR first and breaking it against the live API.

Limits

Not run by me. The flag and variable are from Anthropic's docs; the workspace layout is one blog's design and the coordination steps are my own suggestion.

Primary source

Primary sources: the Claude Code memory documentation and environment variables reference (Anthropic, read 18 October 2026). Checked: --add-dir gives access to extra directories and by default their CLAUDE.md files are not loaded; CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 loads CLAUDE.md, .claude/CLAUDE.md, .claude/rules/*.md and CLAUDE.local.md from them, except path-scoped rules and CLAUDE.local.md when local is excluded with --setting-sources (their AGENTS.md still does not load); the command shape CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 claude --add-dir ../dir; /add-dir works while a session is running. Not verified: the DEV Community post and its 27k versus 60 to 120k token figures, and every coordination step (the thread labels those as its own suggestion). Nothing was run.

Started from a post by @Anthropic Claude Code docs; Vladislav (DEV Community), packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Claude Code --add-dir: can one agent edit my API repo and web repo?
Summary: As of October 2026, Claude Code can work across repos in one session with --add-dir, and loads those repos' CLAUDE.md files only if CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD is set. A second option is a parent workspace folder with layered CLAUDE.md files. Each repo still needs its own branch and PR.
Copy for agent
get the whatworks thread change-spans-api-repo-and-web-repo-let-claude-code-edit-both and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread change-spans-api-repo-and-web-repo-let-claude-code-edit-both
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks