Skip to content

[FEATURE]: Add --worktree / -w startup flag to V2 #48272

Open

Description

@pragmaticivan

Feature hasn't been suggested before.

Describe the enhancement you want to request

Add a --worktree / -w startup flag to OpenCode V2. The flag must create or select an isolated git worktree before it starts the TUI session.

opencode2 -w feature-a
opencode2 --worktree feature-b
opencode2 --worktree

Expected behavior:

  • Create or select a named worktree when the user supplies a name.
  • Generate a worktree name when the user omits the value.
  • Start the session with that worktree as its working directory.
  • Keep session history, file state, tools, and MCP state isolated from sessions in other worktrees.
  • Reuse the existing V2 worktree and workspace infrastructure.

This supports parallel tasks without manual worktree setup or extra terminal tabs. It also gives Claude Code users an equivalent to its -w workflow.

This request differs from #36048. That issue requests worktree subcommands and in-session switching with stash-based state management. This issue requests a startup flag for a one-command isolated session.

Related issues:

Activity

  1. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the request, and for linking the earlier ones! You're asking for a --worktree [name] / -w startup flag in V2. It would create or select a git worktree (generating a name if you don't give one) and start the TUI session in it, so each parallel task gets its own sessions and state from a single command.

    Right now V2 can only create worktrees from inside the TUI, using the Worktrees dialog or by moving a prompt to a new worktree. The default opencode command has no worktree flag. A plugin can't add this either, because plugins load after the CLI has read its flags and chosen the session's directory.

    Maintainers will consider it. Related issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions