Skip to main content

Commands

Enum Commands 

Source
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

§name: String

Branch name for the new worktree

§path: Option<String>

Custom worktree path (default: ../-)

§base: Option<String>

Base branch to create from (default: from config)

§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: bool

Disable 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: EmitFormat

Output 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.

§forward_args: Vec<String>

Extra arguments forwarded verbatim to the AI tool (claude/codex/ gemini). Mutually exclusive with --prompt/--prompt-file because both ultimately set the AI tool’s prompt — use one or the other.

§

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

§branch: Option<String>

Branch name, worktree name, or path to resume (default: current worktree)

§term: Option<String>

Terminal launch method for THIS invocation. Overrides config and CW_LAUNCH_METHOD. Accepts canonical names or aliases. Supports method:session-name for tmux/zellij. Use noop, none, or skip to skip the AI tool launch.

§no_env_forward: bool

Disable auto-forwarding of <TOOL>_* environment variables.

§forward_args: Vec<String>

Extra arguments forwarded verbatim to the AI tool (claude/codex/ gemini). The tool’s resume flag is still injected automatically.

§

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.

§term: Option<String>

Terminal launch method for THIS invocation. Overrides config and CW_LAUNCH_METHOD. Accepts canonical names or aliases. Supports method:session-name for tmux/zellij. Use noop, none, or skip to skip the AI tool launch.

§prompt: Option<String>

Initial prompt to pass to the AI tool. Use - to read from stdin.

§prompt_file: Option<PathBuf>

Read the initial prompt from a file.

§no_env_forward: bool

Disable auto-forwarding of <TOOL>_* environment variables.

§forward_args: Vec<String>

Extra arguments forwarded verbatim to the AI tool.

§

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.

§interactive: bool

Interactive multi-select UI (mutually exclusive with positional targets)

§dry_run: bool

Show what would be removed without removing

§keep_branch: bool

Keep the branch (only remove worktree)

§delete_remote: bool

Also delete the remote branch

§force: bool

Force remove: also bypasses the busy-detection gate (skips the “worktree is in use” check and removes anyway)

§no_force: bool

Don’t use –force flag

§

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

§session_start: bool

Hook-friendly mode: emit a single-line summary and exit 0.

§quiet: bool

Suppress informational chatter; keep only the summary.

§

Upgrade

Check for updates / upgrade

Fields

§yes: bool

Skip the confirmation prompt; required for non-TTY environments.

§

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.json
  • repo: <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

§

ShellSetup

Interactive shell integration setup

§

Exec

Run cmd in one specific worktree.

Fields

§target: String

Worktree name, branch name, or path.

§cmd: Vec<String>

Command and args.

§

Run

Run cmd in every worktree in scope.

Fields

§only: Option<String>

Glob filter on branch name or worktree directory basename (e.g. ‘feat-*’). Matches if either side does.

§no_main: bool

Skip the main worktree.

§jobs: usize

Parallel worktrees.

§continue_on_error: bool

Continue past per-worktree failures.

§cmd: Vec<String>

Command and args.

§

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.

Fields

§tool_input: String

Path to read the hook payload from, or “-” for stdin.

§

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

§branch: Option<String>

Branch name

§list_branches: bool

List branch names (for tab completion)

§interactive: bool

Interactive worktree selection

§

ShellFunction

Generate shell function for gw-cd

Fields

§shell: String

Shell type: bash, zsh, fish, or powershell

§

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

Fields

§spec: Option<PathBuf>

Path to the JSON spawn spec. If omitted, resolves the most recent spec for the current worktree from <git-dir>/gw-spawn-last.json.

Trait Implementations§

Source§

impl Debug for Commands

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromArgMatches for Commands

Source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

fn update_from_arg_matches_mut<'b>( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

impl Subcommand for Commands

Source§

fn augment_subcommands<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate Self via FromArgMatches::from_arg_matches_mut Read more
Source§

fn augment_subcommands_for_update<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate self via FromArgMatches::update_from_arg_matches_mut Read more
Source§

fn has_subcommand(__clap_name: &str) -> bool

Test whether Self can parse a specific subcommand

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.