Getting Started with @northguild/worktree
worktree streamlines common Git worktree tasks into a repeatable workflow.
Install
Section titled “Install”Install globally:
npm install -g @northguild/worktreepnpm add -g @northguild/worktreeyarn global add @northguild/worktreebun add -g @northguild/worktreeOr run directly without global install:
npx @northguild/worktree --helppnpm dlx @northguild/worktree --helpyarn dlx @northguild/worktree --helpbunx @northguild/worktree --helpAgent skill
Section titled “Agent skill”To teach a coding agent how to drive worktree, including its --json agent mode, add the usage skill:
npx skills add northguild/worktree --skill worktreeAt a terminal the command asks which agent(s) to install the skill into; run from inside a coding agent it installs without asking, and --agent <name> chooses. It installs into the current project; add --global (-g) to install it for your user instead, so the agent has it in every repository. It is separate from, and in addition to, the install above: the skill teaches an agent the CLI, it does not install the CLI.
Initial Configuration
Section titled “Initial Configuration”Run once inside your repository:
worktree configIf your repository commits a .worktree.yml, worktree branch already has the team’s source branch,
prefixes and Jira host and does not offer to configure them. The wizard says which keys the file sets and
does not ask for them, so it no longer writes a personal copy of a team value; to override one for yourself,
run worktree config <key> <value>. If the repository has no file yet, worktree config --project writes one
from the team settings in your git config, and on a terminal worktree offers it once. See
Project Configuration.
Common values:
defaultSourceBranch: usuallyorigin/maincodeEditor: usuallycodeagent.command: optional, such asclaude --bg, the command--agentruns to hand a brief to a coding agent
To open worktrees as Herdr spaces instead of editor windows, set
opener to herdr — see Herdr Spaces. To open them as Rex sessions, set it to rex — see
Rex Sessions. Set it to auto to open in whichever of the two the command runs inside, falling back to the editor. Set it to none to open nothing:
branch prints Worktree created at <path> and stops.
First Workflow
Section titled “First Workflow”Create your first branch worktree:
worktree branch feature/improve-readmeThis command will:
- Branch from your configured source branch.
- Create a worktree under
<repo>.worktrees/feature/improve-readme. - Copy the gitignored env files from your main repository —
.env*,.dev.vars*and.envrc. - Open the new worktree in your configured editor, or as a Herdr space when
openerisherdr, or as a Rex session when it isrex; withauto, in the Herdr or Rex you are in, else the editor.
Requirements
Section titled “Requirements”- Git available on your
PATH - Node.js
^22.13.0or>=23.5.0(the range@inquirer/promptsand@oclif/core5 both support; Node 20 and 21 are not) - Existing Git repository
- macOS or Linux — Windows is not supported
If you use automatic editor opening, ensure your editor command is available on your PATH (for example, code).