gbrain README

The project's README from github.com/garrytan/gbrain. As one markdown file: README.md.

GBrain

Search gives you raw pages. GBrain gives you the answer. It's the brain layer your AI agent has been missing — the only one that does synthesis, graph traversal, and gap analysis in one box. Run a full autonomous agent on top of it, or just wire it into Claude Code or Codex as a supercharged retrieval layer in one command; either way your coding agent stops being amnesiac about everything that isn't code.

I'm Garry Tan, President and CEO of Y Combinator. I built GBrain to run my own AI agents. It's the production brain behind my OpenClaw and Hermes deployments: 155,795 pages, 24,589 people, 5,340 companies, 66 cron jobs running autonomously. My agent ingests meetings, emails, tweets, voice calls, and original ideas while I sleep. It enriches every person and company it encounters. It fixes its own citations and consolidates memory overnight. I wake up smarter than when I went to bed — and so will you.

It works as a company brain too. Each person on the team gets their own slice of the brain, scoped by login. When you query, you only see what you're allowed to see — never another person's notes, never another team's data. We fuzz-tested this across every way you can read the brain (search, list, lookup, multi-source reads) and got zero leaks. Drop GBrain in as your team's shared institutional memory — the company-brain shape on YC's Request for Startups. If you're building in that space, you might as well build on this. Tutorial: set up GBrain as your company brain →

Lots of personal-knowledge systems give you keyword matching and grep in a box. GBrain does that, and adds two things nobody else ships together:

The point of building a 150K-page brain is to use it as a strategic moat. To never lose context. To query what's in your own head without re-reading it. The brain layer is what makes the moat usable. The 24/7 dream cycle is what keeps it sharp. Both run on your hardware, your DB, your keys.

It's easier to ship a daemon that runs 24/7 to ingest, enrich, and consolidate than it is to keep an agent in chat working hard. GBrain is that daemon, generalized. Install in 30 minutes. Your agent does the work. As my personal agent gets smarter, so does yours.

~15 minutes to a working personal agent on the recommended Codex / Claude Code path (mostly a short interview); ~30 minutes for the always-on OpenClaw / Hermes setup. Database ready in 2 seconds either way (PGLite, no server).

