Feature Request: Dynamic Context Management for Multi-Project Workflows
Executive Summary
Enable Claude Code to dynamically swap project contexts based on active work, rather than accumulating all contexts from added directories. This would allow users to start sessions from any location while maintaining appropriate project-specific context.
Problem Statement
Current behavior creates friction for users working across multiple projects:
- Starting Location Dependency: Users must remember to start Claude Code from the "correct" directory
- Context Accumulation: Adding directories accumulates all contexts, creating:
- Pattern conflicts between projects
- Cognitive overhead from multiple active contexts
- Unclear precedence rules
- Flow State Interruption: Users must think about directory management during creative work
Example Scenario
A user working on three projects with different CLAUDE.md requirements:
- Project A: "Never give generic advice, always search first"
- Project B: "Speak in full technical terminology"
- Project C: "Optimize for business stakeholders"
Currently, all three contexts remain active simultaneously when using /add-dir, creating confusion about which rules apply.
Proposed Solution
Implement dynamic context swapping where:
Active Context = Global CLAUDE.md + Current Project CLAUDE.md
Behavior
- Auto-detection: Claude Code detects active project from:
- Current working directory
- Recently accessed files
- Explicit user indication
- Clean Swapping: When switching projects:
- Previous project context unloads
- New project context loads
- Global context persists
- User Control: New commands:
/context- Show active context/context switch <project>- Explicitly switch context/context add <dir>- Temporarily add additional context
Benefits
- Reduced Cognitive Load: One project context active at a time
- Natural Flow: Context follows user attention
- Clear Mental Model: Like switching between applications
- Preserved Project Identity: Each project maintains distinct requirements
Use Case
As a developer working on multiple projects with different CLAUDE.md configurations, I frequently find myself:
- Starting Claude Code from the wrong directory
- Having to restart sessions to get the right context
- Dealing with conflicting instructions from multiple active contexts
- Losing flow state while managing directory contexts
This feature would allow me to:
- Start Claude Code from anywhere
- Have it intelligently load the right context
- Switch projects seamlessly within a session
- Maintain focus on the work, not the tool
Backward Compatibility
- Maintain
/add-dirfor users who want cumulative behavior - Add setting:
context.mode: "dynamic" | "cumulative" - Default to current behavior with opt-in to dynamic
Related Issues
- #1628 (changing working directory) - This goes beyond just directory access to context management
- #3146 (configure additional directories) - This proposes dynamic rather than static configuration
- #1376 (multiple project confusion) - This directly addresses the root cause
Implementation Ideas
The simplest approach might be:
- Track which CLAUDE.md files are currently loaded
- When working directory changes, swap project-specific CLAUDE.md
- Keep global CLAUDE.md always active
- Provide visual indicator of active context
Thank you for considering this feature request. Happy to provide more details or clarify any aspects.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