# hivemind-graph

Adopt this skill: https://proskills.md/skills/other/activeloopai-hivemind-harnesses-claude-code-skills-hivemind-graph

Page: https://proskills.md/skills/other/activeloopai-hivemind-harnesses-claude-code-skills-hivemind-graph
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: harnesses/claude-code/skills/hivemind-graph/SKILL.md
size: 4906
sha: d17651ace0620161dd421515ce5d3a773924d563
upstream: https://github.com/activeloopai/hivemind/blob/main/harnesses/claude-code/skills/hivemind-graph/SKILL.md

````text
---
name: hivemind-graph
description: Query the local code graph (functions, classes, calls, imports) through the Deeplake mount at memory/graph/. Use when the user asks structural questions about the codebase — "what calls X?", "what does Y import?", "where is Z defined?", "what's the architecture / which subsystems exist?", "what's the impact of changing this?". The graph is an AST-derived map of the repo, queried as files (no build needed — it rebuilds automatically).
allowed-tools: Read Bash
---

# Hivemind Code Graph

A deterministic, AST-derived map of the current repository — every function,
class, method, interface, type, enum, const, and module, plus the edges between
them (`calls`, `imports`, `extends`, `implements`, `method_of`). It is queried as
synthesized files under the Deeplake mount; there are no real files on disk and
no network call in the read path.

The graph **builds and refreshes automatically** (on Stop / SessionEnd, gated by
a rate limit + git diff). You never run a build command — just read it.

Use it as a fast **INDEX** to locate the few files/symbols that matter, then open
them with `Read` to answer. It is not a substitute for the source.

## When to use this skill

Activate when the user asks a *structural / relational* question about the code:

- "What calls `pushSnapshot`?" / "Who uses this function?"
- "What does `deeplake-pull.ts` import?" / "What depends on X?"
- "Where is `GraphSnapshot` defined?" / "Find the function that handles Y."
- "What are the main subsystems / the architecture here?"
- "If I change this signature, what's affected?" → use `impact/<symbol>` (transitive blast radius)

## When NOT to use this skill

- Reading the **body** of a symbol you already located → use `Read` on the real
  source file. The graph gives location + relationships, not full source.
- Code that isn't **committed/built** yet — the graph can lag uncommitted edits.
  If a file's mtime is newer than the build timestamp, read the live source.
- Languages outside **TypeScript, JavaScript, and Python** (Go, Rust, …) — the
  extractor covers those three, with cross-file `calls`/`imports` resolved for
  named imports. For anything else, fall back to grep/read.

## Path cheat sheet

```bash
cat ~/.deeplake/memory/graph/index.md
#   Overview: node/edge counts, kind breakdown, top files by node count.

cat ~/.deeplake/memory/graph/query/<pattern>   # START HERE (the 2-in-1)
#   Search + expand the top matches with their 1-hop neighbors (callers,
#   callees, imports, heritage). Multi-token AND: query/<a>+<b>.

cat ~/.deeplake/memory/graph/find/<pattern>
#   Case-insensitive substring search on node id + label (max 50 hits).
#   Prints numbered handles [1] [2] ... saved for this worktree.

cat ~/.deeplake/memory/graph/show/<handle-or-pattern>
#   <handle>: a digit from a prior find/ (e.g. 3).
#   <pattern>: a substring → unique node detail, or a candidate list.
#   Output: the node + its 1-hop neighbors grouped by edge relation.

cat ~/.deeplake/memory/graph/neighborhood/<file>
#   Every symbol in a file + its cross-file neighbors (callers/callees/imports).

cat ~/.deeplake/memory/graph/impact/<pattern>
#   Transitive dependents — the blast radius of changing a symbol.

cat ~/.deeplake/memory/graph/path/<from>/<to>
#   Shortest dependency path between two symbol patterns (trace a flow across files).

cat ~/.deeplake/memory/graph/layers      # architectural layers / subsystems
cat ~/.deeplake/memory/graph/tour        # deterministic guided walkthrough
```

## Workflow

1. Broad? Start at `index.md` to see subsystems and the biggest files.
2. Looking for a symbol? `find/<name>` (or `query/<name>`) → pick the handle.
3. Want relationships? `show/<handle>` / `neighborhood/<file>` → callers/callees, imports.
4. Tracing a flow? `path/<from>/<to>`. Change impact? `impact/<symbol>`.
5. Need the actual code? Take the `source_file:line` and `Read` it — don't answer from the graph alone.

## Anti-patterns (read these)

- **"Incoming (0)" does NOT mean dead code.** Cross-file `calls` are resolved for
  *named imports* (TS/JS/Python), but **instance-method dispatch** (`obj.method()`),
  dynamic calls, and nested/inner functions are NOT — a zero-incoming symbol may
  still be reached via one of those. Confirm in the source before calling it unused.
- **The graph can be stale.** It rebuilds at most once per rate-limit window. The
  SessionStart inject prints the build age; if it's old or you've just edited a
  file, prefer the live source for that file.
- **Don't try to build it.** There is no user-facing build step in normal use;
  the hooks handle it. Just read the mount.
- **`find/` is lexical, not semantic.** It matches substrings, not meaning —
  `find/auth` won't surface `login`/`credentials` unless those strings appear in
  the id/label. Try multiple keywords if the first misses.
````

## File: README.md
upstream: https://github.com/activeloopai/hivemind/blob/main/README.md

````text
<h1 align="center">
  <br>
  <a href="https://github.com/activeloopai/hivemind">
    <img src="https://raw.githubusercontent.com/activeloopai/hivemind/main/docs/public/hivemind-logo.svg" alt="Hivemind" width="120">
  </a>
  <br>
  Hivemind
  <br>
</h1>

<h4 align="center">One brain for all your agents</h4>

<p align="center">
  <a href="https://www.npmjs.com/package/@deeplake/hivemind"><img src="https://img.shields.io/npm/v/@deeplake/hivemind?color=blue&label=npm&style=for-the-badge" alt="npm"></a>
  <a href="https://github.com/activeloopai/hivemind/stargazers"><img src="https://img.shields.io/github/stars/activeloopai/hivemind?style=for-the-badge&logo=github" alt="GitHub stars"></a>
  <a href="LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=for-the-badge" alt="License"></a>
  <a href="package.json"><img src="https://img.shields.io/badge/node-%3E%3D22.0.0-brightgreen.svg?style=for-the-badge" alt="Node"></a>
  <a href="https://deeplake.ai"><img src="https://img.shields.io/badge/Powered%20by-Deeplake-orange.svg?style=for-the-badge" alt="Deeplake"></a>
  <a href="https://www.ycombinator.com"><img src="https://img.shields.io/badge/Y%20Combinator-backed-ff6600.svg?style=for-the-badge" alt="Y Combinator backed"></a>
  <a href="https://join.slack.com/t/hubdb/shared_invite/zt-35zr0yil0-lnzJcQhACsBlB7~3lufrCg"><img src="https://img.shields.io/badge/Slack-chat-4A154B?logo=slack&logoColor=white&style=for-the-badge" alt="Join us on Slack"></a>
</p>

<p align="center">
  Auto-learning, cloud-backed shared brain for <b>Claude Code • OpenClaw • Codex • Cursor • Hermes • pi • Claude Cowork (Alpha)</b> agents.<br>
</p>

<p align="center">
  <a href="https://trendshift.io/repositories/28172" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/repositories/28172" alt="activeloopai/hivemind | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
</p>

> One engineer's agent figures out a tricky migration on Monday.
>
> Tuesday, every agent on the team can execute the pattern.

On [LoCoMo](https://arxiv.org/abs/2402.17753), the public long-context memory benchmark, Hivemind is **25% cheaper, 1.7× fewer tokens, and 31% fewer turns** than running without shared memory. ([See the numbers below.](#benchmarks))

<p align="center">
  <img src="https://raw.githubusercontent.com/activeloopai/hivemind/main/docs/public/hivemind_cursor_readme_banner_dark.png" alt="Cut Cursor spend by 34% with Hivemind" width="100%">
</p>

**Beyond memory.** Hivemind doesn't just remember. It mines your team's traces for repeated patterns and codifies them into reusable skills that propagate back into every agent on the team. The agent your junior engineer used this morning is sharper because of what your senior engineer's agent figured out last week.

- 📥 **Captures** every session's prompts, tool calls, and responses as structured traces in Deeplake
- 🧠 **Codifies** patterns into reusable `SKILL.md` files, available to every agent on your team
- 🔍 **Searches** traces and skills with hybrid lexical + semantic retrieval (ILIKE lexical fallback when embeddings off)
- 🔗 **Propagates** capability across sessions, agents, teammates, and machines in real time
- 📁 **Intercepts** file operations on `~/.deeplake/memory/` through a virtual filesystem backed by SQL
- 📝 **Summarizes** sessions into AI-generated wiki pages via a background worker at session end
- ☁️ **BYOC**: keep data in your own GCS, Azure, S3, or on-prem bucket. [See Security & storage](#security--storage)

## Benchmarks

On the [LoCoMo](https://arxiv.org/abs/2402.17753) long-context memory benchmark (100 QA pairs, Claude Haiku via `claude -p`, hybrid lexical + semantic retrieval), Hivemind cuts cost, tokens, and turns versus a no-memory baseline:

| Metric            | Baseline | Hivemind | Improvement      |
|-------------------|----------|----------|------------------|
| Cost / 100 QA     | $8.94    | $6.65    | **25% cheaper**  |
| Tokens / question | 1,700    | 1,008    | **1.7× fewer**   |
| Turns / question  | 8.9      | 6.2      | **31% fewer**    |

The agent reaches the answer in fewer turns with less context, because the prior work is already in scope at recall time, not re-derived per session.

## Quick start

One command, all your agents.

**macOS / Linux**

```bash
curl -fsSL https://deeplake.ai/hivemind.sh | sh
```

**Windows** — in PowerShell:

```powershell
irm https://deeplake.ai/hivemind.ps1 | iex
```

**Any platform, via npm** — for CI and Dockerfiles, or where policy blocks
piping a downloaded script to a shell. Skips the checks the installers do, so
Node 22+ and a writable npm prefix are on you:

```bash
npm i -g @deeplake/hivemind && hivemind install
```

The installer detects every supported assistant on your machine (table below), wires up the hooks, and shows a one-line consent prompt before opening a browser for sign-in. Restart your assistants after install.

**Headless / CI installs:** pass an API token instead of using the browser flow:

```bash
HIVEMIND_TOKEN=<your-token> hivemind install
# or
hivemind install --token <your-token>
```

Get a token from your account settings on https://deeplake.ai. With no token in a non-interactive shell, the install completes with hooks but skips sign-in; run `hivemind login` later to enable shared memory.

**Install for a specific assistant only:**

```bash
hivemind install --only claude
hivemind claude install    # equivalent
hivemind codex install
hivemind claw install
hivemind cursor install
hivemind hermes install
hivemind pi install
hivemind claude_cowork install   # Alpha
```

**Check what's wired up:**

```bash
hivemind status
```

**Supported assistants:**

| Platform         | Integration                                      | Auto-capture | Auto-recall |
|------------------|--------------------------------------------------|--------------|-------------|
| **Claude Code**  | Marketplace plugin                               | ✅           | ✅          |
| **OpenClaw**     | Native extension                                 | ✅           | ✅          |
| **Codex**        | Hooks (`hooks.json`)                             | ✅           | ✅          |
| **Cursor**       | Hooks (`hooks.json` 1.7+)                        | ✅           | ✅          |
| **Hermes Agent** | Shell hooks (`config.yaml`) + skill + MCP server | ✅           | ✅          |
| **pi**           | Extension API (`pi.on(...)`) + skill + AGENTS.md | ✅           | ✅          |
| **Claude Cowork** 🅰️ | MCP server (Claude Desktop)                  | 🅰️ Alpha¹    | ✅          |

🅰️ **Claude Cowork is Alpha.** Auto-recall (the `hivemind_search` / `read` / `index` tools) is solid. ¹Auto-capture covers **Local Agent Mode** sessions only — those write a transcript we can tail; plain desktop-chat turns leave no readable local trace and aren't captured ([why](#claude-cowork-alpha)).

### Alternative install paths

<details>
  <summary><b>Claude Code plugin marketplace</b></summary>

If you prefer Claude Code's native plugin marketplace:

```
/plugin marketplace add activeloopai/hivemind
/plugin install hivemind
/reload-plugins
/hivemind:login
```

Auto-updates on each session start. Manual update: `/hivemind:update`.
</details>

<details>
  <summary><b>OpenClaw ClawHub</b></summary>

```
openclaw plugins install clawhub:hivemind
```

Then type `/hivemind_login` in chat, click the auth link, and sign in.

#### Commands

| Command | Description |
|---------|-------------|
| `/hivemind_login` | Sign in via device flow |
| `/hivemind_capture` | Toggle capture on/off |
| `/hivemind_whoami` | Show current org and workspace |
| `/hivemind_orgs` | List organizations |
| `/hivemind_switch_org <name>` | Switch organization |
| `/hivemind_workspaces` | List workspaces |
| `/hivemind_switch_workspace <id>` | Switch workspace |
| `/hivemind_update` | Check for plugin updates |

Auto-recall and auto-capture are enabled by default. Data i
````