LLMs: fetch llms.txt for the documentation map, or llms-full.txt for the same map with core docs inlined in one fetch. Agents: start with AGENTS.md (or CLAUDE.md if you're Claude Code).

What this looks like

Say you have a meeting with Alice tomorrow. You want to walk in remembering what she works on, when you last talked, and what's still open between you. Here's what you'd type, and what you'd get back.

You ask:

"What do I need to know before my meeting with Alice tomorrow?"

Most personal-knowledge tools give you back a list of pages. Something like:

1. people/alice — Alice runs engineering at Acme...
2. meetings/2026-03-15-alice-q1 — Q1 product review with Alice...
3. meetings/2026-01-08-acme-kickoff — Kickoff meeting with Acme team...
4. customers/acme — Acme is a series-B fintech we work with...
5. notes/2026-04-22 — Quick chat with Alice about pricing...

Five pages you now have to open and read yourself to actually prepare. The tool found the right material, but it didn't do the work.

GBrain gives you back the answer, with sources:

Alice runs engineering at Acme (a series-B fintech). You last spoke
on April 22 in a quick pricing chat. Three things are still open
from that conversation:

1. She owes you the security review for the new tier
   (deadline was May 1; no update since).
2. You committed to pricing for a 500-seat tier
   (you sent it April 25; no response yet).
3. She mentioned they're hiring a CISO; you said you'd intro
   someone from your network.

Heads up: nothing's been added to the brain about Alice or Acme
since April 22, six weeks ago. She may have replied through email
or Slack DM, channels the brain doesn't see. Worth asking her to
catch up before assuming any of this is still current.

Every claim has a source page behind it. The "heads up" at the end tells you what the brain doesn't know yet, so you can ask Alice about it directly instead of being surprised. The brain just did your meeting prep.

This is the difference between a search engine and a brain. Search finds the pages. The brain reads them for you and writes the answer.

Install

[!WARNING] GBrain is NOT distributed on npm. The npm package named gbrain is an unrelated package with no connection to this project. Do not run npm install -g gbrain or bun add -g gbrain — you'll get something else, and it can shadow the real binary on your PATH. Install and upgrade ONLY via the documented paths below (bun install -g github:garrytan/gbrain, or git clone + bun install && bun link). If you already ran the npm install by mistake: npm uninstall -g gbrain / bun remove -g gbrain, then reinstall from GitHub. gbrain doctor detects a shadowing npm install and prints the fix.

GBrain is designed to be installed and operated by an AI agent. New to GBrain? Start with Codex — it runs on the ChatGPT subscription you already have, takes ~15 minutes, and deploys nothing. Already living in Claude Code? Its path is identical. Want GBrain running the way it was designed to run — always on, enriching your brain around the clock? That's OpenClaw or Hermes, at real server + API cost. Each path below is complete on its own. (Wiring it up by hand instead? Jump to CLI standalone or the MCP table.)

Turn Codex into your persistent personal agent. (Just want the brain + skills without the full agent? codex plugin marketplace add garrytan/gbrain@codex-plugin then codex plugin add gbrain@gbrain — see docs/mcp/CODEX.md. The paste block below builds the whole agent.) Works in the ChatGPT desktop app (open Codex on a folder) and in the Codex CLI (codex in a terminal) — same install, same result. Open Codex in a new, empty folder (not an existing code project) — that folder becomes your agent's own private GitHub repo, which bootstrap creates and privacy-verifies for you. Then paste:

Read and follow every step of:
https://raw.githubusercontent.com/garrytan/gbrain/latest-stable/BOOTSTRAP_FOR_AGENTS.md
Goal: set yourself up as my persistent personal agent in this folder, with gbrain
as your memory. Interview me before writing any identity file — never invent
answers. Ask before anything destructive. You are not done until
`gbrain bootstrap verify` exits 0.

Codex will ask for command approvals during the install — approving them is the sandbox working as intended. What you get, in about 15 minutes: a short interview (6 required questions) → your agent's identity (SOUL.md, USER.md, MEMORY.md) rendered from your own answers, never invented → a local PGLite brain (2 seconds, no server, no Docker) → MCP wired so every session can search and write memory → a private GitHub repo, created and privacy-verified, as your agent's durable body. Works with zero API keys — keyword search plus memory your agent writes itself; one optional key upgrades capabilities (OpenAI: semantic search + automatic fact extraction; Voyage: semantic search; Anthropic: fact extraction). Codex reads brain context through its tools each turn (pull-based). The click moment: tell it one small thing to remember, restart Codex, then ask for it back — the answer comes from the brain, not from this chat's context (which the restart cleared). That cross-session round-trip is the whole product; "what's my name / my top jobs?" is answered from your identity files, which is nice but not the same trick.

Two things worth understanding once it's running: you own the brain — every memory is a markdown file in that private repo (read it, clone it to a second machine, delete it and the brain is gone) — and the first skill to run is cold-start: say "fill my brain" and your agent imports your Gmail, calendar, and contacts — via the native connector (gbrain google setup, tokens in gbrain's local credential vault, never held by the agent), via ClawVisor (a hosted OAuth gateway), or from offline archives like Google Takeout — one consented step at a time. An empty brain is a database; a filled one is a memory.

Prefer to make the repo yourself? Create a new empty private repo under your own GitHub account (no README/.gitignore/license), clone it, open the clone in Codex, and paste the same block — bootstrap detects your empty repo and adopts it instead of creating one. The repo must be empty and personal-account-owned; org-owned repos are refused (create one under your account, or let bootstrap make it).

For Claude Code — turn it into your persistent personal agent

Works in the desktop app and in the CLI (claude in a terminal) — identical harness, identical result. Open Claude Code in a new, empty folder (not an existing code project) — that folder becomes your agent's own private GitHub repo, created and privacy-verified for you. Then paste the same block:

Read and follow every step of:
https://raw.githubusercontent.com/garrytan/gbrain/latest-stable/BOOTSTRAP_FOR_AGENTS.md
Goal: set yourself up as my persistent personal agent in this folder, with gbrain
as your memory. Interview me before writing any identity file — never invent
answers. Ask before anything destructive. You are not done until
`gbrain bootstrap verify` exits 0.

