wtf

module
v0.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2026 License: MIT

README

codecov CI

WorkTreeForge (WTF)

A fast worktree workflow tool for git and Jujutsu. Create, switch, and clean up git worktrees or jj workspaces with automated project setup — zero config required.

Install

# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/AndrewPBerg/wtf/main/install.sh | sh

# Windows (PowerShell) — download and run manually, don't pipe to iex
Invoke-WebRequest -Uri https://raw.githubusercontent.com/AndrewPBerg/wtf/main/install.ps1 -OutFile install.ps1
.\install.ps1
Remove-Item install.ps1

# Go (all platforms)
go install github.com/AndrewPBerg/wtf/cmd/wtf@latest

Quickstart

# Set up shell integration (one-time)
wtf setup shell

# List / pick worktrees interactively
wtf sw

# Create a worktree for a new branch
wtf new feature/auth
# ✔ Created worktree at /code/myrepo--feature-auth

# Create a worktree and switch to it in one step
wtf news feature/auth

# Checkout a PR by number
wtf new --pr 42

# Switch to a worktree (cd's automatically with shell wrapper)
wtf sw auth

# Switch across all registered repos
wtf sw -g auth

# Remove a worktree and its branch
wtf rm feature/auth

# Clean up merged/prunable worktrees
wtf clean --dry-run
wtf clean

# Re-run setup in current worktree
wtf setup

Git and Jujutsu

The same commands drive both. wtf uses git worktrees in a .git repo and jj workspaces in a .jj repo:

$ wtf new feat/auth          # in a jj repo
✔ Created workspace at /code/feat-auth--myrepo
  env: .env → symlink
  install: pnpm install

This matters most for setup: jj honors .gitignore, so a fresh jj workspace has no .env and no installed dependencies until wtf links and installs them.

A repo that is both (colocated — jj's default layout) is the only ambiguous case. wtf asks once and remembers your answer per-repo; --vcs git|jj and WTF_VCS override it. Non-interactive shells never prompt: wtf infers the backend from the checkouts the repo already has, so existing scripts are unaffected.

$ wtf new feat/auth
? myrepo is both a git and a jj repo — which should wtf use?
  [1] jj    workspace   (jj manages the working copy here)
  [2] git   worktree
Use which? [1-2] (saved for this repo)

See docs/jj.md for workspace naming, bookmarks, revsets, and listing.

Automatic Setup

When you create a worktree with wtf new or wtf news, WTF automatically:

  1. Handles env files (.env, .env.local, .env.development, .env.development.local) from the main worktree (symlink by default, copy with --copy-env)
  2. Detects your package manager and runs install (pnpm, bun, yarn, npm, uv, poetry, go, cargo, and more)

No config file needed. Override with flags:

wtf new feature/auth --copy-env     # copy env files for isolated agent worktrees
wtf new feature/auth --no-setup     # skip everything
wtf new feature/auth --no-env       # skip env file handling
wtf new feature/auth --no-install   # skip package install

Shell Integration

wtf sw prints the worktree path to stdout (a subprocess can't cd your shell). The shell wrapper intercepts wtf sw to cd automatically. Tab completions are also included — one line handles everything.

# Automatic setup (recommended)
wtf setup shell

# Or manually add to your profile:

# bash — ~/.bashrc
eval "$(wtf init bash)"

# zsh — ~/.zshrc
eval "$(wtf init zsh)"

# fish — ~/.config/fish/config.fish
wtf init fish | source

After setup, wtf sw auth will cd into the matching worktree directly, and wtf sw <TAB> will show available worktrees.

Worktree Path Convention

Worktrees and jj workspaces are created as sibling directories to the main repo. Slashes in names become dashes:

/code/myrepo                    (main)
/code/myrepo--feature-auth      (feature/auth)
/code/myrepo--hotfix-bug        (hotfix/bug)

Commands

Worktree Operations
Command Description
wtf new Create or ensure a workspace (--base, --pr, --ensure)
wtf sw Switch/list workspaces (--global, --prs, --json)
wtf rm Remove a workspace (--force, UUID selectors)
wtf clean Remove merged/prunable workspaces (--dry-run)
wtf news Create a workspace and switch to it (--base)

All of these work on jj workspaces too. --vcs git|jj forces a backend in a repo that is both.

Structured workspace lifecycle
Command Description
wtf workspace current Inspect the workspace containing the current directory
wtf workspace inspect Inspect one managed workspace by UUID, name, or path
wtf workspace list List managed workspaces through the versioned contract
wtf cleanup plan/apply Plan and apply identity-bound, fail-closed cleanup
wtf resources Inspect UUID-owned declared files, ports, leases, and debt
wtf doctor Diagnose identity, VCS, resource, and cleanup health
wtf capabilities --json Describe supported JSON schemas and automation contracts
wtf port Show the current workspace's allocated port

Structured JSON results use version: 1. WTF workspace UUIDs are persistent random identities and are distinct from Agent Bridge's deterministic scope UUIDs.

Setup
Command Description
wtf setup Run project setup in current worktree (--env, --install)
wtf setup shell Auto-configure shell integration (one-time)
wtf init Print shell functions + tab completions for eval/source
wtf completion Generate shell completion script (--shell, --install)
Registry & Monitoring
Command Description
wtf repos List all registered repos
wtf unregister Remove a repo from the registry
wtf watch Watch PRs for changes and send notifications (-g, -i)
Tooling
Command Description
wtf git-diff Create or refresh Zed/Git diff metadata for a JJ workspace
wtf version Print version
wtf update Update to the latest version
wtf uninstall Remove the wtf binary (--force to skip prompt)

See docs/ for detailed command documentation, and docs/jj.md for Jujutsu specifics.

Pi extension

The canonical Pi extension lives in packages/pi-extension/. It keeps agent checkout creation on WTF's managed path instead of raw git worktree add or jj workspace add commands.

Install or refresh it locally, then run /reload in existing Pi sessions:

./scripts/install-pi-extension.sh

Development

Requires Task:

task all                 # fmt -> lint -> test -> build
task test-coverage       # enforce the adjusted 90% coverage floor
task pi-extension-check  # lint, typecheck, and test the Pi extension

See CONTRIBUTING.md for the full dev loop.

Directories

Path Synopsis
cmd
wtf command
internal
cli
git
identity
Package identity owns WTF's durable repository and workspace identities.
Package identity owns WTF's durable repository and workspace identities.
jj
Package jj implements the vcs.Manager interface on top of the jj CLI, mapping jj workspaces onto wtf's worktree model.
Package jj implements the vcs.Manager interface on top of the jj CLI, mapping jj workspaces onto wtf's worktree model.
resource
Package resource provides the versioned, workspace-owned resource lifecycle substrate.
Package resource provides the versioned, workspace-owned resource lifecycle substrate.
ui
vcs
Package vcs defines the version-control abstraction shared by the git and jj backends.
Package vcs defines the version-control abstraction shared by the git and jj backends.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL