Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions agent-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2020,7 +2020,8 @@
"model_picker",
"background_agents",
"scheduler",
"rag"
"rag",
"git"
]
},
"instruction": {
Expand Down Expand Up @@ -2356,7 +2357,8 @@
"user_prompt",
"model_picker",
"background_agents",
"scheduler"
"scheduler",
"git"
]
}
}
Expand Down
1 change: 1 addition & 0 deletions docs/configuration/tools/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Built-in tools are included with docker-agent and require no external dependenci
| Type | Description | Page |
| --- | --- | --- |
| `filesystem` | Read, write, list, search, navigate | [Filesystem](../../tools/filesystem/index.md) |
| `git` | Read-only repository inspection (status, log, branches, show, blame) | [Git](../../tools/git/index.md) |
| `shell` | Execute shell commands synchronously | [Shell](../../tools/shell/index.md) |
| `background_jobs` | Run and manage long-running shell commands | [Background Jobs](../../tools/background-jobs/index.md) |
| `scheduler` | Schedule instructions to run at a time or on a recurring interval | [Scheduler](../../tools/scheduler/index.md) |
Expand Down
100 changes: 100 additions & 0 deletions docs/tools/git/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
title: "Git Tool"
description: "Read-only inspection of the working git repository."
keywords: docker agent, ai agents, tools, toolsets, git tool
linkTitle: "Git"
weight: 125
canonical: https://docs.docker.com/ai/docker-agent/tools/git/
---

_Read-only inspection of the working git repository._

## Overview

The git toolset gives an agent structured, **read-only** access to the working repository — status, history, branches, a commit's changes, and line-level authorship. It is implemented with go-git, so it needs **no `git` binary**.

Compared with running `git` through the `shell` tool, the git toolset returns clean, structured output the model can read reliably, is **safe by construction** (no command can modify the repository), and works even when `shell` is disabled or no `git` binary is installed.

> [!NOTE]
> The git toolset is read-only. To stage, commit, or check out, use the [`shell`](../shell/index.md) tool.

## Configuration

```yaml
toolsets:
- type: git
```

No configuration options. The repository is opened at the agent's working directory; a subdirectory still resolves to the repository root.

> [!WARNING]
> **The repository is discovered by walking up parent directories.** If the working
> directory is not itself a repository but an ancestor is (for example a
> home directory tracked as dotfiles), the toolset resolves to that ancestor and
> `git_show` / `git_blame` can expose its full history and file contents. The
> filesystem toolset's allow/deny lists do **not** apply here. Only enable this
> toolset where the surrounding repository is safe to read.

> [!NOTE]
> **Performance.** go-git is pure Go, which costs speed on large repositories:
> `git_status` rehashes the whole worktree, and `git_blame` scales with history
> depth times file size — its 400-line output cap is applied *after* the full
> computation, so it does not make blaming a large file cheaper.

## Tools

| Tool | Description |
| --- | --- |
| `git_status` | Current branch and changed files (staged / unstaged / untracked). |
| `git_log` | Recent commits (hash, date, author, subject). |
| `git_branches` | Local branches, current one marked with `*`. |
| `git_show` | A commit's metadata, message, and changed files with +/- counts. |
| `git_blame` | Line-by-line authorship for a file. |

### `git_log`

| Parameter | Required | Description |
| --- | --- | --- |
| `limit` | No | Maximum number of commits to return (default 20). |
| `path` | No | Only show commits that touch this path. |

### `git_show`

| Parameter | Required | Description |
| --- | --- | --- |
| `ref` | No | Commit hash or revision to show (default HEAD). |

### `git_blame`

| Parameter | Required | Description |
| --- | --- | --- |
| `path` | Yes | File path to blame, relative to the repository root. |
| `rev` | No | Commit or revision to blame at (default HEAD). |

## Example

```yaml
agents:
root:
model: openai/gpt-5-mini
description: A code review assistant
instruction: |
Review the working changes: check git_status, then git_show the latest
commit, and summarize what changed.
toolsets:
- type: git
- type: filesystem
```

Example `git_status` output:

```text
On branch master
1 changed file(s) [XY = staged/worktree; M=modified A=added D=deleted R=renamed ?=untracked]:
M main.go
```

> [!TIP]
> **When to use**
>
> Use the git toolset whenever the agent needs repository context — before editing, to review recent history, or to find who last touched a line — without exposing the writable `shell` surface.
1 change: 1 addition & 0 deletions pkg/teamloader/toolsets/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var BuiltinToolsets = []BuiltinToolsetInfo{
builtinToolset("background_jobs", "background-jobs", "Run and manage long-running shell commands"),
builtinToolset("fetch", "fetch", "Read content from HTTP/HTTPS URLs"),
builtinToolset("filesystem", "filesystem", "Read, write, list, search, and navigate files and directories"),
builtinToolset("git", "git", "Read-only git repository inspection: status, log, branches, show, blame"),
builtinToolset("lsp", "lsp", "Connect to Language Server Protocol servers for code intelligence"),
builtinToolset("mcp", "mcp", "Extend agents with external tools via the Model Context Protocol"),
builtinToolset("mcp_catalog", "mcp-catalog", "Discover and activate remote MCP servers from the Docker MCP Catalog"),
Expand Down
4 changes: 4 additions & 0 deletions pkg/teamloader/toolsets/toolsets.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/docker/docker-agent/pkg/tools/builtin/backgroundjobs"
"github.com/docker/docker-agent/pkg/tools/builtin/fetch"
"github.com/docker/docker-agent/pkg/tools/builtin/filesystem"
gittool "github.com/docker/docker-agent/pkg/tools/builtin/git"
"github.com/docker/docker-agent/pkg/tools/builtin/lsp"
"github.com/docker/docker-agent/pkg/tools/builtin/mcpcatalog"
"github.com/docker/docker-agent/pkg/tools/builtin/memory"
Expand Down Expand Up @@ -77,6 +78,9 @@ func DefaultToolsetCreators() map[string]teamloader.ToolsetCreator {
"fetch": func(_ context.Context, toolset latest.Toolset, _ string, runConfig *config.RuntimeConfig, _ string) (tools.ToolSet, error) {
return fetch.CreateToolSet(toolset, runConfig)
},
"git": func(_ context.Context, _ latest.Toolset, _ string, runConfig *config.RuntimeConfig, _ string) (tools.ToolSet, error) {
Comment thread
dwin-gharibi marked this conversation as resolved.
return gittool.CreateToolSet(runConfig)
},
"mcp": func(ctx context.Context, toolset latest.Toolset, _ string, runConfig *config.RuntimeConfig, _ string) (tools.ToolSet, error) {
return mcp.CreateToolSet(ctx, toolset, runConfig)
},
Expand Down
Loading