Problem
When using git worktree, each worktree is an independent working directory. Currently, CodeGraph requires running codegraph init -i in each worktree directory separately.
This creates friction for developers who use worktrees for:
- Parallel development on multiple branches
- AI coding agents working on different branches simultaneously
- Quick context switching between features/PRs
Current Behavior
.codegraph/ directory is created per working directory
- It's NOT tracked by git (typically in .gitignore)
- Each new worktree needs manual initialization
- Indexing large projects multiple times is time-consuming
Desired Behavior
Option A: Shared Index Repository-wide
- Store
.codegraph/ in the main git repository directory (not worktree-specific)
- All worktrees reference the same index
- MCP server detects worktree context and uses shared index
- Trade-off: Index reflects one branch's code structure
Option B: Auto-inherit on Worktree Creation
- When detecting git worktree context, automatically copy or symlink
.codegraph/ from parent/main worktree
- Or provide a
--inherit flag for codegraph init
Option C: Git-tracked Index
- Officially support committing
.codegraph/ to git
- Provide guidance on handling branch differences
- New worktrees automatically inherit via git checkout
Use Case Example
# Main repo with CodeGraph initialized
cd ~/project-main
codegraph init -i
# Create worktree for feature branch
git worktree add ~/project-feature feature-123
# Currently: need to manually init again
cd ~/project-feature
codegraph init -i # <-- This is the friction point
# Desired: worktree auto-detects and reuses/inherits index
Environment
- Git worktree feature (Git 2.5+)
- Common in AI agent workflows (Claude Code, OpenClaw, etc.)
Related
This is particularly relevant for AI coding agents that use worktrees to work on multiple tasks/branches in parallel.
Problem
When using git worktree, each worktree is an independent working directory. Currently, CodeGraph requires running
codegraph init -iin each worktree directory separately.This creates friction for developers who use worktrees for:
Current Behavior
.codegraph/directory is created per working directoryDesired Behavior
Option A: Shared Index Repository-wide
.codegraph/in the main git repository directory (not worktree-specific)Option B: Auto-inherit on Worktree Creation
.codegraph/from parent/main worktree--inheritflag forcodegraph initOption C: Git-tracked Index
.codegraph/to gitUse Case Example
Environment
Related
This is particularly relevant for AI coding agents that use worktrees to work on multiple tasks/branches in parallel.