Sandbox
@amaar-mc/wit

Agent coordination protocol for shared codebases

Wit sits between your agents and git. Agents declare intents, lock symbols, and check for conflicts over a Unix socket, while git still handles version control.

46 stars3 forksTypeScriptUpdated 5mo ago
Who it's for

Builders who want multiple coding agents to work in one repository without colliding on the same files or symbols.

What it delivers

You can see and avoid work overlap before code is written, instead of cleaning up merge conflicts later.

What it does

Intent tracking

Agents announce what they plan to work on with `wit declare` so others can see the scope.

Symbol locks

Agents reserve specific functions, classes, types, or exports with `wit lock` instead of locking whole files.

Conflict detection

The daemon warns when intents overlap, when a lock is already held, or when one change depends on another locked symbol.

Contract enforcement

Accepted function-signature contracts are checked by a Git pre-commit hook and can block invalid commits.

Claude Code plugin

The plugin adds a `wit:coordinate` skill and a session hook that loads shared state at startup.

Git hook integration

`wit hook install` sets up commit-message and pre-commit hooks for intent tracking and contract checks.

How to get it

  1. 1Wit requires Bun (v1.0+). It uses Bun-native APIs for the daemon, SQLite, and process…
    curl -fsSL https://bun.sh/install | bash
  2. 2From npm
    bun install -g wit-protocol
  3. 3From source
    git clone https://github.com/amaar-mc/wit.git
    cd wit
    bun install
    bun link
  4. 4Run
    cd your-project
    wit init

README

wit

Agent coordination protocol for shared codebases

Declare intents. Lock symbols. Detect conflicts. Before code is written.

CI npm License Stars


Wit demo — two agents, same file, LOCK_CONFLICT

Wit coordinates multiple AI coding agents working on the same repository simultaneously. It sits between your agents and git — git handles version control, Wit prevents the conflicts.

The name comes from the word itself: the intelligence to coordinate before colliding. It also stands for Workspace Intent Tracker.

The Problem

You have three Claude Code instances (or Cursor, Copilot, Devin — any combination) working on the same repo. Without coordination, they each write code independently and produce merge conflicts that waste time and break work.

Git detects conflicts after they happen. Wit prevents them before code is written.

How It Works

Wit runs a lightweight daemon in the background. Agents communicate with it over a Unix socket using JSON-RPC. The daemon tracks four things:

PrimitiveWhat it doesExample
IntentsAgent announces planned work scope"I'm refactoring the auth module"
LocksAgent reserves a specific function/type/classLock src/auth.ts:validateToken
ConflictsDaemon warns when intents or locks overlap"Agent B also declared intent on auth.ts"
ContractsAgents agree on function signatures"validateToken accepts string, returns boolean"

Intents and locks are warnings, not blocks. Agents always get to decide what to do. The only hard enforcement is contracts — a git pre-commit hook blocks commits that violate an accepted contract signature.

Quick Start

Prerequisites

Wit requires Bun (v1.0+). It uses Bun-native APIs for the daemon, SQLite, and process management. Install Bun if you don't have it:

curl -fsSL https://bun.sh/install | bash

Install the CLI

From npm:

bun install -g wit-protocol

From source:

git clone https://github.com/amaar-mc/wit.git
cd wit
bun install
bun link

After either method, the wit command is available globally.

Initialize in your repo

cd your-project
wit init

This creates a .wit/ directory, starts the daemon, and generates a CLAUDE.md with coordination instructions. You only run this once per project — the daemon auto-starts on subsequent commands.

Every Claude Code session in this project will now automatically read the CLAUDE.md and follow the coordination protocol. Agents declare intents, lock symbols, and respect conflicts without any manual setup.

Basic workflow

# See what's happening
wit status

# Declare intent before working
wit declare --description "Adding rate limiting to API" --files src/api.ts --files src/middleware.ts

# Lock a specific function you're about to modify
wit lock --symbol "src/api.ts:handleRequest"

# Check status — your intent and lock are visible to all agents
wit status

# Release when done
wit release --symbol "src/api.ts:handleRequest"

# Watch live updates (like htop for coordination)
wit watch

What agents see

When Agent B tries to work in an area Agent A has claimed:

# Agent B declares intent on the same file
$ wit declare --description "Fixing auth bug" --files src/api.ts

# Response includes conflict warning:
# {
#   "intentId": "abc-123",
#   "conflicts": {
#     "hasConflicts": true,
#     "items": [{
#       "type": "INTENT_OVERLAP",
#       "message": "Agent A has active intent on src/api.ts"
#     }]
#   }
# }

Agent B sees the warning, checks what Agent A is doing, and chooses to work on a different part of the codebase.

Claude Code Plugin

Wit ships as a Claude Code plugin. Once installed, agents automatically declare intents and lock symbols before editing — no manual configuration.

Step 1: Add the Wit marketplace (one-time)

/plugin marketplace add amaar-mc/wit

Step 2: Install the plugin

/plugin install wit@amaar-mc-wit

Step 3: Make sure the CLI is installed (see Install the CLI above)

Step 4: Initialize Wit in your project

wit init

That's it. Every Claude Code instance in the project now coordinates automatically.

What the plugin provides:

  • wit:coordinate skill — Instructs agents to declare intents and acquire locks before editing code. Activates automatically when .wit/ exists.
  • Session hook — On session start, loads current coordination state so agents immediately see what other agents are working on.

