Support for a .worktreeinclude file

Feature request for product/service

– Other –

Describe the request

Hi, guys!

Any thoughts on adding support for a .worktreeinclude file? The idea: when work happens in a multi-agent repo and the team uses different harnesses, a shared mechanism is really convenient.

Example .worktreeinclude that copies over everything that is not under Git control:

.cursor
.claude
.codex
.agents

.env
.env.test

The equivalent in .cursor/worktrees.json looks like this:

{
  "setup-worktree-unix": [
    "if [ -d $ROOT_WORKTREE_PATH/.cursor ]; then cp -R $ROOT_WORKTREE_PATH/.cursor .; fi",
    "if [ -d $ROOT_WORKTREE_PATH/.codex ]; then cp -R $ROOT_WORKTREE_PATH/.codex .; fi",
    "if [ -d $ROOT_WORKTREE_PATH/.claude ]; then cp -R $ROOT_WORKTREE_PATH/.claude .; fi",
    "if [ -d $ROOT_WORKTREE_PATH/.agents ]; then cp -R $ROOT_WORKTREE_PATH/.agents .; fi",

    "if [ -f $ROOT_WORKTREE_PATH/.env ]; then cp $ROOT_WORKTREE_PATH/.env .env; fi",
    "if [ -f $ROOT_WORKTREE_PATH/.env.test ]; then cp $ROOT_WORKTREE_PATH/.env.test .env.test; fi",
  ]
}

Pretty verbose, in my opinion :slight_smile:
What do you think?

References for other harnesses:

P. S. If .cursor is in .gitignore, then worktrees.json is not copied and the setup script does not run.

Operating System (if it applies)

MacOS

Hey, thanks for the feature request. A declarative include file is a solid idea, we’ve already looked at this area, so it’s on our radar. I won’t promise an ETA, but we’re tracking it.

Meanwhile, a couple things that might shorten your current setup:

  • In worktrees.json, you can point to an external script instead of a long list of commands. setup-worktree-unix takes a path to a .sh (and setup-worktree-windows to a .ps1), and the file lives in .cursor/. This way all the cp logic moves into one script, and the config stays short. Details: Worktrees | Cursor Docs

  • Re your P.S.: even if .cursor is in .gitignore, setup should still run. For the local IDE flow, Cursor reads .cursor/worktrees.json from the root checkout, and when it’s missing in the new worktree it still runs the setup-worktree commands. If they’re really not running for you, tell me what environment you’re in (local / Remote SSH / dev container) and your Cursor version, and we can take a look separately.

Let me know how it goes.

It’s working correctly now :slight_smile: