# Set up Hive Mind

Hive Mind is shared memory for coding agents. Connect it to the coding tool you're running in, install the usage guidance below, and verify the connection. Follow these steps in order and tell me what you did at the end.

**Server:** `https://hive-mind.fly.dev`. If I've given you a different Hive Mind URL, use that instead. The MCP endpoint is `<server>/mcp/sse` (SSE transport).

**Scope:** set it up **globally** (every project on this machine) unless I've said "just this project". If I did, use the project-level paths noted in each step.

## 1. Connect the MCP server

Configure the tool you're running in. Name the server `hivemind`. Hive Mind supports MCP OAuth, so I sign in through the browser and no token gets written to disk.

- **Claude Code:** run `claude mcp add --transport sse --scope user hivemind https://hive-mind.fly.dev/mcp/sse`. Use `--scope project` for just this project. Then tell me to run `/mcp` and choose **Authenticate** for `hivemind`.
- **Cursor:** add the entry below to `~/.cursor/mcp.json` (or `.cursor/mcp.json` in this project), merging into any existing `mcpServers`. Then tell me to enable it under Settings → MCP and sign in.
  ```json
  { "mcpServers": { "hivemind": { "url": "https://hive-mind.fly.dev/mcp/sse" } } }
  ```
- **Codex, or any stdio-only client:** bridge through `mcp-remote`. For Codex, append this to `~/.codex/config.toml` if there's no `[mcp_servers.hivemind]` section yet (Codex config is always global). It needs Node/npx on PATH, and the first connection opens the browser to sign in.
  ```toml
  [mcp_servers.hivemind]
  command = "npx"
  args = ["-y", "mcp-remote", "https://hive-mind.fly.dev/mcp/sse"]
  ```

**Fallback: an agent token.** If OAuth doesn't work in this client, ask me for an agent token. I issue one from the Hive Mind portal (`<server>/ui`), with the `push` and `read` scopes. Add it to the same server entry: `"headers": {"Authorization": "Bearer <token>"}` in JSON, or `"--header", "Authorization: Bearer <token>"` in the `mcp-remote` args. If you write it into a file inside a repo, make sure that file is in `.gitignore`. Never commit a token, and never echo it back in chat.

## 2. Install the usage guidance

Install the guidance block below so future sessions know when to use Hive Mind.

| Tool | Global | Just this project |
| --- | --- | --- |
| Claude Code | `~/.claude/skills/hivemind/SKILL.md` | `.claude/skills/hivemind/SKILL.md` |
| Cursor | No global rules file. Give me the block to paste into Settings → Rules → User Rules. | `.cursor/rules/hivemind.mdc` |
| Codex | `~/.codex/AGENTS.md`, appended | `AGENTS.md`, appended |
| Anything else | That tool's global instructions file, if it has one | `AGENTS.md`, appended |

- **Claude Code skill** frontmatter: `name: hivemind` and `description: Use constantly — fetch before most tasks, query when status would change your plan, push after any unit of work, contribute any gotcha or decision.`
- **Cursor `.mdc`** frontmatter: `description: Shared Hive Mind team-memory tools` and `alwaysApply: true`.
- **When appending to an AGENTS.md:** put the block under the heading `## Hive Mind (shared team memory)`, and skip it if that heading already exists.

````markdown
Hive Mind is connected: the team's shared memory for coding agents. Four
tools are available: `hivemind_fetch`, `hivemind_query`, `hivemind_push`,
`hivemind_contribute`. Call them liberally.

**Fetch near the start of almost every task.** Call `hivemind_fetch` before
editing a module you haven't touched this session, before choosing a library
or pattern, before architecture/infra decisions, before touching auth,
billing, security or compliance code, before fixing a bug that may have
happened before, and before explaining why something is built the way it is.

**Query when the answer would change what you do next.** Call
`hivemind_query` before starting a task (did someone already do it?), when
asked for status, before reviewing a PR, when debugging code someone touched
recently, and when planning or estimating.

**Push after every discrete unit of work**, not just at the end of a session:
a bug fix (even a one-liner), a feature, a refactor, a config or dependency
change, a test, a root cause found, a design decision, a revert, a migration.
Set `project` to the current repository's name, and make `content` specific
enough for a teammate to act on: what changed, which files, the outcome.

**Contribute anything that took more than a minute to figure out.** Use
`hivemind_contribute` (not push) for workarounds, "looks wrong but isn't"
explanations, non-default config choices, architecture tradeoffs, gotchas,
runbook steps, and undocumented conventions. Push is "what I did";
contribute is "what's true about this system." Duplicates merge
automatically.

Never push or contribute secrets, credentials, or customer data. Your access
is scoped to one namespace, and calls fail closed if the org's subscription
has lapsed.
````

## 3. Verify

1. Once I've signed in (or the token is in place) and the client has reloaded, call `hivemind_fetch` with a short query about the current project. An empty result is fine; an auth error is not.
2. Call `hivemind_push` with `project` set to the current repository's name and content "Connected Hive Mind on this machine."
3. Report back: global or project scope, which tools you configured, which files you created or changed, and whether both calls succeeded. If a call failed, show the error and stop. Don't retry with guessed credentials.
