Skip to content

Fato07/agit

agit

CI Release Go Report Card Go Version License: MIT

Infrastructure-aware Git orchestration for AI agents.

agit gives AI coding agents persistent, queryable awareness of their Git infrastructure. It manages a local registry of repositories, orchestrates Git worktrees for agent isolation, detects cross-worktree conflicts, and coordinates task assignment across multiple agents.

The Problem

AI coding agents (Claude Code, Cursor, Codex, OpenClaw) operate without persistent memory of their infrastructure. Each session starts blind — no knowledge of available repos, active work, or what other agents are doing. When multiple agents work on the same repo, conflicts are discovered only at merge time.

The Solution

agit provides:

  • Persistent registry — agents always know what repos are available via MCP
  • Worktree isolation — each agent gets its own workspace, no stepping on toes
  • Conflict detection — know about overlapping changes before merge time
  • Task coordination — agents claim work atomically, preventing duplication
  • Hook system — trigger custom scripts on worktree, task, and conflict events

Quick Start

# Install (binary)
curl -sSfL https://raw.githubusercontent.com/Fato07/agit/main/install.sh | sh

# Or install from source
go install github.com/fathindos/agit@latest

# Initialize
agit init

# Register your repos
agit add ~/projects/my-app --name my-app
agit add ~/projects/api --name api

# Spawn isolated worktrees for agents
agit spawn my-app --task "refactor auth" --agent claude-1
agit spawn my-app --task "add tests" --agent cursor-1

# Check for conflicts
agit conflicts my-app

# See everything at a glance
agit status

# Merge completed work back
agit merge <worktree-id> --cleanup

Demo

agit demo

MCP Integration

Add agit to your agent's MCP config for automatic infrastructure awareness:

{
  "mcpServers": {
    "agit": {
      "command": "agit",
      "args": ["serve"]
    }
  }
}

Now any MCP-compatible agent can call agit_list_repos() on startup and immediately know what's available.

Commands

Command Description
agit init Initialize agit (~/.agit/)
agit add <path> Register a Git repository
agit repos List registered repositories
agit spawn <repo> Create isolated worktree for an agent
agit status [repo] Show worktrees, agents, conflicts
agit conflicts [repo] Check for overlapping file changes
agit tasks <repo> Manage tasks (create/claim/complete/next)
agit agents List and manage registered AI agents
agit merge <id> Merge worktree back to base branch
agit cleanup Remove completed/stale worktrees
agit serve Start MCP server (stdio or SSE)
agit update / agit upgrade Self-update to the latest release
agit config show Display current configuration
agit config set <key> <value> Set a configuration value
agit config path Print configuration file path
agit config reset Reset configuration to defaults

Global Flags

Flag Description
--no-color Disable colored output
-q, --quiet Suppress informational messages
-o, --output <format> Output format: text (default) or json
-i, --interactive Enable interactive selection mode

Configuration

agit stores its configuration in ~/.agit/config.toml. Use agit config subcommands or edit the file directly.

[server]
transport = "stdio"       # "stdio" or "sse"
port = 3847               # Port for SSE transport

[defaults]
branch_prefix = "agit/"           # Prefix for auto-generated branch names
worktree_dir = ".worktrees"       # Directory for worktrees within repos
cleanup_stale_after = "24h"       # Duration before stale worktrees are cleaned
auto_conflict_check = true        # Check for conflicts automatically

[agent]
heartbeat_interval = "30s"        # Agent heartbeat frequency
stale_after = "5m"                # Duration before agents are marked disconnected

[ui]
color = ""                # "auto", "always", or "never" (empty = auto)
output_format = ""        # "text" or "json" (empty = text)
compact = false           # Compact output mode

[updates]
enabled = true            # Enable automatic update checking
check_interval = "24h"   # How often to check for updates

hook_timeout = "30s"      # Maximum execution time for hooks

[hooks]
# Run shell commands on events (async, non-blocking)
# "worktree.created" = "notify-send 'New worktree created'"
# "task.claimed" = "echo $AGIT_TASK_ID >> /tmp/claimed.log"
# "task.completed" = "./scripts/on-task-done.sh"
# "task.failed" = "curl -X POST https://hooks.example.com/fail"
# "worktree.removed" = "echo cleaned"
# "conflict.detected" = "slack-notify 'Conflict found'"

Supported hook events: worktree.created, worktree.removed, task.claimed, task.completed, task.failed, conflict.detected

Hooks receive environment variables: AGIT_EVENT, plus event-specific variables like AGIT_WORKTREE_ID, AGIT_TASK_ID, AGIT_REPO.

All dot-notation keys for agit config set:

server.transport, server.port, defaults.branch_prefix, defaults.worktree_dir, defaults.cleanup_stale_after, defaults.auto_conflict_check, agent.heartbeat_interval, agent.stale_after, ui.color, ui.output_format, ui.compact, updates.enabled, updates.check_interval, hook_timeout, hooks.<event>

MCP Tools Reference

When running as an MCP server (agit serve), the following tools are available to agents:

Tool Description
agit_list_repos List all registered repositories
agit_repo_status Get detailed status for a specific repository
agit_spawn_worktree Create an isolated worktree for an agent
agit_remove_worktree Remove a worktree from disk and registry
agit_check_conflicts Scan for file conflicts across active worktrees
agit_list_tasks List tasks for a repository
agit_claim_task Atomically claim a pending task for an agent
agit_complete_task Mark a task as completed with optional result
agit_merge_worktree Merge a worktree branch into the default branch
agit_register_agent Register a new AI agent
agit_heartbeat Update agent heartbeat timestamp
agit_create_task Create a new task for a repository
agit_fail_task Mark a task as failed with optional reason
agit_start_task Mark a claimed task as in-progress with a worktree
agit_list_agents List all registered AI agents
agit_list_worktrees List worktrees for a repository
agit_get_task Get detailed information about a specific task
agit_add_repo Register a Git repository via MCP
agit_cleanup_worktrees Prune orphaned worktrees
agit_next_task Atomically claim the highest-priority pending task

License

MIT

About

AI-native Git workflow tool with MCP server for agent-driven development

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors