---
title: WorktreeInput
description: "The input of a `worktree()`: a branch Worktree, a detached one, or a branch Worktree at a `Handoff`."
---

# `WorktreeInput`

Type, in `@jr2/orchestrator/src/worktree.ts`. It is an export of `@jr2/orchestrator`, in the [Effects](group-effects.md) group of the [Authoring surface](../authoring-surface.md) page.

```ts
type WorktreeInput =
  | {
      path: AnyWorktreePath;
      branch: string;
      from?: string;
      detach?: never;
      handoff?: never;
      expect?: never;
    }
  | {
      path: AnyWorktreePath;
      detach: string;
      branch?: never;
      from?: never;
      handoff?: never;
      expect?: never;
    }
  | {
      path: AnyWorktreePath;
      handoff: Handoff;
      branch?: string;
      detach?: never;
      from?: never;
      expect?: never;
    };
```

The input of a `worktree()`: a branch Worktree, a detached one, or a branch Worktree at a
[`Handoff`](type-handoff.md).

**Forms**: it is one of these objects.

- Form 1: `path`, `branch`, `from`, `detach`, `handoff`, `expect`

  - `path`: [`AnyWorktreePath`](type-anyworktreepath.md)

    The root of the Worktree: `${context.workspace.repos.app}/<name>`, a constant word.
  - `branch`: `string`

    The branch. It resolves as a local branch, then `origin/<branch>` (tracked), then a new
    branch.
  - `from` (optional): `string`

    Where a new branch starts. Default: the Binding's base. On a branch that exists, it must
    be that branch's tip, or the cut is `refused`.
  - `detach` (optional): `never`
  - `handoff` (optional): `never`
  - `expect` (optional): `never`
- Form 2: `path`, `detach`, `branch`, `from`, `handoff`, `expect`

  - `path`: [`AnyWorktreePath`](type-anyworktreepath.md)
  - `detach`: `string`

    The commit to check out, with no branch. The Worktree is forced to it and cleaned on each
    cut. Ignored files stay, so that a reviewer can run the tests.
  - `branch` (optional): `never`
  - `from` (optional): `never`
  - `handoff` (optional): `never`
  - `expect` (optional): `never`
- Form 3: `path`, `handoff`, `branch`, `detach`, `from`, `expect`

  - `path`: [`AnyWorktreePath`](type-anyworktreepath.md)
  - `handoff`: [`Handoff`](type-handoff.md)

    The commit of a `ready` cut of an enclosing Workspace of this run, which this nested
    Workspace takes ([ADR-0080](../decisions/0080-a-nested-workspace-takes-a-handoff-at-its-cut.md)). The cut checks each field against the run's ledger.
  - `branch` (optional): `string`

    The branch of the new Worktree. Default: the Handoff's branch. A detached Handoff needs
    it.
  - `detach` (optional): `never`
  - `from` (optional): `never`
  - `expect` (optional): `never`
