Git Worktree
The session git tool runs git as a privileged host operation. It accepts a
structured command object (command, plus subcommand/name/path for
worktrees) and returns a tool result with output and an exit code.
worktree with subcommand: 'create' adds a worktree at path on a new branch
named name. This example
inspects a repo, then creates, lists, and removes a worktree directly through the
tool surface.
Pass a command object rather than positional arguments: { command: 'status' },
{ command: 'diff' }, or { command: 'worktree', subcommand: 'list' }. The
command values are status, log, branch, checkout, diff, stash,
remote, and worktree; the tool has no commit or push command. Each
call returns a tool result, so check exit_code (Rust/Python), exitCode
(Node.js), or ExitCode (Go) before trusting the output.
Direct git calls are privileged host operations: they skip the session's
permission policy and confirmation prompts. Gate branch switches and worktree
removal in your application, or use governedTool('git', ...) /
governed_tool / GovernedTool to keep the session's gates.
A runnable version ships at sdk/node/examples/git/test_worktree_git.ts.