Skip to content

CLAUDE.md parent directory traversal is a security/privacy concern #26944

Description

@rdewaele

Problem

Claude Code recursively walks up the directory tree from the working directory to / and reads every CLAUDE.md it finds. This behavior is not configurable.

This is a security and privacy concern:

  1. Unintended context leakage: Starting Claude Code in ~/projects/foo/bar/ silently loads CLAUDE.md from ~/projects/foo/, ~/projects/, ~/, etc. — directories the user never explicitly pointed Claude at. In a workspace with multiple unrelated projects under a shared parent, this leaks instructions and context from one project into another.

  2. No user awareness: There is no indication that parent CLAUDE.md files were loaded. The user has no way to know that files outside their working directory are influencing Claude's behavior.

  3. No opt-out: The traversal is hardcoded. There is no setting to disable or limit it.

Expected behavior

At minimum, provide a configuration option to control this behavior. Possible approaches:

  • A setting to disable parent directory traversal entirely (only load CLAUDE.md from the working directory)
  • A setting to limit traversal to the git repository root
  • A setting to set an explicit boundary (e.g., stop at a specific directory)
  • Display which CLAUDE.md files were loaded at startup so the user is aware

Current behavior

Claude Code unconditionally recurses from cwd up to (but not including) /, loading every CLAUDE.md and CLAUDE.local.md it encounters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions