r/opencode • • 6d ago

Worktree directory

I'd like OpenCode to put each project's Git worktrees in a sibling directory named <project>.worktrees. For example, if my repository is at ~/my_project, I'd like its worktrees to go under ~/my_project.worktrees.

I found that I can set a fixed directory in ~/.config/opencode/opencode.jsonc:

{
  "$schema": "https://opencode.ai/config.json",
  "worktree": {
    "directory": "../worktrees"
  }
}

Is there a way to include the project directory's name in that path, for example by setting "directory": "../<project>.worktrees"?

2 Upvotes

1 comment sorted by

1

u/mwilson_9309 5d ago

The config snippet shows a fixed path; the sibling name would need project-name interpolation. If worktree.directory doesn't support that, you'd need to set the path per project or use a launcher to compute it.