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.
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.
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?
About your request, there’s currently no way to chain slash commands or create custom aliases like /wt. Slash commands are built-in and can’t be customized.
But there are two options that can make your workflow easier:
Cursor Rules: create a file at .cursor/rules/worktree.mdc with an instruction that will automatically add context when you use /worktree:
---
description: When creating worktrees, always run setup
globs:
alwaysApply: false
---
After creating any worktree, ALWAYS read .cursor/worktrees.json and run ALL setup commands before doing anything else. Do not skip this step.
Then, when using /worktree, you can add @worktree to pull in that instruction.
Or simpler, copy the full prompt, including the reminder about worktrees.json, as a snippet or template and paste it each time.
Also worth noting, the team is aware that agentic worktree setup is unreliable right now, and it’s on the radar to improve. Let me know if you have more questions.