[MODEL] Agents/scales recursively search parent directories - no option to disable
Preflight Checklist
- [x] I have searched existing issues for similar behavior reports
- [x] This report does NOT contain sensitive information (API keys, passwords, etc.)
Type of Behavior Issue
Claude accessed files outside the working directory
What You Asked Claude to Do
When launching Claude Code CLI from a subdirectory, agents and skills automatically search upward through parent directories. This causes unintended behavior when a child project wants to use its own isolated resources.
Directory Structure:
D:\02workspace\myplat
├── .claude/
│ ├── agents/
│ │ └── requirement-analyzer.md
│ └── CLAUDE.md (nearly empty)
└── Team
└── ProductManager
├── .claude/
│ ├── skills/
│ │ ├── requirement-recorder/
│ │ └── requirement-designer/
│ └── CLAUDE.md (configures to call requirement-analyzer)
└── settings.json
How I start Claude Code:
```bash
# Launch Claude Code CLI from ProductManager directory
cd D:\02workspace\myplat\Team\ProductManager
claude
In my case:
- Current directory:
D:\02workspace\myplat\Team\ProductManager - The
CLAUDE.mdin this directory is configured to callrequirement-analyzerskill - This directory only has
skills/requirement-recorderandskills/requirement-designer - The system automatically searched up and found
agents/requirement-analyzer.mdin the parent directoryD:\02workspace\myplat\.claude\ - This triggered the wrong agent instead of using the local skills
What Claude Actually Did
The system silently searches upward through parent directories and uses resources found there, without any warning or configuration option to prevent this behavior.
Expected Behavior
I would expect:
- An error message when the configured resource doesn't exist in the current project's
.claude/directory - OR a configuration option to disable parent directory search, such as:
disableParentSearch: trueresourceDiscovery.scope: "local"
- Explicit opt-in for parent directory resource sharing, not automatic discovery
Files Affected
Permission Mode
Accept Edits was ON (auto-accepting changes)
Can You Reproduce This?
Yes, every time with the same prompt
Steps to Reproduce
- Create nested directory structure:
- Parent:
D:\02workspace\myplat\.claude\agents\requirement-analyzer.md - Parent: `D:\02workspace\myplat\.claude\CLAUDE.md is empty
- Child:
D:\02workspace\myplat\Team\ProductManager\.claude\skills\requirement-recorder\
- In child directory's
CLAUDE.md, configure to callrequirement-analyzerskill (not agent)
- Launch Claude Code CLI from child directory:
```bash
cd D:\02workspace\myplat\Team\ProductManager
claude
- Trigger a call to requirement-analyzer. (send message as: "I want to build a .... system/ add .... functions")
- Observe that it uses parent directory's agent, not the local skill or send me back the error message
Claude Model
Sonnet
Relevant Conversation
Impact
High - Significant unwanted changes
Claude Code Version
2.0.76
Platform
Anthropic API
Additional Context
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