$ROOT_WORKTREE_PATH not resolving in worktrees.json after Cursor 3.0 /worktree migration

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

After upgrading to Cursor 3.0, the new /worktree command partially executes .cursor/worktrees.json setup commands. pnpm install runs successfully, but subsequent cp commands using $ROOT_WORKTREE_PATH fail silently – .env files are missing in the created worktree. This was working correctly prior to the /worktree command migration.

{
  "setup-worktree": [
    "pnpm install",
    "cp $ROOT_WORKTREE_PATH/apps/client/.env apps/client/.env",
    "cp $ROOT_WORKTREE_PATH/.env.local .env.local",
    "cp $ROOT_WORKTREE_PATH/supabase/.env.local supabase/.env.local"
  ]
}

Steps to Reproduce

  1. Place the above worktrees.json in .cursor/
  2. Use /worktree to create a new worktree
  3. node_modules exists (confirming pnpm install ran), but all three .env files are missing

Expected Behavior

$ROOT_WORKTREE_PATH should resolve to the original project root, and all setup commands should execute – as they did before Cursor 3.0.

Operating System

MacOS

Version Information

Version: 3.0.12

Additional Information

This is a pnpm monorepo. The fact that pnpm install succeeds but the cp commands don’t suggests the issue is specifically with $ROOT_WORKTREE_PATH no longer being set or resolved under the new /worktree flow.

FWIW, When I asked my agent to debug this (Sonnet 4.6), they said:

That was my mistake. The worktree creation instructions explicitly say:

After each create, look for .cursor/worktrees.json in REPO_ROOT, then WORKTREE_PATH. If found, run setup once before other work.

I skipped that step — I created the worktree, saw the output, and immediately jumped into reading source files and implementing the feature without checking for a setup file. I should have looked for .cursor/worktrees.json in the repo root right after the worktree was created and run its commands before doing anything else.

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey, thanks for the report. It looks like the issue isn’t that $ROOT_WORKTREE_PATH doesn’t resolve, it’s that the agent skipped running the commands from worktrees.json entirely. The agent probably ran pnpm install on its own as a standard step, not from the config.

In Cursor 3.0, worktree setup is fully agentic. /worktree tells the agent to read .cursor/worktrees.json and run the commands. Sometimes the agent skips this step, which is what you’re seeing and what Sonnet 4.6 confirmed.

For debugging: open the Output panel via View > Output, select Worktrees Setup in the dropdown, and try /worktree again. If it’s empty, setup didn’t run.

As a workaround, you can explicitly remind the agent in your prompt:

/worktree After creating the worktree, read .cursor/worktrees.json and run ALL setup commands before doing anything else. <your prompt>

The team is aware of this issue. The reliability of the agentic worktree setup has come up in a few threads. I’ve passed it along for prioritization. Let me know if the workaround helped.

Thanks for the response! I can confirm that the issue was that the agent was skipping worktrees.jsonentirely. It had run the pnpm installcommand to run the test suite.

I typically run /worktree /build @insert-plan-here, which probably compounds the issue, as my build command is pretty detailed.

One question about your suggestion – is it possible to chain commands, to create a /wt that includes /worktree plus your text?