---
name: shibing624-worktree
description: "Isolate parallel work in a git worktree of the current repository (worktree tool: status / new / merge / remove). Use when another live session is dirty in the same directory (list_agents), when two agents would fight over index.lock, or when starting a parallel task checkout."
license: "Apache-2.0"
metadata:
  decimalai-skill-id: "c3c78240-8e53-4745-8a7f-6e329ca67977"
  decimalai-version-id: "b3b80f0d-0efa-4149-8924-99e126f00a1d"
  decimalai-version: "2"
  decimalai-body-sha256: "ac3a90470a459d00361823f286846b904532ff52986757717059f5976b6cac95"
  decimalai-name: "shibing624/worktree"
  decimalai-format: "1"
  decimalai-invocation: "model"
  decimalai-category: "agent-tooling"
  decimalai-source: "https://app.decimal.ai/s/shibing624-worktree@2/SKILL.md"
---
# Isolate work in a worktree

Several sessions in one checkout overwrite each other and contend for git's
index. A worktree is one directory + one branch per *task*, sharing the
repository.

This session does **not** move. `worktree(action="new")` returns a path.
Pass that path as `work_dir` on `read_file` / `write_file` / `apply_patch` /
`execute`. On `glob` / `grep`, pass it as `path`. Omit those arguments and
the call stays in this session's directory.

Do not `cd` and expect later calls to follow — each call is independent.
Do not `execute` `git worktree add`: that only makes a directory, and later
calls still use this session unless you pass `work_dir` / `path`. Use
`worktree(action="new")`.

## When

- `list_agents` shows another session in this directory (dirty files, same
  branch) and you are about to edit.
- A change should not land on the shared working tree.

Not this: a read-only `task` subagent (it does not write). A second CLI
that should start already inside a tree is `agentica --worktree <task>`.

## How

Name the *task*, not yourself. Reused while the checkout is healthy; gone
after merge. A registration that is no longer a checkout is refused — remove
it first, or pick another name. The tool does not delete leftover files to
make room.

- `worktree(action="new", name="<task>")` — create or reuse; returns the path
- `worktree(action="status")` — every worktree of this repo
- `worktree(action="merge", name="<task>")` — land on local main (conflicts
  stay in that worktree, then fast-forward on main), delete the checkout
- `worktree(action="remove", name="<task>")` — drop a `wt/*` checkout git
  will allow (dirty is refused; an unmerged branch is left in place)

`new(name="main")` is refused: `main` is the repository root, not a task.

For a chunk of work big enough for its own process, `delegate(task=...,
work_dir=<path>)` already takes the same path.

If a directory goes missing, `status` labels it `(directory gone)` or
`(not a checkout)`. Say so; do not rebuild it by destroying what sits there.
`remove` the name, then `new` if you still want it.
