Skip to content

[FEATURE]: Support custom branch names when creating workspaces (worktrees) #20950

Closed

Description

@KingingWang

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Current Behavior:
When creating a new workspace (git worktree) through OpenCode's UI or API (POST /experimental/worktree), the branch name is automatically generated as opencode/<slugified-name>. Users cannot specify a custom branch name like feature/my-branch or bugfix/issue-123.

Use Case:
In many development workflows, teams use specific branch naming conventions (e.g., feature/, bugfix/, hotfix/ prefixes). The current auto-generated opencode/<name> format doesn't align with these conventions, making it harder to:

  • Follow team branch naming policies
  • Integrate with CI/CD pipelines that expect certain branch patterns
  • Organize branches logically in git history

Workaround (Temporary Solution):
Currently, users can manually create a worktree with a custom branch name and register it in OpenCode:

# 1. Manually create worktree with custom branch name
git worktree add -b feature/my-custom-branch /path/to/worktree

# 2. Register it in OpenCode's database by updating the project sandboxes field

However, this requires manual database manipulation and is not user-friendly.

Proposed Solution:
Extend the workspace creation API to accept an optional branch parameter:

POST /experimental/worktree
{
  "name": "my-workspace",
  "branch": "feature/my-custom-branch"
}

If branch is provided, use it directly (after validating it doesn't already exist). If not provided, fall back to the current auto-generated opencode/<name> format.

Additional Context:
Looking at the code in packages/opencode/src/worktree/index.ts, the CreateInput schema and makeWorktreeInfo function would need to be modified to accept and use a custom branch name.

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 4, 2026
  2. github-actions commented on Apr 4, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  3. KingingWang commented on Apr 4, 2026

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

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions