Preserve the project subdirectory as the agent working directory in new worktrees#16524

opened23d agobyBboundsj

My project is configured to start in {project}/ios, a subdirectory of a Git repository.

When I create a new worktree, T3 starts the agent at {worktree} instead of {worktree}/ios. This prevents subdirectory-scoped skills from appearing in the composer picker for Codex and Claude.

Expected behavior: preserve the project’s path relative to the repository root when launching the agent and discovering skills in the new worktree.

Moving these skills to the repository root isn’t suitable because they should remain scoped to the subproject.

Note

Grok responding on behalf of Julius.

Triage

Thanks @boundsj for the clear report. Reading current main, this looks like a real bug, and I don't see an existing issue for it. A project whose workspace is a subdirectory of a Git repository keeps that directory for a local thread, but a new worktree drops it and starts at the checkout root. That would explain why subdirectory skills disappear for Codex and Claude.

What I found

  • Worktrees are always the repo root. git worktree add checks out the repository root at the worktree path (GitVcsDriverCore.createWorktree). The thread stores that path, and the session cwd prefers thread.worktreePath over project.workspaceRoot (RuntimePolicyV2.resolve).
  • Skills follow that cwd. The composer looks up skills at the same path (projectScriptCwd, then resolveProviderSkillsForCwd on web and mobile). Claude skills are read from <cwd>/.claude/skills, and Codex skills/list is called with that cwd, so skills that live under the subdirectory aren't the ones discovered, and the agent isn't started there. Terminals and the files view use this cwd too.

Likely fix area

Worktree creation / RuntimePolicyV2.resolve and skill discovery. One option: take the project's path relative to the repository root (e.g. ios) and use <worktree>/ios as the agent cwd and the skill-discovery cwd, while keeping the stored worktree path as the checkout root (that's where Git created the tree). A project that already is the repository root would stay unchanged.

A maintainer will decide on the fix direction.

Synced from GitHub

Still seeing this on current main: worktree threads for a project rooted in a repo subdirectory start the agent at the worktree root, so subdirectory-scoped skills don't show up. #19920 has a possible fix with tests and before/after screenshots. It's closed now and has drifted from main, but it may be a useful starting point.

Synced from GitHub

Since I'm trying to work on a mobile app that is part of a larger repo and the xcode mcp is in the mobile directory, this is now starting to become a blocker since automating the simulator is becoming buggy. I'm really hoping this issue can get picked up and addressed with one of the PRs I proposed or something like them. I think sadly I'lll need to stop using t3 for now at work since I can't change the way the repo is organized.