Documentation

Last updated November 29, 2026

Quick start

Rhei is one native Rust install: the rhei CLI and the resident rheid daemon. It maps your repo, wires your coding agents over MCP, and keeps source, the graph, memory, and Dream findings on your machine. No account required.

Install

$curl -fsSL https://rhei.team/install.sh | sh

Prebuilt for macOS and Linux on arm64 and x86_64. The installer verifies SHA-256 checksums and installs rhei and rheid into ~/.local/bin; Homebrew ships the same pair. No Node, Bun, or package manager runtime is needed. Nothing about your code is sent during install.

First run

cd /path/to/your/repo
rhei setup
rhei now --global        # cross-repo work arcs & bridges (38 ms)
rhei doctor              # 7-point local health check

One command does everything. rhei setup auto-detects all 8 harnesses (Claude Code, Codex, OpenCode, Antigravity, Cursor, Windsurf, Pi, OMP), starts indexing in the background while asking “How should Rhei learn?” — choose Local intelligence, multi-subscription CLI rotation, an OpenAI-compatible endpoint, or Awake only — and reveals your Rhei Insight Code Map and Codebase Pulse immediately. Pass --non-interactive for agents or CI, and run rhei daemon install on macOS to auto-start rheid at login.

Connect your agent

rhei setup detects which agents are installed and edits only their configs, idempotently. Name one agent (rhei setup codex) or all to force it. The hooks are passive observers: they never block a tool call, and they let Rhei see what the agent touched so memory and proof stay attached to real work.

AgentMCP configPassive hooks
Claude Code~/.claude.json~/.claude/settings.json
Codex~/.codex/config.toml~/.codex/hooks.json · PreToolUse / PostToolUse
OpenCode~/.config/opencode/opencode.jsonopencode/plugins/rhei-hook.mjs
Antigravity~/.gemini/antigravity/mcp_config.json~/.gemini/settings.json · BeforeTool / AfterTool
Cursor~/.cursor/mcp.json (or ./.cursor with --project).cursor/hooks.json
Windsurf~/.codeium/windsurf/mcp_config.jsonMCP only
Pi~/.pi/agent/mcp.json~/.pi/agent/extensions/rhei-hook.mjs
OMP~/.omp/agent/mcp.json~/.omp/agent/extensions/rhei-hook.mjs

For any other MCP client, register the CLI as a stdio server:

{ "command": "rhei", "args": ["mcp"] }

After changing MCP config, restart or reconnect the client. rhei setup --uninstall removes every entry Rhei added.

Your first task

Once your agent is connected, give it a goal. An agent should inherit the work, not the transcript. This is the loop it runs:

1

Orient

The agent states the goal. Rhei returns pointers, not bodies: the files and symbols that matter, memories and cautions anchored to them, and any sibling worktrees touching the same code.

rhei_orient
  goal: "add rate limiting to the upload route"

→ 5 seeds · 2 memories · 1 caution · under 600 tokens

2

Expand what matters

Follow only the seeds worth reading. Expand returns the exact connected neighborhood, so the agent reads slices instead of whole directories.

rhei_expand
  seeds: ["src/upload/route.ts#handleUpload"]  depth: 2

→ callers · callees · guards · tests

3

Check the blast radius

Before the edit, see who depends on the target, which tests cover it, and where coverage is blind.

rhei_impact
  targets: ["src/upload/route.ts#handleUpload"]

→ dependents · covering tests · blind spots

4

Edit, then prove

The agent edits with its own tools while the passive hooks observe. Afterward, the Truth Gate and the proof view show what changed, what was checked, and what is still missing.

rhei_review  view: "gate_check"
rhei_review  view: "proof"

→ gate clear · files, evidence, QA

5

Leave something behind

A decision or caution worth keeping lands as a candidate anchored to the code. Review decides whether it becomes truth.

rhei_record  action: "memory_add"  kind: "decision"
  body: "upload limits live at the edge, not in the handler"

→ candidate · unapproved until reviewed

MCP tools

Agents see eight compact tools. Each call is a thin, crash-isolated adapter over the CLI; a running rheid serves orient, expand, impact, and memory recall warm from RAM.

Orient & navigate
rhei_orient

Stage 1. Seed pointers, memories, cautions, and sibling worktrees for a goal, never file bodies. Call before editing. Sub-agents pass onboard=true for the Stage-0 packet and a proactive lease.

goal · top_k · max_tokens · ws · onboard

rhei_expand

Stage 2. The exact connected neighborhood of seeds given as URIs, path#symbol, or names.

seeds · depth · kinds

rhei_graph

Code graph queries: callers, callees, symbols (file outline or name search), map (hierarchy), and services.

op · target · path · ws

rhei_search

Search code, symbols, docs, and memories in one repo or a multi-repo workspace.

query · mode · regex · path · ws

Impact & review
rhei_impact

Reverse blast radius of targets or the working-tree diff: dependents, covering tests, and blind spots.

