Skip to main content

Git

Local git operations for code agents. Check status, view diffs, browse history, create commits, and manage branches. Pairs with the GitHub toolkit for remote + local workflows.

Quick Start

import { Agent, openai, GitToolkit } from "@radaros/core";

const git = new GitToolkit({ cwd: "/path/to/repo" });

const agent = new Agent({
  name: "code-agent",
  model: openai("gpt-4o"),
  instructions: "Help users manage their git repository.",
  tools: [...git.getTools()],
});

const result = await agent.run("Show me what files have changed and create a commit with a good message.");

Config

cwd
string
Working directory for git commands. Defaults to process.cwd().
maxOutput
number
default:"10000"
Max output characters. Long output is truncated.

Tools

ToolDescription
git_statusShow working tree status (modified, staged, untracked files).
git_diffShow changes — unstaged by default, or --staged. Optionally filter by file.
git_logShow commit log history (default 10 commits, one-line format).
git_commitStage files and create a commit. Stages all modified files by default.
git_branchList, create, or switch branches.

Security

All commands use execFileSync (not shell execution) to prevent command injection. Arguments are passed as arrays directly to the git binary.

No Dependencies

This toolkit requires no additional packages — it uses the system git binary that is already available on virtually all development machines.