claude-code - 💡(How to fix) Fix Feature request: Hard workspace boundary enforcement for project isolation

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

This is particularly important for:

  • Multi-repo development environments
  • Shared machines / CI environments
  • Agent orchestration systems that manage multiple project contexts
  • Preventing accidental cross-contamination between projects

Error Message

An agent invoked in Project A attempted to modify source files in Project B (a sibling directory). The agent had knowledge of Project B's file paths and proceeded to edit them without any barrier.

Root Cause

This is particularly important for:

  • Multi-repo development environments
  • Shared machines / CI environments
  • Agent orchestration systems that manage multiple project contexts
  • Preventing accidental cross-contamination between projects

Fix Action

Workaround

We are currently mitigating this via system prompt instructions in CLAUDE.md ("never access files outside the project git root"), but this is soft enforcement only and can be overridden by the model's judgment.

RAW_BUFFERClick to expand / collapse

Problem

When Claude Code is used in a multi-project environment (e.g., multiple repos on the same machine), there is no hard enforcement preventing the agent from reading/writing files outside the current project's git root.

Observed behavior

An agent invoked in Project A attempted to modify source files in Project B (a sibling directory). The agent had knowledge of Project B's file paths and proceeded to edit them without any barrier.

Current state

  • The working directory is set correctly based on the project context
  • There is no filesystem-level sandbox preventing access to arbitrary paths
  • Read, Write, Edit, and Bash tools can all access files outside the project root
  • The only protection is the agent's own judgment (soft isolation via system prompt)

Proposed solution

Add a hard workspace boundary option that restricts all file operations to the current project's git root (or a configured set of allowed directories):

  1. Permission-level enforcement: Add a setting like "workspaceBoundary": "git-root" that causes all file tool calls targeting paths outside the boundary to be auto-denied (or require explicit user approval).
  2. Bash sandboxing: For shell commands, restrict cwd and validate that file arguments resolve within the boundary (similar to how MCP servers can enforce ALLOWED_WORKSPACE_DIRS).
  3. Explicit cross-project access: If cross-project access is needed, require the user to explicitly grant it (e.g., via a permission prompt or config).

Context

This is particularly important for:

  • Multi-repo development environments
  • Shared machines / CI environments
  • Agent orchestration systems that manage multiple project contexts
  • Preventing accidental cross-contamination between projects

Workaround

We are currently mitigating this via system prompt instructions in CLAUDE.md ("never access files outside the project git root"), but this is soft enforcement only and can be overridden by the model's judgment.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Feature request: Hard workspace boundary enforcement for project isolation