targets · git_diff · depth · ws

rhei_review

Cockpit state: status, work, tree, dream_brief, delta, chapter, proof, gate_check, finish, health, handoff, now (cross-repo work arcs, active worktrees, and friction), and connected (2-hop work graph & shared contract bridges). The health view runs flows, duplicates, test-intel, dormant, dead-code, decay, drift, and risk sweeps; dream_brief carries what the last Dream mode cycle found.

view · sweep · depth · chapter_id · global · target

Memory
rhei_memory_recall

Recall code-anchored memories by text or by anchor (path or path#symbol). Cautions always surface.

query · target · kind · ws

rhei_record

Record knowledge: memory_add (always lands as an unapproved candidate), review_comment on a chapter, or insight_verdict on a Dream or health candidate.

action · kind · body · anchors

Rhei does not edit files for the agent. Agents edit with their own tools; Rhei supplies context before the edit and governs what becomes truth after it.

CLI

Every tool has a CLI equivalent, plus the commands humans use to set up, inspect, and govern. Add --json for machine-readable output or --ws <workspace> to work across repositories.

rhei setup [agent|all]Unified 1-command onboarding: detects all 8 harnesses (Claude Code, Codex, OpenCode, Antigravity, Cursor, Windsurf, Pi, OMP), registers rhei mcp and passive hooks, indexes the repo in the background while asking "How should Rhei learn?" (Local intelligence, multi-subscription CLI rotation, OpenAI-compatible endpoints, or Awake only), and reveals the Rhei Insight Code Map + Codebase Pulse. Idempotent; --non-interactive for agents/CI, --uninstall reverses it.
rhei now [--global|--connected|--narrate]Situational report in ~38 ms: cross-repo work arcs, active worktrees, friction hotspots, and shared contract bridges.
rhei provider status|set|checkConfigure how Rhei learns in ~/.rhei/config.toml: Local intelligence, multi-subscription CLI rotation, OpenAI-compatible endpoints, or Awake only. Zero raw API keys stored; automatic silent failover.
rhei doctor [--verify-sha|--strict]7-point local health check: binary/daemon match, harness sync, private 0700/0600 permissions, hub.db v3 integrity, model integrity, providers, and drifted cautions.
rhei update [--check|--sync-harnesses]Atomic self-update with SHA-256 verification and cross-harness MCP, hook, and SKILL.md re-sync, plus automatic 1-shot update whispers inside agents.
rhei initIndex the repository standalone: tree-sitter graph, tests, services, and docs. Warm re-runs reconcile only what changed.
rhei statusOne-screen cockpit: freshness, graph and memory counts, semantic tier, and drifted cautions.
rhei orient <goal>Stage 1 pointers, bounded slices, memories, and cautions for a goal.
rhei impact <targets>Reverse blast radius, covering tests, and blind spots. --git-diff uses the working tree.
rhei gate checkTruth Gate: invariants, layer reachability, guard bypass, and LOC budgets. Also approve, reject, steer, log.
rhei health <sweep>Report-only sweeps: flows, duplicates, test-intel, dormant, dead-code, decay, drift, risk.
rhei dream <cmd>Run a Dream mode consolidation cycle on demand, or read brief, status, history; accept or dismiss candidates.
rhei ingest embeddingsEmbed indexed files and symbols with a local server (MLX or Ollama). Also ingests SCIP, LCOV, and runtime traces.
rhei export trajectoriesExport verified coding trajectories as JSONL with --format sft|dpo|grpo. Purity gates enforced.
rhei daemon <cmd>Manage the resident rheid: install (LaunchAgent), start, stop, status, logs.
rhei sync --pull | --pushZero-server team canon through .rhei/canon.jsonl.
rhei eval <suite>Reproduce the benchmarks locally: orient, memory, impact, agent, swarm.
rhei mcpServe the eight tools over stdio. rhei setup configures this for you.

01 AWAKE & 02 DREAM

While you work (01 AWAKE), passive hooks track live edits and cautions. When no agent holds a lease for fifteen seconds, 02 DREAM (Dream mode) starts a two-phase, non-blocking consolidation cycle inside rheid off the writer path — or stays off if you chose Awake only. Foreground calls never wait on it. It works through three layers:

L1Structural & health sleep

  • Execution flow spines (entry → handler → guard → db)
  • Cross-language dead code and near-duplicate reuse hints
  • Anti-bloat test cover: the smallest test set that covers every path
  • Stalled docs (decay) and dormant code (dormant)

L2Memory consolidation & playbooks

  • Co-change coupling learned from history
  • House style per module and verified intent → done playbooks
  • Cautions promoted from real failures, with drift detection
  • Invariants enforced by the Truth Gate in under 50 µs

L3Rhei Lapis · co-designed local intelligence

  • Albedo (1.7B, ~840 MB) — pure System-1 reflex for instant FileCards, single-pass decisions & MorningDeck briefs
  • Citrinitas (4B, ~1.9 GB) — hybrid architect & adversarial verifier (The Shadow) with tight 150–300t <think> on demand
  • Rubedo (30B MoE, ~15 GB) — deep System-2 local synthesis & multi-file coding inside the MCP tool loop
  • Per-repo semantic adapter (Qwen3-0.6B + W_repo) and verified, secret-scrubbed SFT / SimPO / RLVR datasets

Results land in the dream_brief, which the next rhei_orient surfaces. Switch learning backends any time with rhei provider set (Local intelligence, multi-subscription CLI rotation, OpenAI-compatible endpoints, or Awake only) with automatic silent failover. Every finding is a candidate: accept or dismiss it with rhei dream accept|dismiss, or let an agent record an advisory insight_verdict. Nothing Dream mode finds becomes truth on its own.

rhei dream run         # one cycle now (default budget 120 s)
rhei dream brief       # what the last Dream mode cycle found
rhei provider status   # inspect active Local intelligence / provider chain
rhei health flows      # any layer-1 sweep on demand
rheid --idle-dream-secs 30   # change the quiet threshold

Trajectory Foundry

On Enterprise, rhei export trajectories --format sft|dpo|grpo turns approved engineering work into training data for your own private models. Only sealed chapters with complete proof and authoritative approval qualify, within a 600-token budget, after zero-leak probes. Rhei never trains on your code; the datasets stay with you.

Memory

Agents usually forget everything when a session ends. Rhei carries the useful parts forward as code-anchored memory: cautions, decisions, ideas, and invariants.

Anchored to code

Memories attach to a path or path#symbol, so they come back when that code is in play and fade when it changes underneath them.

Cautions always surface

A note about something that went wrong warns future work about that one thing only. It never hides unrelated files or overrides good decisions.

Superseded, not resurrected

When a decision is replaced, the old one stays in history and stops resurfacing. The benchmark checks this directly.

Useful is never confused with true

Everything an agent records lands as a candidate. Shared team canon, and anything that changes your code, still goes through review and the same gates.

In local mode, memory stays private on your machine. Teams share an agreed canon through rhei sync; on Pro, memory follows you across machines and repos, according to your data settings.

Truth Gate

Agents execute. Rhei governs what becomes truth. rhei gate check enforces the invariants in .rhei/invariants.toml: layer reachability, guard bypass, forbidden paths, and production LOC budgets, transitively across the graph. Violations come back with the path that caused them.

rhei gate check     # clear, or the exact violations
rhei gate log       # who approved, rejected, or steered what

The same gate runs on pull requests through the Rhei GitHub Action, so a change that crosses a boundary is caught before review, not after merge.

Benchmarks

Live receipts on an Apple M5 Pro, from held-out splits and isolated head-to-heads against other code-graph tools. Every number is reproducible with rhei eval and the bench scripts in the Rhei repository.

MetricResultReceipt
Agent tokens96.8% fewer100% file hit on held-out, unhinted agent tasks · OpenClaw (7,624 vs 236,648 tokens)
Cold index, 67k files~10 sOpenClaw, 67,144 files · 495 MiB peak · other graph tools timed out
Cold trail ingest, 3.97 GB7.15 s555 MB/s DOD Global Trail Hub ingest across local agent sessions
Warm trail ingest & rhei now38 ms38 ms warm trail ingest · 38 ms rhei now --global across repos
Cold index, medium repos150 ms418 files (150.6 ms) · 2,466 files (158.5 ms)
Impact F10.978Suite B2 callers on held-out symbols · rhei and fastapi
Memory MRR1.00010,000 distractors, 500-commit flood, 50 epochs (0.035 → 1.000)
Under concurrent load<12 ms p998 readers / 2 writers, 880 RPCs · hook p99 under 325 µs · 0 busy
Resident daemon9.3 MiBrheid RSS while serving warm tools

Held-out means the cases were not used to tune Rhei. Where Rhei is weaker, the receipts say so; natural-language localization on very large monorepos is still improving.

Data & updates

Local mode keeps source, the graph index, reports, memory, and Dream mode findings on your machine — free today with no account required. When optional cloud tiers launch, they will only send what your configured source-upload mode allows: never, metadata_only, or selected_slices. Rhei never trains on your code.

Full contracts: Data Use overview, Security, and Privacy Policy.

Updating & health checks

rhei update --check            # zero-telemetry release check
rhei update                    # atomic SHA-256 update + harness re-sync
rhei update --sync-harnesses   # re-sync MCP, hooks, and SKILL.md across all 8 harnesses
rhei doctor --verify-sha       # verify binaries, permissions, hub.db v3, models, and providers

rhei update replaces both binaries atomically after SHA-256 verification and keeps every connected harness in sync — agents also receive a quiet 1-shot update whisper when a newer release ships. You can also update via curl -fsSL https://rhei.team/install.sh | sh or brew upgrade rhei. Updates never touch your source.

Contact

Stuck or missing something? Email team@rhei.team.