Without Claude Code: Wit works with any AI agent that can run shell commands. Add instructions to your agent's system prompt to call wit declare, wit lock, wit status, and wit release. See the Protocol Specification for the raw JSON-RPC API.

Commands

CommandWhat it does
wit initCreate .wit/, start daemon, generate session ID
wit statusShow all active intents, locks, contracts, and conflicts
wit declareAnnounce intent to work on files/symbols
wit lockAcquire a semantic lock on a specific symbol
wit releaseRelease a held lock
wit watchLive dashboard of coordination state
wit hook installInstall git hooks for contract enforcement and intent tracking

All commands support --json for machine-readable output.

Semantic Locking

Wit doesn't lock files — it locks symbols. A symbol is a function, class, type, or export identified by its path:

src/auth.ts:validateToken      # a function
src/models.ts:User             # a type/class
src/utils.py:calculate_score   # a Python function
src/utils.py:RateLimiter       # a Python class

Wit uses Tree-sitter WASM grammars to parse your code and identify symbol boundaries — the exact byte range of each function, class, and type. Two agents can safely work on different functions in the same file.

Supported languages: TypeScript, JavaScript, Python.

Conflict Detection

When an agent declares an intent, Wit runs three checks:

CheckWhat it catches
Intent OverlapTwo agents targeting the same code region
Lock IntersectionIntent targets a symbol locked by another agent
Dependency ChainIntent targets a caller of a locked symbol

All conflicts are warnings. The intent still succeeds. The agent decides what to do.

Contracts

Agents can agree on function signatures. Once accepted, a git pre-commit hook enforces the contract — commits that change the agreed signature are blocked.

# Install enforcement hooks
wit hook install

# Now if an accepted contract's signature changes, the commit is rejected
git commit -m "changed params"
# ERROR: Contract violation — src/auth.ts:validateToken signature changed

Contracts are propose/accept/reject. No counter-proposals in v1.

Intent-to-Commit Tracking

wit hook install also installs a prepare-commit-msg hook. Active intents are linked to commits via git trailers:

feat: add rate limiting

Wit-Intent: abc-123-def-456

Architecture

+-----------+    +-----------+    +-----------+
| Claude A  |    | Cursor B  |    | Copilot C |
+-----+-----+    +-----+-----+    +-----+-----+
      |                |                |
      |   JSON-RPC over Unix socket    |
      |                |                |
      +--------+-------+----------------+
               |
         +-----+------+
         | Wit Daemon  |
         |             |
         |  Hono HTTP  |
         |  SQLite WAL |
         |  Tree-sitter|
         +-----+------+
               |
         .wit/daemon.sock
         .wit/state.db
  • Daemon: Bun process, Hono HTTP server, Unix domain socket
  • Storage: SQLite with WAL mode for concurrent agent access
  • Parsing: Tree-sitter WASM grammars (zero native dependencies, no build step)
  • CLI: Clipanion, auto-starts daemon on first use
  • Protocol: JSON-RPC 2.0 with witVersion field for version negotiation

Protocol Specification

Wit exposes 12 JSON-RPC methods for agent coordination. Full spec in two formats:

Any AI coding tool that can POST JSON to a Unix socket or run a shell command can participate in the coordination protocol. Build your own integration using the spec.

.wit/ Directory

FilePurpose
daemon.sockUnix domain socket for JSON-RPC communication
daemon.pidDaemon PID for lifecycle management and crash recovery
state.dbSQLite database with WAL mode for concurrent access
session.idStable session identifier for agent tracking

Add .wit/ to your .gitignore.

Supported Languages

Wit uses Tree-sitter WASM grammars to parse source code at the AST level. Currently supported:

  • TypeScript / JavaScript (functions, arrow functions, methods, types, interfaces, classes)
  • Python (functions, classes)

Adding a new language is straightforward. See issue #1 (Go), #2 (Rust), or #4 (Java/Kotlin) for examples of what's involved.

Limitations (v1)

  • Single machine only (no network coordination between remote agents)
  • TypeScript/JavaScript and Python (more languages planned, architecture is extensible)
  • CLI and API only (no GUI or dashboard beyond wit watch)
  • Warnings only (locks and conflicts never block, except contract enforcement)
  • Bun runtime required (standalone binary planned, see #10)

Contributing

Wit is open source and contributions are welcome. Good places to start:

git clone https://github.com/amaar-mc/wit.git
cd wit
bun install
bun test

License

MIT


Star this repo if you find it useful.

Files in the repo

Repository payload21 top-level entries
  • .claude-plugin
  • .github
  • docs
  • drizzle
  • hooks
  • skills
  • src
  • .gitignore
  • .npmignore
  • bun.lock
  • CLAUDE.md
  • demo.gif
  • demo.mp4
  • drizzle.config.ts
  • index.ts
  • LICENSE
  • logo.png
  • marketplace.json
  • package.json
  • README.md
  • tsconfig.json

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More tools

JuliusBrussee/
caveman

🪨 why use many token when few token do trick — Claude Code skill that cuts 65% of tokens by talking like caveman

105k
1 add
MemPalace/
mempalace

The best-benchmarked open-source AI memory system. And it's free.

59k
stablyai/
orca

Orca is the ADE for working with a fleet of parallel agents. Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

66k

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

132k

Never stop coding. Free MIT AI gateway: one endpoint, 352 providers (150+ free), 1200+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 550+ contributors

64k
headroomlabs-ai/
headroom

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

71k