Everything from the Codex path applies — interview, identity from your own answers, local brain, private repo, keyless mode — plus Claude Code gets per-turn context hooks (on by default, with an opt-out): your brain loads automatically into every prompt, and your work persists to your private repo on a per-turn cadence (debounced ~5 min locally, every turn in a cloud sandbox — this covers the /exit case the harness never fires a session-end hook on), with a notice on your next turn if a push ever fails. This works in a Claude Code cloud session too, not just on your laptop: verification falls back to pure git protocol when the sandbox blocks the GitHub API, and gbrain bootstrap cloud-setup-script prints the environment setup recipe. The click moment: tell it one small thing to remember, restart the session, then ask for it back — a fresh session has no chat context, so the answer can only come from the brain. That cross-session round-trip is the whole product ("what's my name?" is answered from your identity files — nice, but not the same trick). Same two follow-ups as the Codex path: you own the brain (markdown in your private repo), and cold-start is the first skill to run — "fill my brain" imports your email, calendar, and contacts (ClawVisor) or offline archives, one consented step at a time. Full contract, security posture, cloud sandboxes, and uninstall: docs/guides/bootstrap.md.

Prefer to make the repo yourself? Create a new empty private repo under your own GitHub account (no README/.gitignore/license), clone it, open the clone in Claude Code (CLI or the desktop app's open-a-repo flow), and paste the same block — bootstrap adopts your empty repo instead of creating one. The repo must be empty and personal-account-owned; org-owned repos are refused.

For OpenClaw or Hermes — GBrain as intended, always on

This is GBrain used the way it was designed to be used: a server-hosted agent with 24/7 crons, continuous ingestion, and the overnight dream cycle that enriches your brain while you sleep — your agent works whether your laptop is open or not. It's also the highest-cost path: a deployed server (8GB+ RAM) plus raw API token usage that scales with how hard your agent runs, well beyond a chat subscription. Start here if you want the full experience from day one; start with Codex above if you want to feel it first. If you don't have a platform running yet, both deploy in one click:

Then paste this into your agent:

Retrieve and follow the instructions at:
https://raw.githubusercontent.com/garrytan/gbrain/master/INSTALL_FOR_AGENTS.md

The agent installs GBrain, creates the brain, asks for your API keys, loads the 50+ bundled skills, configures the dream cycle, and verifies the install end-to-end. ~30 minutes. You answer questions, it does the work.

Never set up an AI agent platform before? The personal-brain tutorial walks the whole path end-to-end — picking OpenClaw vs Hermes, deploying it, pointing it at INSTALL_FOR_AGENTS.md, getting the API keys, and verifying the first query. Start there if any of the above is new.

Lighter ways in

Just want a memory for your coding agent — no identity, no repo. Spin up a local brain and connect it in two commands — zero server, zero token, zero tunnel. --surface verbs gives your agent the seven-verb memory protocol (recall, remember, entity, synthesize, forget, context_pack, delta — MEMORY_VERBS v1, frozen + additive-forever) instead of the full tool wall; drop the flag for every operation:

gbrain init --pglite                                    # 2-second local brain (no Docker)
claude mcp add gbrain -- gbrain serve --surface verbs   # or: codex mcp add gbrain -- gbrain serve --surface verbs

If claude is not found, install Claude Code first — or use the per-harness blocks in the protocol doc. Heads-up: memories agents save default to brain-wide visibility (every connected agent can recall them); pass visibility: "private" for local-only facts.

Already have a brain on a remote host (OpenClaw, Hermes, or any gbrain serve --http)? Point your laptop agents at it with one command each — --install wires it up and smoke-tests the token before handoff:

gbrain connect https://your-host/mcp --token gbrain_xxx --install               # Claude Code
gbrain connect https://your-host/mcp --token gbrain_xxx --agent codex --install # Codex

Onboarding a whole agent harness onto a shared brain? On the brain host, gbrain agent register <name> --harness claude-code mints a scoped OAuth client plus a 30-day token and prints the paste-ready wiring block — presets for daily-driver and write-isolated coding agents. The onboarding decision table says which path fits.

Brain-only install into another coding agent (Cursor, Claude Cowork, or anything that can fetch a URL and run shell commands) — paste the OpenClaw/Hermes block above (INSTALL_FOR_AGENTS.md); it installs the brain, skills, and dream cycle without the personal-agent identity layer. Tested with Codex, Claude Code, Claude Cowork, Cursor, and AlphaClaw.

→ Full walkthrough: give your coding agent a memory — the memory-only paths end to end, plus the brain-first protocol you paste into CLAUDE.md / AGENTS.md and the four habits that make it actually change how you work.

CLI standalone (no agent)

bun install -g github:garrytan/gbrain
gbrain init --pglite     # 2 seconds; no server, no Docker
gbrain doctor            # verify health
gbrain import ~/notes/   # index your markdown
gbrain query "what themes show up across my notes?"

Postgres-at-scale, Supabase, and thin-client setup paths live in docs/INSTALL.md.

Connect GBrain to your AI client (MCP)

GBrain exposes nearly all of its 100+ operations as MCP tools (stdio and HTTP; a handful of local-only ops stay CLI-side) — or exactly the seven memory verbs with --surface verbs. The specific snippet depends on which client you use:

Upgrading an existing brain: existing search chunks need rebuilding before remote chunk retrieval resumes. Semantic result caching is temporarily disabled; stored contradiction reports and code-inspection tools have local-only limits. Follow the upgrade recovery guide for rebuild commands, embedding costs, and the restrictions that remain after rebuilding. Say to your agent: "Upgrade gbrain and check whether my search index needs rebuilding."

gbrain (garrytan/gbrain)

Searching Database…

31K ·GitHub
这是什么东西?GBrain 是给 AI 编程助手用的记忆和知识层:它不返回原始的搜索结果,而是给出经过整理、引用清晰的答案,覆盖你的页面、联系人、公司和想法,还会自动构建一张知识图谱,并明确告诉你它目前还不知道什么。它是 Garry Tan(YC 的 CEO)为自己运行 OpenClaw 和 Hermes 助手而开发的。
它是一个我打开的应用,还是给我的编程助手用的东西?它是给你的编程助手用的一个层,不是你打开的应用:一个用 bun 安装的 CLI,通过 MCP 接入,运行在本地数据库上——或者作为常驻后台服务跑在你自己的服务器上。还有一种更轻量的两命令模式,可以给任何编程助手加上一套只有七个动词的记忆协议(recall、remember 等)。
我该怎么把它跑起来?先用 bun install -g github:garrytan/gbrain 安装,然后在一个新的空文件夹里打开 Codex 或 Claude Code,粘贴安装代码块。大约 15 分钟后,你会完成一次简短的问答,生成身份文件,2 秒内就绪一个本地大脑(无需服务器),完成 MCP 接线,并得到一个私有的 GitHub 仓库。常驻的 OpenClaw/Hermes 方案大约需要 30 分钟。
不配任何 API 密钥也能用吗?可以——无密钥模式提供关键词搜索,加上助手自己写下的记忆。可选的密钥能增强功能:OpenAI 提供语义搜索和自动事实提取,Voyage 提供语义搜索,Anthropic 提供事实提取。
安装时最大的坑是什么?npm 上那个叫 gbrain 的包和本项目无关,装了它可能会在 PATH 上遮蔽真正的命令。只走 GitHub 这条安装路径;如果你已经踩了坑,gbrain doctor 能检测出来并打印修复方法。
我的大脑数据是存在本地,还是存在别人的云上?存在你自己的硬件、你自己的数据库、你自己的密钥上:大脑就是一个本地数据库,每条记忆都是你自己私有 GitHub 仓库里的一个 markdown 文件,你可以随时克隆或删除。公司大脑模式会按登录名划定每个人的可见范围,所有读取路径都经过模糊测试,零泄露。
和普通搜索相比,知识图谱能多带来什么?每次写入页面都会提取实体引用并建立带类型的边——attended、worksat、investedin、founded、advises——而且完全不用调用 LLM,所以像'谁在 Acme AI 工作?'这类问题能得到纯向量搜索给不出的答案。在一个 240 页的测试语料上,它的 P@5 达到 49.1%,R@5 达到 97.9%,精确率比关闭图谱的版本高出约 31 个百分点。
让它全天候运行会发生什么?定时任务会在你睡觉时吸收会议、邮件、推文和语音通话,为助手遇到的每个人和每家公司补充信息,并在夜间整理记忆——作者的生产环境里存有 155,795 个页面、24,589 个人、5,340 家公司和 66 个自主运行的定时任务。
它能导入我现有的 Gmail、日历和通讯录吗?可以——冷启动的'fill my brain'技能会一步一个确认地把它们导入:可以通过原生连接器(gbrain google setup,令牌保存在本地凭据库中,助手本身不会持有),可以通过 ClawVisor(一个托管式 OAuth 网关),也可以从 Google Takeout 这类离线归档导入。
常驻方案运行起来要花多少钱?Codex 和 Claude Code 这两条路用的是你已有的 ChatGPT 或 Claude 订阅,不需要部署任何东西。OpenClaw/Hermes 才是花钱的路:需要一台 8GB 以上内存的服务器(Render 和 Railway 有一键部署),外加随助手运行强度增长的 API 令牌费用。
Creator
garrytan
Size
353.3 MB
Stars
31K
Age
6mo
Commits · 90 Days