pub enum Commands {
Show 21 variants
New {
name: String,
path: Option<String>,
base: Option<String>,
term: Option<String>,
prompt: Option<String>,
prompt_file: Option<PathBuf>,
no_env_forward: bool,
emit: EmitFormat,
forward_args: Vec<String>,
},
Resume {
branch: Option<String>,
term: Option<String>,
no_env_forward: bool,
forward_args: Vec<String>,
},
Spawn {
target: Option<String>,
term: Option<String>,
prompt: Option<String>,
prompt_file: Option<PathBuf>,
no_env_forward: bool,
forward_args: Vec<String>,
},
Rm {
targets: Vec<String>,
interactive: bool,
dry_run: bool,
keep_branch: bool,
delete_remote: bool,
force: bool,
no_force: bool,
},
List,
Ls,
Doctor {
session_start: bool,
quiet: bool,
},
Upgrade {
yes: bool,
},
SetupClaude,
Config {
action: ConfigAction,
},
ShellSetup,
Exec {
target: String,
cmd: Vec<String>,
},
Run {
only: Option<String>,
no_main: bool,
jobs: usize,
continue_on_error: bool,
cmd: Vec<String>,
},
Guard {
tool_input: String,
},
ClaudeWorktreeCreate,
ClaudeWorktreeRemove,
Path {
branch: Option<String>,
list_branches: bool,
interactive: bool,
},
ShellFunction {
shell: String,
},
UpdateCache,
CompleteTargets,
SpawnAi {
spec: Option<PathBuf>,
},
}Variants§
New
Create new worktree for feature branch.
Trailing positional args are forwarded verbatim to the underlying AI
tool (claude/codex/gemini). Use -- to disambiguate when forwarded
args start with a hyphen, e.g. gw new feat-x -- --model opus.
Fields
term: Option<String>Terminal launch method for THIS invocation. Overrides config
and CW_LAUNCH_METHOD. Accepts canonical names (e.g.,
wezterm-tab) or aliases (e.g., w-t, w-t-b). Supports
method:session-name for tmux/zellij. Use noop, none, or
skip to skip the AI tool launch entirely.
prompt: Option<String>Initial prompt to pass to the AI tool. Use - to read the
prompt from standard input (e.g., --prompt - with a heredoc
or pipe).
prompt_file: Option<PathBuf>Read the initial prompt from a file (recommended for multi-line prompts)
no_env_forward: boolDisable auto-forwarding of <TOOL>_* environment variables
(e.g. CLAUDE_* when ai-tool is claude). Without this flag, gw
snapshots the parent shell’s matching env at invocation time
and re-injects it inside the spawned terminal so launchers like
wezterm/iterm/tmux/zellij behave like a normal child process.
emit: EmitFormatOutput format for stdout. text (default) for human-readable styled
output; json emits a single-line JSON object with worktree metadata
and suppresses the AI-tool launch. Useful for scripts and the Claude
Code WorktreeCreate hook integration.
Resume
Resume AI work in a worktree.
Trailing positional args are forwarded verbatim to the AI tool. The
tool’s own resume flag (--continue/--resume) is always injected
alongside, so gw resume foo -- --model opus resumes with opus.
Fields
Spawn
Launch AI tool in an existing worktree (default: current).
Trailing positional args are forwarded verbatim to the AI tool.
Fields
target: Option<String>Worktree target — exact worktree name, branch name, or path. Default: current worktree.
Rm
Remove one or more worktrees.
With no arguments: removes the current worktree (must be inside one).
With one or more positional targets: removes each of them; flags apply
to every target.
With -i: opens a multi-select UI.
Exits 0 on full success, 1 if the user cancelled at the confirmation prompt or in the interactive UI, 2 if any target could not be removed (not found, busy, or an error).
Fields
targets: Vec<String>Branch names or paths of worktrees to remove. If empty and –interactive is not set, removes the current worktree.
List
List all worktrees (rich, human-readable)
Ls
Print all worktrees as TSV (for scripts)
Columns: worktree_id, branch, status, age, repo_root, path
Doctor
Run diagnostics
Fields
Upgrade
Check for updates / upgrade
SetupClaude
Install Claude Code skills and hooks into the current repo’s .claude/.
Writes skill files into .claude/skills/gw-delegate/ and
.claude/skills/gw-manage/, then registers three Claude Code hooks
(PreToolUse Bash guard, WorktreeCreate, WorktreeRemove) into
.claude/settings.json. Idempotent — re-running only writes files
whose content changed.
Config
View or edit gw configuration.
Configuration lives in two scopes:
global:~/.config/git-worktree-manager/config.jsonrepo:<repo-root>/.cwconfig.json(overrides global)
set writes to global by default; pass --repo for a repo
override. edit opens an interactive TUI that lets you toggle
between scopes with Tab.
Fields
action: ConfigActionShellSetup
Interactive shell integration setup
Exec
Run cmd in one specific worktree.
Run
Run cmd in every worktree in scope.
Fields
Guard
Hook helper: read a Claude Code hook payload from stdin (or a file) and decide whether to allow or block the inbound tool use. Exits 0 to allow; non-zero with stderr message to block.
ClaudeWorktreeCreate
[Internal] Read a Claude Code WorktreeCreate hook payload from stdin
and create a worktree via gw new --emit json --term skip under the hood.
Prints only the worktree path (plain text, one line) to stdout.
ClaudeWorktreeRemove
[Internal] Read a Claude Code WorktreeRemove hook payload from stdin
and run the configured pre_rm hook as a best-effort advisory step.
Always exits 0; Claude Code owns the actual removal.
Path
[Internal] Get worktree path for a branch
Fields
ShellFunction
Generate shell function for gw-cd
UpdateCache
Refresh update cache (background process)
CompleteTargets
[Internal] Print completion targets for the current repo (one per line)
SpawnAi
[Internal] Execute an AI tool spawn spec file
Trait Implementations§
Source§impl FromArgMatches for Commands
impl FromArgMatches for Commands
Source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>
Source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§fn update_from_arg_matches_mut<'b>(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut<'b>( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§impl Subcommand for Commands
impl Subcommand for Commands
Source§fn augment_subcommands<'b>(__clap_app: Command) -> Command
fn augment_subcommands<'b>(__clap_app: Command) -> Command
Source§fn augment_subcommands_for_update<'b>(__clap_app: Command) -> Command
fn augment_subcommands_for_update<'b>(__clap_app: Command) -> Command
Command so it can instantiate self via
FromArgMatches::update_from_arg_matches_mut Read moreSource§fn has_subcommand(__clap_name: &str) -> bool
fn has_subcommand(__clap_name: &str) -> bool
Self can parse a specific subcommandAuto Trait Implementations§
impl Freeze for Commands
impl RefUnwindSafe for Commands
impl Send for Commands
impl Sync for Commands
impl Unpin for Commands
impl UnsafeUnpin for Commands
impl UnwindSafe for Commands
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more