btw_tool_git_diff: Tool: Git Diff

View source: R/tool-git.R

btw_tool_git_diffR Documentation

Tool: Git Diff

Description

This tool allows an LLM to run gert::git_diff_patch(), equivalent to ⁠git diff⁠ in the terminal, and to see the detailed changes made in a commit.

Usage

btw_tool_git_diff(ref = NULL, `_intent` = "")

Arguments

ref

a reference such as "HEAD", or a commit id, or NULL to the diff the working directory against the repository index.

_intent

An optional string describing the intent of the tool use. When the tool is used by an LLM, the model will use this argument to explain why it called the tool.

Value

Returns a diff patch as a formatted string.

See Also

Other git tools: btw_tool_git_branch_checkout(), btw_tool_git_branch_create(), btw_tool_git_branch_list(), btw_tool_git_commit(), btw_tool_git_log(), btw_tool_git_status()

Examples


withr::with_tempdir({
  gert::git_init()
  gert::git_config_set("user.name", "R Example")
  gert::git_config_set("user.email", "ex@example.com")

  writeLines("hello, world", "hello.md")
  gert::git_add("hello.md")
  gert::git_commit("Initial commit")

  writeLines("hello, universe", "hello.md")

  # What the LLM sees
  cat(btw_tool_git_diff()@value)
})


btw documentation built on Nov. 5, 2025, 7:45 p.m.