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 exitCode. This example inspects a repo, then creates, lists, and removes a worktree directly through the tool surface.

Rust
Node.js
Python
Go

Pass a command object rather than positional arguments: { command: 'status' }, { command: 'diff' }, or { command: 'worktree', subcommand: 'list' }. 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. Put push, publish, and release workflows behind application-level approval or automation gates.

A runnable version ships at sdk/node/examples/git/test_worktree_git.ts.