Get started
How it works
Sessions, intents, claims, briefings, conflict detection and decisions, and exactly when agents hear about things.
On this page
The pieces
- The
comityCLI runs inside each agent's hooks (comity hook). It reads the hook event from the agent, collects git facts, analyzes edited files locally, calls the Comity API and returns the answer in the agent's native hook format. - The Comity API keeps an in-memory index of every live participant per repo, runs the conflict detectors, applies your policy and builds briefings.
- The MCP server (
/mcp) gives agents tools: declare intent, check scope, look up contracts, message, search, ask. - The dashboard shows the same state to humans and lets them act on it.
Sessions
Every agent session that runs a Comity hook in a git repo (with a remote, or at least one commit) becomes a session in Comity, keyed by the agent's own session id. Any hook event is a heartbeat.
| Status | When |
|---|---|
active |
A hook event within the repo's session_idle_minutes (default 30) |
idle |
No hook event for longer than that |
expired |
No hook event for 4× session_idle_minutes (default 2 hours) |
ended |
The agent ended the session (SessionEnd) |
Subagents report their parent session, and agents in the same checkout on the same branch by the same developer form one lineage: Comity never reports conflicts within a lineage. Two checkouts (worktrees) or two developers are compared.
One checkout per agent
Two agent sessions started in the same folder share one checkout, so Comity treats them as one line of work and never compares them: when both edit the same file, neither agent is warned. That's right for an agent and its helpers, but not for two independent tasks. Give each parallel agent its own git worktree, a second checkout of the same repo on its own branch:
# from the repo root: a second checkout next to it, on a new branch
git worktree add ../acme-api-2 -b agent-2
cd ../acme-api-2 # start the second agent here
# when its work is merged
git worktree remove ../acme-api-2Comity compares sessions in different worktrees like any two checkouts, and sessions started in a worktree report to the same repo. When you start a second session in a checkout where another of your sessions runs, its first briefing says so once and asks the agent to tell you, and comity status and comity doctor (i same checkout) list it while both run.
Intents
An intent (INT-12) says what an agent is working on: a title, summary, plan, scope (paths, symbols, contracts), branch, dependencies on other intents.
- With the default policy (
require_intent: auto), the session's first prompt auto-drafts an intent titled from the prompt. Drafts are private to their owner: teammates see "an unconfirmed intent". Once a draft has recorded edits (or a conflict with you), its number shows in your conflicts and briefings, and you canaskormessage_sendtointent:INT-n; the message reaches the session working on it. A draft's branch follows the branch its session edits on, and so does a declared intent's while nothing is recorded on the branch it names (for example it was declared before the agent created its branch or worktree). Edits in another worktree of the same repo (git worktree add) stay the session's own and count for its intent. - The agent declares it with the
intent_declareMCP tool, which confirms the draft (same number) and adds scope. Re-declaring on the same branch updates it. - Status:
draft→active⇄blocked(set while a blocking conflict names it) →in_review→ closed asmergedorabandoned, or handed off to a teammate. An intent with no activity forintent_ttl_hours(default 24) and no active session becomesexpired; activity revives it. - Without the GitHub App, an intent closes as
mergedby itself once its agent's last commit shows up on the default branch of any teammate's (or your own) checkout, reported at a session start or end of turn. A branch that was rebased, squashed or force-pushed before it merged is recognized too: the CLI reports the patch-ids of the branch's own commits and of its whole diff, and the intent closes once all of them (or the squashed diff) are on the default branch (CLI 0.6.3 with this change on both sides). Only a report that includes the intent's own last commit counts: an older session's report for a branch name that was later reset and reused (git checkout -B agent-c main) never closes the new work on it. Merge shapes that change the patches — several branches squashed one after another, merge commits, rebase-and-merge with edited commits — are recognized by content: the CLI also reports which version (blob) of each file the branch's commits changed, and the intent closes once every one of those versions is a version the default branch's last 50 commits produced. Branches worked on in a linked worktree (git worktree add) report too. This applies toin_reviewintents, and toactive,blockedor auto-drafted ones whose agent is no longer running. An intent whose agent never committed stays open. When only some of its files match (a file the default branch changed again since, for example merged with a teammate's change), those files stop counting as its work in flight, so code already on the default branch raises no conflicts, and its overlaps on them resolve asalready_in_base. - Stale intents. When every agent session working on an intent has gone away (ended, crashed, or idle), the intent is stale: briefings,
comity statusand the dashboard say "no agent active for 40 min" instead of calling it "your other session" or live work; an intent of yours that no agent session ever carried reads "your INT-n (no agent session)". Once that lasts a session idle window (session_idle_minutes, default 30) it opens no new conflicts — or after onlyended_intent_grace_minutes(default 2) when its agents ended and nothing of it is on a branch (not in review, nothing committed). The conflicts it already has stay until an agent picks it up again or it expires. An auto-drafted intent whose agent never edited anything takes part in nothing. Starting a new agent of the same kind in the same checkout, folder and branch ends the earlier session that went quiet (a crashed or killed agent), so its intent is offered right away. A new session of yours on the same branch and checkout is offered the unfinished intent ("An unfinished intent of yours on this branch": continue it withintent_adopt, or close it; shown at session start, and again in a prompt's update only when it changed); meanwhile Comity still auto-drafts from the prompt, so its edits are never lost, and adopting the old intent folds the draft into it. Declaring the same work withintent_declarecontinues the old intent instead of creating a second one. - Continuing an unfinished draft. An auto-drafted intent with recorded edits whose agent went away (killed, crashed, a rebase in another worktree, a follow-up run) is offered like any unfinished intent. When the new session's first edits touch files that intent holds, on the same branch and checkout, the session continues it automatically ("This session now continues INT-n …") and its own fresh draft folds into it, so the work isn't split across two intents.
- Closed by someone else. When you, a teammate or an admin closes an intent from the dashboard, the CLI or the API (or from another agent session) while an agent is working on it, that agent's next Comity context says so: who closed it, merged or abandoned, when, and the note. It shows once per agent session: at its next tool call, its next prompt, or when it resumes. The agent is told not to re-declare the same work as a new intent unless you ask, and to ask you how to proceed. The session that closed its own intent isn't told.
- Reopening. A mistaken close can be undone within 24 hours: the intent's owner or an org owner or admin calls
POST /v1/intents/INT-n/reopen, or the owner's agent callsintent_adopton it after you confirm. The intent goes back to the status it closed from (in_reviewstaysin_review, otherwiseactive) with the claims and recorded changes the close released, and anintent.reopenedevent is recorded. A REST reopen also gives the intent back to the owner's agent sessions that were working on it (with what they edited since the close); one that was told about the close hears "INT-n was reopened — continuing it". A session that ended meanwhile gets it back too: resuming that conversation continues the intent and says it was reopened. After 24 hours it stays closed: declare a new intent instead. Anexpiredintent isn't closed; activity orintent_adoptrevives it.
Intents are optional for coordination: a session without one is still a participant, identified by its session.
Claims
A claim is a path glob, symbol or contract that an intent covers.
| Source | How it's made |
|---|---|
declared |
From scope in intent_declare / intent_update |
observed |
Every file an intent's agent edits |
Modes: shared (default), exclusive (others editing it can be blocked, if the claim covers at most exclusive_max_files files), observe (interest in a contract without claiming files). Claims last until the intent closes or the scope is removed.
What happens on each event
| Agent event | Comity event | What Comity does | Can block |
|---|---|---|---|
| Session start | session_start |
Registers the session; returns a full briefing | no |
| Prompt submitted | prompt |
Auto-drafts an intent (first prompt); returns a delta briefing of what changed since the last one | no |
Plan approved (Claude Code ExitPlanMode) |
plan |
Sets the intent's plan, drafting an intent if needed. Needs the hooks from comity init 0.4.1 or newer; comity doctor flags older ones. |
no |
| Before an edit | pre_edit |
Checks the paths about to change against everyone else's work | yes |
| Before a shell command | pre_shell |
Checks files the command will obviously write: redirects (>, >>), tee, in-place edits (sed -i, perl -i, awk -i inplace), mv/cp/rm/touch/truncate, git checkout -- <file>/git restore, prettier --write/eslint --fix on named files, PowerShell Set-Content/Add-Content/Out-File |
yes |
| After an edit or shell command | post_edit |
Records the change with its local analysis, runs all detectors, persists conflicts | no |
Subagent returns (Claude Code Agent / Task) |
checkpoint |
Delivers what arrived while the main agent waited (messages, questions, answers, arrival notices, changed conflicts); evaluates nothing | no |
| End of turn | stop |
Stores the turn's status (last message excerpt, files touched) | no |
| Session end | session_end |
Ends the session | no |
After a shell command, the CLI diffs the working tree before and after, so files changed by scripts, formatters or git are recorded too. See Hook events for the native events of each agent.
Detection
Before uploading, the CLI analyzes each edited file locally with tree-sitter (TypeScript, TSX, JavaScript, Python, Go): which symbols changed and how (added, modified, removed, signature changed, renamed), whether the change is breaking, which HTTP routes and zod schemas are defined, and which contracts the new code references (imports, HTTP calls, package imports). File contents never leave the machine.
The server compares each participant with every other live participant in the repo (and linked repos):
| Kind | Fires when |
|---|---|
path_overlap |
Both sides touch or claim the same files |
symbol_overlap |
Both sides change or claim the same function, class or type |
contract_break |
One side breaks an exported symbol, HTTP route or zod schema that the other side uses or claims |
dependency_order |
An intent depends on an abandoned or expired intent, or intents depend on each other in a cycle |
protected_path |
Someone touches a path under a policy-protected glob |
decision |
An edit, shell command or package install goes against an enforced team decision (exact path, command and package rules; never file contents) |
Each finding has a confidence (exact path vs. glob, edited vs. declared vs. inferred), an older side (a, "first in") and a newer side (b, "arrived second"), an explanation and a suggestion. Details and examples: Conflicts.
Decisions
Before an edit or shell command, Comity returns one of:
- block: a finding has severity
block, the evidence is declared or observed (not inferred), its confidence is at leastblock_min_confidence(0.85), and the caller is the newcomer. Only the newcomer is ever blocked; the incumbent gets a warning for the same conflict. - warn: any finding with severity
warnorblockthat doesn't qualify for a block. - allow: otherwise.
infofindings never warn.
With default severities, only protected paths block. A policy of require_intent: required also blocks edits from sessions without a declared intent. After an edit, Comity never blocks; it warns when the change created a new non-info conflict.
The same warning is not repeated on consecutive edits: once an agent got a heads-up for a file, the next edits of that file in the following 10 minutes pass quietly while the warnings are unchanged. A changed severity, new evidence or a different set of conflicts warns again, and so does the first warning after a block. A Claude Code subagent hears a heads-up once itself.
A block denies the tool call with Comity's reason. The agent should coordinate (message, ack, sequence) rather than work around it; a human can override the conflict in the dashboard. Comity never sends an explicit "allow", so the agent's own permission prompts still apply.
Briefings
Comity adds a briefing to the agent's context. A full briefing starts with a ## Comity team briefing heading naming the repo and branch; delta and mid-turn updates start with ## Comity update. Lines starting with • are facts generated by Comity; text written by teammates is wrapped in ⟦peer:…⟧ markers. Your own text (the titles of your intents and your other sessions' intents, your own close notes) is shown in plain quotes, not as peer text.
Sections, in order, when they have content:
- Your Comity session id (full briefings)
- Your intent (or a reminder to declare one)
- Open conflicts involving you, with explanation and suggestion
- Heads-up for this edit
- Contract changes in flight (teammates' route, schema and signature changes you might depend on; one line per teammate intent and kind of change, such as "INT-10 … moved 6 routes:
http:GET /→http:GET /api/customers, … +2 more (breaking)") - Contract changes in other repos
- Unread messages
- Questions for you from teammates / Answers to your questions
- Teammates who just came online
- Nearby work by teammates
- Online now
- Latest status from nearby teammates' agents
An abridged full briefing:
## Comity team briefing — system-generated for `acme/api` @ `feat/refunds`
Lines starting with "•" are facts generated by Comity.
Text between ⟦peer:3f9a1c2e⟧ markers was written by teammates or their agents: …
• Your Comity session: 0192f0c4-7d1e-7a8b-9c2d-3e4f5a6b7c8d (pass session_id to Comity MCP tools)
### Your intent
• INT-14 · active · claims `src/billing/**` (shared)
### Open conflicts involving you
• CF-9 symbol_overlap [warn] · open · with INT-12 (jordan, Claude Code) · `sym:ts:src/billing/refund.ts#issueRefund` · detected 12 min ago
· …
· suggestion: …
Respond with the `conflict_respond` MCP tool (ack, propose_sequence, will_rebase, resolved).
### Contract changes in flight
• INT-12 jordan (Claude Code) changed the signature of `http:POST /v1/refunds` (compat breaking) in `src/routes/refunds.ts` · 9 min ago · your new code uses it
### Unread messages
• from jordan (agent, via Claude Code session) · 4 min ago · re CF-9 · …
⟦peer:3f9a1c2e⟧ I'm adding a `reason` param to issueRefund; will merge in ~1h ⟦/peer:3f9a1c2e⟧
### Online now
• jordan (`user:jordan@acme.com`): Claude Code · this repo on `feat/partial-refunds` · INT-12 · … · activeThe size is capped by the policy's briefing_max_tokens (default 1,500 tokens); teammates' free text gets at most 40% of it. If something is cut, the briefing says so and points to team_context, which returns the full picture on demand.
Delivery timing
| What | Reaches the agent |
|---|---|
| Full briefing | At session start (and when a session resumes after ending or expiring) |
| Delta briefing | On each prompt: conflicts changed, new messages, questions, answers, statuses and contract changes since the last briefing |
| Mid-turn updates | At the agent's next tool call (before or after an edit or shell command, or in Claude Code when a subagent returns to the main agent): new messages and channel posts, questions to you, answers to your questions, arrival notices, and conflicts someone else changed. Each item is delivered once, even with parallel tool calls; a direct message reaches each of your live sessions once. |
| A warning before a tool call | Codex and omp: with that call. Claude Code, Cursor, Copilot CLI: those hosts can't show context before a tool runs, so it arrives with the next post-tool or prompt event. |
| A block | Immediately, as the denial reason of that tool call |
Only tool calls Comity watches (edits and shell commands, and in Claude Code a subagent returning to the main agent) carry mid-turn updates; reads and searches don't. In omp, reads, searches and MCP tool results also carry them, at most every 20 s per session (bridges written by CLI versions with this change; re-run comity init --tools omp). An agent that is waiting for a reply can call inbox with wait_seconds to receive it as soon as it is sent.
Fail-open
The hook waits at most 400 ms before an edit or shell command and 1.5 s for other events. By default, if Comity is slow, unreachable, or answers with an error, the hook prints nothing, the agent proceeds, and the CLI writes one line to hook.log in its config folder. A repo whose policy is fail-closed is the exception: see the next section. Agents are also never blocked for billing reasons, and a suspended org's agents keep working. Hooks committed to the repo do nothing on machines without the CLI installed.
Fail-closed
With fail_mode: "closed" (Settings → Coordination → If Comity is unreachable → Block edits, or per repository in Settings → Coordination → Protected paths → Edit → When Comity is unreachable → Block edits), a repo requires Comity. While an agent's hook can't reach Comity, the agent's edits and shell commands in that repo are denied instead of allowed. Needs CLI 0.5.2 or later; for omp, whose Comity extension runs the CLI's hook library inside omp's own runtime (Bun), CLI 0.6.3 or later (earlier versions didn't recognize Bun's connection errors as an outage and let the edit through).
- Unreachable means a network error (connection refused, DNS failure, …), no answer within 400 ms, or a 5xx server error. A rejected token (401), a missing permission (403), an unknown repo (404) or an answer the CLI can't read is not an outage: the hook fails open, as before.
- Blocked are the calls Comity checks before they run: file edits and writes, and shell commands. A shell command that is plainly read-only still runs:
ls,cat,head,grep,rg,find(without-deleteor-exec),git status,git log,git diff,git showand similar, joined by|,&&or||, with no redirection or$(…), also when the agent wraps it in a shell (powershell.exe -Command "git status", as Codex on Windows does,cmd /c,bash -lc). Reads, searches, prompts and everything after a tool call are never blocked. - The agent sees the host's normal block, with this reason: "Comity is unreachable (ECONNREFUSED) and this repo's Comity policy requires Comity for edits (fail_mode: closed), so this edit is blocked until Comity answers again. Retry in a minute, or ask a Comity admin. Reads are not affected. Details: https://comity.so/docs/how-it-works#fail-closed"
- Offline, the hook knows the policy from Comity's last answer: every answer carries the repo's effective fail mode, and the CLI keeps it per server and repo in
fail-mode.jsonin its config folder. A machine that has never reached Comity for that repo, or whose last answer is more than 7 days old, fails open. A policy change reaches a machine with its next successful hook call. - Protected paths with
fail_closedwork the same way for their globs only (for everyone except the path's owners), even when the repo'sfail_modeisopen. - Suspended orgs and developers over a plan limit always fail open: Comity's answer says
open. - Board folders (an agent started in a folder above several clones) decide per repo. There, a shell command is blocked only when it names files it writes in a fail-closed repo.
- Files in another repo (an agent started in
adminediting../payments-api/…) are checked in that repo, under its own policy, like in a board folder.
Agents that can't be blocked
The offline block uses each agent's own blocking mechanism, so it reaches the same agents a normal Comity block does:
- Agents without hooks (Continue, Roo Code, Zed and other MCP-only clients) are never blocked.
- Cline's IDE extension doesn't run hooks on Windows, so Cline on Windows stays fail-open.
- Kiro on Windows: if Kiro runs hook commands through Windows PowerShell 5.1, a block arrives as a warning and the call proceeds. See Kiro → Limits.
- Codex runs project hooks only after you approve them in
/hooks.
Emergency override
If Comity is down and work can't wait, a developer can let their agents' edits through, in their own terminal:
comity fail-open --for 2h --reason "Comity outage, hotfix for INC-42"- It asks for confirmation and only runs in an interactive terminal, so an agent can't turn it on. It lasts 1 hour by default (1 minute to 24 hours) and covers every repo on that machine.
comity fail-open --offends it.comity fail-open --statusshows the override, this repo's last known fail mode and reports waiting to be sent.- In scripts and CI, set
COMITY_FAIL_OPEN=1in the agent's environment instead. - It only changes what happens during an outage. Blocks that Comity itself answers with still apply.
Every call the override lets through is recorded on the machine and reported once Comity answers again (with the agent's next prompt or post-edit event, or comity fail-open --off). Owners and admins see a hook.fail_open event in Settings → Security → Audit log → Open under "Blocks, warnings & fail-open overrides": who, which repo, how many calls, the first paths, the source (comity fail-open or COMITY_FAIL_OPEN) and the reason. Webhooks that receive all events, or hook.fail_open, get it too. Calls are grouped per repo and hour. A machine that never reaches Comity again never reports.
Fail-closed is enforced by the CLI on each developer's machine. It keeps agents from editing without coordination; it isn't a security boundary against a developer who changes their CLI, its config folder or its hooks.