Inspiration

We run several AI coding agents at once, and every session starts without any of our team's conventions. A reviewer tells one engineer's agent that exports must call assertSingleCustomer(). A week later another engineer's agent makes the same mistake in the same file, and someone types the same correction again.

CLAUDE.md and Cursor rules hold only what someone remembered to write down. Most of a team's rules live in review comments and "no, not like that" messages, and those are gone when the chat closes. Review bots like Greptile and CodeRabbit learn from PR comments, but they act after the code is written. We wanted every agent to know the rule before it writes.

What it does

Hivemind is persistent memory for every AI coding agent on a team. In our eval, it took headless Claude Code from 14 of 36 passing runs to 36 of 36.

  • Learns from corrections. When an engineer corrects their agent, Hivemind turns the correction into a lesson, records who said it and on which file, and marks it pending.
  • A lead approves. The lead who owns that team or repo approves or rejects each lesson. Agents can propose lessons but cannot approve them.
  • Every agent gets it. At the start of each session, a hook loads the approved lessons into the agent's context: locked rules first, then lessons ranked by confidence, capped at 6,000 characters.
  • Locked rules. Security can lock a rule. Locked rules always load and block any proposed lesson that contradicts them.
  • Checks while agents work. After each file edit, a hook gives the agent the locked rules for that file, hivemind watch checks the change on save, and the agent is warned if another engineer's agent edited the same file in the last 10 minutes.
  • Lives in the terminal. hivemind watch runs in a pane next to the agent, with four tabs: Here (violations in the current file, with the fix), Rules, Queue (a to approve, r to reject) and Feed. hivemind why prints who set a rule, their words, and what it has blocked.
  • Works with six agents. hivemind init connects a repo to Claude Code, Cursor, Gemini CLI, Codex, GitHub Copilot and Windsurf.

How we built it

  • Web app, API and MCP server: one Next.js (App Router, TypeScript) app with Tailwind, shadcn/ui and Motion, deployed on Render.
  • Database: Supabase Postgres holds scopes (org → team → repo → person), roles, lessons, events and live activity.
  • Hooks: Claude Code's SessionStart hook fetches the context pack, and its PostToolUse hook returns rule and collision warnings. Adapters map Cursor, Gemini CLI, Codex, Copilot and Windsurf hook events onto the same endpoints.
  • MCP tools: get_team_rules, search_memory and propose_memory. Proposals are always pending.
  • Extractor: Claude Haiku classifies each correction as a rule, a one-off or noise, merges it with existing lessons, and checks it against locked rules.
  • Ranking: each lesson has a Beta(α, β) score. Confirmations raise it, contrary corrections lower it, and the pack sorts by the Wilson lower bound, so a lesson five people confirmed ranks above one seen once.
  • Terminal app: hivemind watch is a zero-dependency Node program that polls the API every 2 seconds.
  • Eval harness: eval/run.mjs runs headless claude -p in fresh copies of a test repo, and eval/check.mjs grades the diffs with regex graders checked against 16 hand-written cases.

Session start and file edits make no model calls. Haiku runs only when someone corrects an agent.

Challenges we ran into

  • Lessons or just more text? A longer prompt alone might make a model more careful. We added a placebo condition (12 unrelated lessons of the same length) and 4 held-out tasks whose text appears in no lesson.
  • The eval leaked our own rules. Early runs passed too often because headless Claude Code reads CLAUDE.md, hooks and MCP config by default, and it was picking up this project's. Running each task in safe mode, in a fresh temp copy, fixed it.
  • Hook limits. SessionStart can't be an http hook, its output is capped at 10,000 characters, and http hook URLs don't expand environment variables. So SessionStart is a small Node script, and the pack stops at 6,000 characters.
  • Fixes versus rules. "Use assertSingleCustomer here" fixes one line; "every export calls assertSingleCustomer" is a rule. Most chat messages are neither, so the extractor drops one-offs and noise before anything reaches a lead.

Accomplishments that we're proud of

We measured it. We built a TypeScript export service with six team conventions that appear nowhere in the repo, wrote 12 tasks that each tempt the agent to break one, and ran headless Claude Code (Sonnet 5.5) 3 times per task in each condition:

  • No memory: 14 of 36 runs passed (39%)
  • Placebo: 15 of 36 (42%)
  • Hivemind: 36 of 36 (100%)

On the 4 held-out tasks, no-memory runs passed 3 of 12 and Hivemind 12 of 12. Across the 12 tasks, Hivemind did better on 8 and worse on none (sign test, p = 0.0078). Cost per passing run fell from $0.055 to $0.024.

Limits: 12 tasks we wrote, one repo, one model, and lessons written by hand in the extractor's format. The dashboard's 14-day history is generated test data.

What we learned

With the right lessons in context, the agent passed every run, so its failures came from missing information. Shared memory is also an attack surface (OWASP lists memory poisoning as ASI06), which is why agents can only propose and a person approves.

What's next

  • Import lessons from PR review comments.
  • Run the eval on the live ranked pack, with more tasks and models.
  • Down-weight old evidence, and mark contradicted lessons invalid.

Built With

  • anthropic
  • claude-code
  • claude-haiku
  • claude-sonnet
  • codemirror
  • codex
  • cursor
  • gemini-cli
  • github-copilot
  • mcp-handler
  • model-context-protocol
  • motion
  • next.js
  • node.js
  • pnpm
  • postgresql
  • react
  • render
  • shadcn/ui
  • supabase
  • tailwindcss
  • typescript
  • windsurf
  • zod
Share this project:

Updates

Submission history