Skip to main content
AI tutorials

Build an AI-Agent-Friendly Version Control Server with gitai

This tutorial introduces gitai, an open-source, server-centric version control system designed for coding agents. You will build it from source, run the example environment, understand its architecture, configure a server, and explore landing, storage, caching, reviews, and verification workflows.

Build an AI-Agent-Friendly Version Control Server with gitai

What is gitai?

gitai is an open-source version control system designed for AI coding agents. It implements a server-centric approach in which clients remain online, fetch only the objects and paths they need, and send source-control operations to a server.

The project is inspired by the publicly described design of Anthropic's Scion, but gitai is an independent implementation. It is MIT licensed, vendor neutral, and does not require the server to call a language model. AI-powered operations can use any provider, a deterministic tool, or no AI provider at all.

Under the hood, gitai uses normal Git repositories while moving history queries, landing, changeset tracking, and repository coordination to the server. This model is intended for workloads with many short-lived tasks that need to land changes quickly on shared branches.

Key features

  • Selective data access: the object service provides individual objects and sparse trees. The graft clone and graft sparse commands materialize only requested paths.
  • Server-side history: blame, path history, ancestry, and code search run on the server and are memoized as derived data.
  • Concurrent landing: UserLand rebases changes onto the current branch tip and uses compare-and-swap updates instead of a traditional merge queue. Concurrent lands can be batched into one reference update.
  • Conflict resolution: conflicting lands can use a selected resolver through a versioned, vendor-neutral protocol.
  • Changeset log: accepted reference updates record their operation and actor in an ordered log that clients can list or watch.
  • Scalable storage: SQLite or PostgreSQL stores changesets, references, reviews, and the write-ahead log, while content-addressed packs can live in file storage, S3, GCS, or Azure.
  • Agent controls: per-agent tokens, RPC allowlists, and branch policies determine which operations agents can perform.
  • Verification and monitoring: graft-verify can test the tip, bisect a failure, and revert the change responsible. Monitoring agents, called superfans, follow the changeset stream and can report through Slack.
  • Strict caching: graft-cache can cache immutable objects in daemon and regional tiers while verifying each object.

How the architecture works

Agents, CI jobs, and sparse workspaces communicate with the gitai server through the Graft CLI or Go SDK over gRPC. An optional graft-cache daemon sits in front of the server to provide additional cache tiers.

The server handles landing, object access, changesets, derived data, search, and review. Its write path combines a changeset with a compare-and-swap operation for each reference. Database storage holds the changeset write-ahead log, references, changelog, and reviews. Object storage holds content-addressed packs.

Server nodes are designed to be stateless caches that can be rebuilt. This allows additional nodes to be added as the deployment grows. Local Git repositories remain available as caches that any node can rebuild.

For more detail, read the project's architecture documentation and storage documentation.

Install and build gitai

1. Install the prerequisites

gitai currently requires Linux or macOS, Go 1.26, a C toolchain, Meson, and Ninja. The build compiles a bundled version of Git, so make sure the required native build tools are available before starting.

2. Clone the repository

git clone https://github.com/feder-cr/git-ai.git
cd git-ai

3. Build the binaries

Run the Make target to build the server, CLI, and supporting tools:

make build

The resulting binaries are placed in _build/bin. To inspect the CLI and its available commands, run:

./_build/bin/graft

Run the quickstart

The repository includes an example that starts a temporary gitai environment with a server, a cache daemon, two agents, and a land operation:

examples/graft/quickstart.sh

This is the fastest way to see the core workflow without preparing a permanent database, object store, or deployment. Because the example uses a temporary directory, it is best suited to learning and experimentation.

Run your own server

1. Start with the example configuration

Use examples/graft/config.toml as a starting point for a custom server configuration. The server can be started with the built binary:

_build/bin/gitaly serve config.toml

Within the source tree, the server-side extensions are called Graft. You will see this name in the [graft] configuration section, the graft CLI, the internal/graft package, and the Graft documentation.

2. Add database and object storage

For a deployment in which repository state is stored in a database and object storage, add a [graft.storage] section to the configuration. The documented migration process is to start in shadow mode, import repositories, and then switch to authoritative mode.

Follow the storage guide for the exact configuration and migration details. The supported storage model uses SQLite or PostgreSQL for coordination data and file, S3, GCS, or Azure storage for content-addressed packs.

Work with agent changes

In a traditional Git workflow, each worker may clone a repository, develop locally, and push to a shared branch. gitai instead allows agents to stay connected to the server and request only the data they need.

Agents can use sparse workspaces to limit materialized paths. The relevant commands include:

  • graft clone to materialize a selected view of a repository.
  • graft sparse to request or adjust only the paths needed by a task.

When an agent is ready to contribute, UserLand rebases the change onto the current tip and attempts a compare-and-swap update. If several agents land changes concurrently on one branch, gitai can batch those operations into one reference update rather than forcing every agent through a separate merge queue.

If the land produces a conflict, configure a resolver according to the conflict-resolution documentation. The resolver can be based on an LLM provider, a deterministic tool, or no external AI provider.

Explore changesets, reviews, and verification

Changeset history

Every accepted reference update becomes an entry in the changeset log. The entry includes the operation and actor, giving clients an ordered record that they can list or watch live. This stream can also drive monitoring agents that track changes relevant to particular components.

Reviews and policies

gitai includes agent-friendly reviews with semantic approval rules. For example, a comment-only change can require fewer approvals than a logic change. Agent security controls also include per-agent tokens, RPC allowlists, and branch policies.

Read the review documentation and agent security documentation before exposing a server to automated users.

Verification after landing

The graft-verify workflow tests the branch tip after changes land. If a test fails, it can bisect the changes and revert the change that introduced the failure. This supports a workflow in which integration happens continuously and the system identifies the change responsible for a broken tip.

See the verification guide for the supported workflow and configuration.

Advanced deployment tips

  • Use caching deliberately: add graft-cache when agents or CI jobs need fast access to immutable objects across daemon or regional cache tiers.
  • Separate coordination from object storage: use SQLite or PostgreSQL for changesets and references, and configure the object-storage backend for repository packs.
  • Scale with additional nodes: the server nodes are designed as rebuildable caches, so adding nodes does not require each node to hold an independent authoritative state.
  • Read the landing documentation: the landing and batching guide explains the compare-and-swap workflow and concurrent updates.
  • Review current limitations: this is version 0.1.0, interfaces may change before 1.0, and known gaps such as garbage collection of packs are documented in LIMITATIONS.md.
  • Use the design documents: PLAN.md through PLAN6.md explain the rationale and evolution of the implementation.

Conclusion

gitai adapts a server-centric source-control model for repositories worked on by many concurrent coding agents. Its Graft CLI and server provide sparse data access, server-side history, compare-and-swap landing, conflict resolution, changeset logs, reviews, verification, and scalable storage.

Start with make build and examples/graft/quickstart.sh, then move to a configured server and persistent storage when you understand the workflow. For deeper implementation and operational guidance, use the project's Quickstart, configuration reference, and architecture documentation.