If one repository is the change target and another is reference material, both Claude Code and Codex CLI document ways to add directories to a local session. Their boundaries differ: Claude Code treats added folders as working directories governed by its permission mode, while Codex CLI describes --add-dir folders as additional writable roots. If the reference repository must stay unchanged, isolate it with an operating-system or container read-only mount and verify the resulting diff; a prompt alone is not an access control.
How do I give both tools a second local repository?
From the target repository, Claude Code documents claude --add-dir ../backend. Its CLI reference says this adds a directory Claude can read and edit, and its permissions guide says file edits still follow the active permission mode. Codex CLI accepts repeated --add-dir flags alongside a primary directory, as shown in OpenAI's CLI source. For a local trial, the shape is codex --cd ../frontend --add-dir ../backend. Check the installed version's help before relying on a flag.
Which fits when the second repository is reference only?
Claude Code's permission system can ask before file edits or use a narrower permission mode; its documentation also describes rules that block file-tool writes. Those controls do not by themselves constrain every shell command, MCP tool, or hook. Codex CLI describes added directories as writable roots, and its effective sandbox settings still determine whether those roots are available. Neither command example creates an operating-system read-only mount. If the reference code must not change, expose a read-only copy or mount enforced by the host/container, then inspect the diff and filesystem permissions after the task.
Does an added directory bring its instructions and settings too?
Do not assume so. Anthropic says most .claude/ configuration is not discovered from an added directory; some configuration types are exceptions, and loading CLAUDE.md from added directories requires an environment setting. The Codex command-line flag adds a directory path; its CLI reference does not promise that the other repository's agent instructions are automatically loaded. Point the agent to the exact instruction or API files it should read, and ask it to report the files it used before editing.
What should I check before allowing edits across repositories?
- Start from clean Git worktrees and record each repository's branch and status.
- Choose the primary working directory explicitly; add only the other paths needed for the task.
- For Claude Code, review the active permission mode and any rules for the added path. For Codex, confirm the effective sandbox permits the roots you intend to use.
- Ask for a plan that names which repository may change and which files are reference material.
- Afterward, inspect
git statusand diffs in every repository, then run each project's relevant checks yourself.
This is a local CLI workflow comparison, not guidance for Codex Cloud or Claude Code's cloud sessions. It does not claim either tool produces better cross-repository changes. A Codex issue requesting access to interconnected repositories is one qualitative example of this task; it does not establish how common the need is.
Which sources support this comparison?
- Anthropic Claude Code CLI reference — documents
--add-dir. - Anthropic Claude Code permissions guide — documents working directories, file permissions, and limits of file-tool write blocking.
- OpenAI Codex CLI source — defines the current
--add-dirflag as additional writable directories. - OpenAI Codex security documentation — describes sandbox and approval controls.
- OpenAI Codex issue #2797 — one qualitative request about access to interconnected repositories.
Affiliate disclosure: no affiliate link is used on this page.
Methodology and limitations
This local CLI comparison maps each vendor's documented additional-directory behavior and permission boundaries to one task: edit a target repository while consulting a second repository. OpenAI's public Codex issue #2797 is one qualitative example of this request, not evidence of prevalence. No product test, cross-repository benchmark, or security audit was performed.
Affiliate placeholder {{AFF_TOOLNAME}} — referral link not configured.