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.

Node.js
Python

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 exitCode (Node) / exit_code (Python) 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 crates/code/sdk/node/examples/git/test_worktree_git.ts.