Skip to content

CLI commands

Bare twig <fragment> resolves and opens the worktree with your configured opener set. Bare twig inside a repo opens a picker over that repo’s worktrees; outside one it shows help.

The fragment can also be a GitHub pull request URL — twig https://github.com/org/app/pull/140 (or any URL inside that PR, like …/pull/140/files). twig maps it to the PR’s head branch and picks it up exactly as twig -r <branch> would, no -r needed. See remote pickup.

The fragment can also be a Codex thread link — twig codex://threads/<id> (or a bare thread id) opens the directory that local Codex session ran in. With -s the argument is instead a Codex session title to fuzzy-match (twig -s "frame pr 142"). See Codex local sessions.

FlagMeaning
-t, --tabenter in the current tab instead of a new window
-r, --remotesearch remote branches when nothing matches locally
-s, --sessiontreat the argument as a Codex session title to fuzzy-match
-v, --verbosenarrate each resolution step and scan location checked
--runrun the [run] script after setup succeeds
--setupforce the setup script to re-run
--no-setupskip setup entirely
--with a,bopeners to run, overriding the configured set

A fragment that collides with a subcommand name: use twig open <fragment>.

Identical to the bare form, as an explicit subcommand.

The first-run wizard. It discovers likely roots (ranked by repo count and Claude-worktree signal), detects installed editors to offer as openers, writes a commented config, and offers to add the tw function to your shell config. Refuses to overwrite an existing config without --force. An interactive twig <fragment> miss with no config file offers this wizard automatically.

Prints the resolved worktree path on stdout and nothing else, for cd "$(twig cd foo)". Supports -r, -s, -v, PR-URL, and Codex-thread fragments. With no fragment, picks among the current repo’s worktrees.

twig enter [dir] [—run] [—setup] [—no-setup]

Section titled “twig enter [dir] [—run] [—setup] [—no-setup]”

Runs the on-entry steps in the current terminal for dir (default: cwd): trust gate, setup-if-needed, optional [run]. This is the primitive that twig open injects into new windows and the tw function calls after cd.

Every worktree twig can see (current repo, providers, roots) as PATH BRANCH STATUS, where status is clean, dirty, stale (record without directory), or broken (git can’t read it).

Confirms, then git worktree remove + git worktree prune. The branch is kept. --force skips confirmation and removes dirty trees. Refuses to remove the main worktree.

twig trust [fragment] [—show|—list|—revoke]

Section titled “twig trust [fragment] [—show|—list|—revoke]”

Approve (or inspect/revoke approval of) the twig.toml governing a worktree. See the trust model.

twig shell-init <zsh|bash|fish> [—cmd tw]

Section titled “twig shell-init <zsh|bash|fish> [—cmd tw]”

Emits the tw shell function.

Diagnoses git, config (including warnings), roots, providers, openers, the trust store, and terminal availability.

twig exits 0 on success and 1 on errors. The exception is --run, where the run script’s own exit code passes through.