Skip to content

enter_worktree — create an isolated git worktree

enter_worktree is the agent-facing wrapper around git worktree add. It creates a fresh branch and a sibling checkout at <repo>/../<repo>-<name>/ so the agent can experiment without disturbing the main tree. Pair with exit_worktree to clean up.

ArgTypeRequiredDefaultDescription
namestringyesBranch name. Also used as the worktree directory leaf.
base_branchstringnoHEADBranch / commit to base the new worktree on.
{"name": "feature-X-experiment", "base_branch": "master"}
from chimera.tools.worktree_tool import EnterWorktreeTool
tool = EnterWorktreeTool()
result = tool.execute(
{"name": "spike-redis-backend"},
env=local_env,
)
print(result.output)
Created worktree at /Users/me/dev/chimera-spike-redis-backend on branch 'spike-redis-backend' (from HEAD).

result.metadata["worktree_path"] carries the absolute path so a downstream tool can cd into it.

MessageCause
Not inside a git repositoryThe env’s workdir isn’t a git checkout.
Branch '<name>' already existsPick a different name or delete the old branch first.
Worktree path already existsStale leftover — remove with exit_worktree.