Let me start a session before deciding which repo to work in

Resolved 💬 3 comments Opened May 22, 2026 by cheekychops Closed Jun 22, 2026

The ask

Let me start a Claude Code session before I've decided which repo I'll be working in.

The natural workflow: cd ~/workspace && claude from a parent directory that contains many sibling repos and worktrees, then chat with the agent and let it navigate into whichever one the task ends up needing — sometimes more than one over a long session. The conversation context is more valuable than any single repo's tooling state, so jumping repos shouldn't require restarting.

Today this isn't supported: the session's cwd is frozen at session start, and "I haven't picked a repo yet" effectively means "I've picked the parent dir forever" as far as the harness is concerned. Several cwd-aware bits then misbehave or refuse to help.

Concrete sharp edges

These all stem from the same root cause — the harness tracks a single session-start cwd and ignores what the agent's bash subprocess actually cd'd into.

1. Statusline can't display the active repo

The statusline script consumes workspace.current_dir / workspace.added_dirs from the harness JSON. When the session started outside any repo and the agent later cd'd into a sub-repo via Bash, the JSON exposes only the original cwd — there's no field carrying the agent's live bash cwd. Statusline shows the parent dir (or nothing-git-related at all) instead of the worktree the agent is actually editing in.

2. EnterWorktree path=<existing> refuses to switch

After the agent has created a worktree (git worktree add) and entered it via bash cd, asking the harness to register it fails:

EnterWorktree path=<workspace>/my-monorepo-feature-a
→ "Cannot enter an existing worktree: the current directory is not in a git repository."

The "current directory" being checked is the harness session cwd (the workspace parent, not a repo), not the bash cwd (which is inside the worktree). The target path is a valid worktree of an actual repo and the agent is actively editing in it, but the tool refuses on a precondition that has nothing to do with the target's validity.

3. /add-dir refuses subdirectories of the session cwd

/add-dir <workspace>/my-monorepo-feature-a
→ "<workspace>/my-monorepo-feature-a is already accessible within the existing working directory <workspace>."

So the workaround of populating workspace.added_dirs manually doesn't work either: anything under the session cwd is treated as already accessible and skipped, even though the sub-path is a distinct git toplevel that the statusline (and any future cwd-aware consumer) would want to know about separately.

4. The Skill tool can't invoke /add-dir for the user

Skill add-dir <workspace>/my-monorepo-feature-a
→ "add-dir is a UI command, not a skill. Ask the user to run /add-dir themselves — it cannot be invoked via the Skill tool."

Even if /add-dir did accept descendants, the agent can't trigger it autonomously — which defeats the navigate-as-you-go use case.

Net effect: a long-running session that wants to hop between sibling repos can't get the harness to follow it, and the agent ends up apologising to the user about all of the above.

Suggestions (independent — any one helps; together they close the gap)

  1. Track the agent's live bash cwd. Persist the Bash tool's cwd to the harness session state on each invocation, and expose it in the statusline input (e.g. workspace.active_dir) and to other cwd-aware tools so their preconditions check the active dir, not the session-start cwd.
  2. Loosen /add-dir to permit registering sub-repos as distinct workspace entries when the path is a distinct git toplevel that doesn't already appear in workspace.added_dirs.
  3. Loosen EnterWorktree path=<existing>'s precondition. "Must be inside a git repo" should mean "the target path is a valid worktree of an actual repo" — which it is — not "the harness's session cwd is inside a repo".
  4. Allow agent-side invocation of /add-dir (via the Skill tool or a new dedicated tool), so workspace registration doesn't require a user round-trip.

Workarounds today

  • Start a fresh session inside the specific repo each time you switch (cd <workspace>/repo-X && claude) — at the cost of losing prior conversation.
  • Or accept the stale statusline and the inability to EnterWorktree / /add-dir mid-session.

Neither serves "one long-running session that navigates a multi-repo workspace."

Versions

  • Claude Code 2.1.148.
  • Linux.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