Skip to main content

Worktree

Struct Worktree 

Source
#[non_exhaustive]
pub struct Worktree { pub sparse_paths: Option<Vec<String>>, pub base_ref: Option<WorktreeBaseRef>, pub bg_isolation: Option<BgIsolation>, pub symlink_directories: Option<Vec<String>>, pub location: Option<String>, pub extra: Extra, }
Expand description

worktree.

Configure how Claude Code creates and manages git worktrees for --worktree, the EnterWorktree tool, and isolated subagents and background sessions.

Docs: worktree.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§sparse_paths: Option<Vec<String>>

Check out only the listed directories in each worktree through git sparse-checkout. Claude Code writes only those directories plus root-level files to disk, which is faster in large monorepos; see Check out only the directories you need.

  • Values: array of strings, directory paths relative to the repository root
  • Default: unset, so each worktree checks out the whole tree
  • Scope: any settings file.

Docs: sparsePaths.

§base_ref: Option<WorktreeBaseRef>

Choose which ref new worktrees branch from. "fresh" branches from origin/<default-branch> for a clean tree matching the remote; "head" branches from your current local HEAD, so unpushed commits and feature-branch state are present in the worktree.

  • Values: string, one of:
    • "fresh": new worktrees branch from origin/<default-branch>
    • "head": new worktrees branch from your current local HEAD, including unpushed commits
  • Default: "fresh"
  • Scope: any settings file.

Docs: baseRef.

§bg_isolation: Option<BgIsolation>

Choose how background sessions isolate their file edits. If you moved a session to the background with ← or /background, that session edits files in place whatever this key says. With "worktree", Claude Code blocks Edit and Write in the main checkout until the session calls EnterWorktree; with "none", background jobs edit the working copy directly.

  • Values: string, one of:
    • "worktree": Claude Code blocks Edit and Write in the main checkout until the session calls EnterWorktree
    • "none": background jobs edit the working copy directly
  • Default: "worktree"
  • Scope: any settings file.

Docs: bgIsolation.

§symlink_directories: Option<Vec<String>>

Symlink directories from the main repository into each worktree so you don’t duplicate large directories on disk.

  • Values: array of strings, directory paths relative to the repository root
  • Default: unset, so Claude Code symlinks no directories
  • Scope: any settings file.

Docs: symlinkDirectories.

§location: Option<String>

Choose the folder on a remote machine where Desktop SSH sessions create their worktrees, instead of <project-root>/.claude/worktrees/. Only the desktop app reads this key: --worktree, the EnterWorktree tool, isolated subagents, and background sessions ignore it. Requires Claude Desktop v1.44121.0 or later.

  • Values: string, an absolute path or one that starts with ~/
  • Default: unset, so worktrees go inside the project
  • Scope: user, in ~/.claude/settings.json on the remote machine.

Docs: location.

§extra: Extra

Keys Claude Code accepts here that this crate doesn’t model (newer or undocumented ones), kept as written so the document round-trips.

Trait Implementations§

Source§

impl Clone for Worktree

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Worktree

Source§

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

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

impl Default for Worktree

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Worktree

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Worktree

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Worktree

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Worktree

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.