SameTree
Local coordination for coding agents that share a Git working tree.
README
SameTree
Run multiple Claude Code and OpenCode agents in the same repository and branch.
SameTree is a local multi-agent coordination MCP server for running multiple Claude Code, OpenCode, and other coding agents in parallel on the same repository, branch, and working tree. Agents share tasks, file claims, messages, handoffs, and repository policy without separate Git worktrees, a daemon, or a cloud service.
<p align="center"> <img src="docs/demo.svg" alt="SameTree setup, task and path ownership, conflict prevention, and agent messaging" width="100%"> </p>
What It Does
- Gives agents a shared task board and inbox.
- Prevents agents from unknowingly editing the same paths.
- Transfers work through structured handoffs.
- Shares coordination rules through versioned repository files.
- Stores all live state locally in the Git worktree.
Requirements
- Node.js 22.12 or newer
- Git
- A local filesystem
SameTree does not support state databases on NFS, SMB, cloud-synced folders, or multiple machines.
Install
git clone https://github.com/simozampa/sametree.git
cd sametree
npm ci
npm run build
npm link
SameTree is not yet published to npm. npm link exposes sametree and sametree-mcp from the source checkout.
Quick Start
cd /path/to/your/project
sametree setup --claude --opencode
Setup is required once per project. It configures the requested harnesses and writes shared instructions under .sametree/. After that, start agents normally in separate terminals:
opencode
claude
Every instance gets a unique identity automatically and joins the agents in that worktree. Different projects and Git worktrees use separate state. Avoid switching branches while agents are active because every process in that worktree sees the same checkout.
Coordination Loop
The generated agent instructions tell each agent to:
- Check current tasks, claims, messages, and policy.
- Claim a task and the smallest paths it needs.
- Coordinate conflicts instead of overwriting another agent.
- Update or hand off work and release claims when finished.
Agents normally use the MCP tools directly. The CLI provides the same coordination surface for humans and scripts:
export SAMETREE_AGENT=opencode-1
export SAMETREE_HARNESS=opencode
sametree status
sametree task create --title "Add request validation" --priority high
sametree task claim task_...
sametree claim acquire src/http/request.ts test/http/request.test.ts
sametree task update task_... --status done
sametree claim release --all
SAMETREE_AGENT=observer sametree watch --tail
Optional Git hooks can reject commits that overlap active claims or violate repository policy:
export SAMETREE_AGENT=human
sametree hooks install
How It Works
Each MCP client starts a local SameTree process. All clients in one worktree open the same SQLite database under Git's private worktree directory:
Claude Code ─┐
Claude Code ─┼─ MCP stdio / CLI ─ Domain service ─ SQLite WAL
OpenCode ────┤ └─ Git working tree
OpenCode ────┘
There is no server to run. State stays local and is never committed.
SameTree is designed for trusted agents on one machine. It coordinates edits but does not merge simultaneous changes or sandbox processes.
FAQ
Can multiple Claude Code and OpenCode agents safely work in the same repository?
SameTree reduces collisions between Claude Code and OpenCode instances sharing one checkout. Each agent gets its own identity, sees the same task board, and claims files before editing them.
Do parallel coding agents need separate branches or Git worktrees?
Not when the work is intertwined. SameTree is built for agents collaborating on the same branch and live working tree. Independent tasks can still use separate Git worktrees, which SameTree keeps isolated.
How do coding agents share context across sessions?
SameTree stores tasks, messages, handoffs, claims, and policy acknowledgements in a worktree-local SQLite database. Claude Code and OpenCode access that shared context through MCP tools.
Is SameTree a Conductor alternative?
Conductor gives each task an isolated workspace, branch, files, and merge path. SameTree coordinates agents inside one live working tree. Use Conductor-style isolation for independent tasks and SameTree for coupled work that must share uncommitted state.
How is SameTree different from agent-talk?
agent-talk provides encrypted agent-to-agent messaging across people and machines through a relay. SameTree stays on one machine and adds tasks, file claims, handoffs, policy, and Git checks for agents sharing a working tree.
Does SameTree work across multiple machines?
No. SameTree is intentionally local to one machine and one Git worktree. Use a networked coordination or messaging tool when agents need to communicate across machines.
Documentation
- Architecture: storage and concurrency decisions
- Protocol: tools, state transitions, and invariants
- Four-agent review loop: worker and reviewer example
- Contributing: development and demo generation
- Security: vulnerability reporting
Development
npm ci
npm run check
npm pack --dry-run
License
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.