* feat(skillpack): extract copyArtifacts shared helper (T1)
Pure file-copy primitive for scaffold (gbrain→host) and harvest (host→gbrain).
Atomic-refusal contract: symlink-reject + canonical-path containment validate
every item before any write. Used by both directions of the v0.33 loop.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(skillpack): scaffold subcommand + SKILL.md frontmatter sources (T2)
New scaffold.ts replaces the managed-block installer. One-time additive copy
into the user's repo via copyArtifacts; refuses to overwrite existing files
(user owns them). Partial-state policy: copies missing paired sources even
when the skill dir already exists.
bundle.ts extended with loadSkillSources + enumerateScaffoldEntries — paired
source files declared in each SKILL.md's frontmatter sources: array, not in
openclaw.plugin.json. Single source of truth, co-located with the skill.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(skillpack): reference command + apply-clean-hunks (T4 + T15)
reference is the read-only diff lens with an agent-readable framing line. Pure-JS
unified-diff producer + parser + applier (no patch(1) dependency). Two-way merge
with documented limitation: without scaffold-time base tracking, applied hunks
align everything to gbrain. The agent dry-runs reference first, then decides.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(skillpack): migrate-fence + scrub-legacy-fence-rows (T5 + T16)
migrate-fence is the one-shot transition from the pre-v0.36 managed-block model.
Strips begin/end markers and the cumulative-slugs receipt comment; preserves
fence rows verbatim as user-owned routing during the transition to frontmatter
discovery. Receipt-then-row fallback (F-CDX-8) covers stale/missing receipts.
scrub-legacy-fence-rows is the opt-in cleanup after migrate-fence. Two-condition
gate: removes a row only when skills/<slug>/ exists AND that skill's frontmatter
declares non-empty triggers (proof frontmatter discovery covers it).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(skillpack): harvest + privacy linter (T6 + T7)
The inverse loop: lift a proven skill from a host repo (~/git/wintermute, etc.)
back into gbrain so other clients can scaffold it. --from <host-repo-root> is
symmetric with scaffold's --workspace.
Security: symlink rejection + canonical-path containment (mirrors validateUploadPath).
Privacy: default-on linter scans harvested files against ~/.gbrain/harvest-private-patterns.txt
plus built-in defaults (Wintermute, email, Slack channel patterns). Any match
rolls back the copy and exits non-zero. --no-lint bypasses for the editorial
workflow after a manual scrub.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(repo-root): cwd_walk_up tier for non-OpenClaw hosts (T9 + D3)
autoDetectSkillsDir now walks up from cwd looking for any skills/ directory,
ahead of the implicit ~/.openclaw/workspace fallback. cd ~/git/wintermute &&
gbrain skillpack scaffold ... finds wintermute automatically without requiring
a RESOLVER.md/AGENTS.md to exist yet.
R5 regression preserved: $OPENCLAW_WORKSPACE still wins when explicitly set.
+5 test cases in test/repo-root.test.ts pin the new tier order and the R5 guard.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(skillpack): rewrite CLI dispatch, drop install + uninstall (T3 + T10)
skillpack.ts dispatcher rewritten for the v0.36 contract: scaffold, reference
(+ --apply-clean-hunks), migrate-fence, scrub-legacy-fence-rows, harvest, plus
the existing list / diff / check.
install and uninstall are gone — both exit non-zero with a hint pointing at
scaffold / migrate-fence. Clean break, no deprecated alias.
skillpack-check gains --strict for CI gating. When invoked as the subcommand
`gbrain skillpack check`, default is informational (exit 0 even with drift);
--strict opts back into the cron-friendly exit-1-on-issues behavior. Top-level
gbrain skillpack-check preserves its existing exit semantics for backwards compat.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(skills): skillpack-harvest editorial workflow + resolver wiring (T8)
The companion editorial skill for the gbrain skillpack harvest CLI. Walks the
genericization checklist (scrub fork names, generalize triggers, lift fork-
specific conventions to references) before the CLI runs. Routing-eval fixtures
use paraphrased intents to avoid the intent_copies_trigger lint.
Wires the new slug into openclaw.plugin.json#skills, skills/manifest.json, and
skills/RESOLVER.md.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* test(skillpack): 9-case real-subprocess E2E flow (T11)
Spawns gbrain as a subprocess against tempdir workspaces. Covers: scaffold
first-run + re-run no-op, reference diff + --apply-clean-hunks, migrate-fence,
scrub-legacy-fence-rows, harvest privacy-lint catch + --no-lint bypass, and
the install removed-error path. No DATABASE_URL needed — skillpack is
filesystem-only.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* chore: docs + VERSION + CHANGELOG for v0.36.0.0 (T13 + T14)
Skillpacks as scaffolding, not amber.
v0.36 retires the managed-block install model. Six new subcommands replace
install + uninstall: scaffold, reference (with --apply-clean-hunks), migrate-fence,
scrub-legacy-fence-rows, harvest, plus the existing list / diff / check
(check gains --strict for CI gating). Routing comes from each skill's
frontmatter triggers — gbrain does not touch your RESOLVER.md or AGENTS.md.
Companion editorial skill skillpack-harvest drives the genericization
checklist; default-on privacy linter catches Wintermute / email / Slack
references before they leak into gbrain core.
New docs guide at docs/guides/skillpacks-as-scaffolding.md walks the model
and the migration path for pre-v0.36 installs.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(ci): privacy checks — allow-list harvest-lint tests, scrub user-facing fork-name references
CI's check-privacy.sh and check-test-real-names.sh both flagged the literal
fork name across the v0.36 skillpack diff. Two failure modes, two fixes:
1. **Meta-rule-enforcement files** added to both allow-lists. The harvest
privacy linter's whole job is to catch the banned literal leaking into
gbrain; its source has the regex pattern, its tests verify the linter
fires by feeding it the banned string, and the skill markdown documents
the substitution policy. Same exception status as check-privacy.sh and
check-proposal-pii.sh themselves. Files allow-listed:
- src/core/skillpack/harvest-lint.ts
- test/skillpack-harvest-lint.test.ts
- test/skillpack-harvest.test.ts
- test/e2e/skillpack-flow.test.ts
- skills/skillpack-harvest/SKILL.md
2. **User-facing references** swapped for canonical phrasing per CLAUDE.md's
responsible-disclosure rule. README + new docs guide + 4 src docstrings
+ 1 test now say 'your OpenClaw' / 'host agent repo' / 'agentRepo' var
name. Behavior unchanged — only documentation strings touched.
Verify gate (the script CI runs) passes locally: EXIT=0.
Tests still pass: 60/60 across the affected files.
llms-full.txt regenerated.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(test): update check-resolvable-cli expectation for cwd_walk_up tier
Sister fix to the test/repo-root.test.ts update in commit a31418e3. The new
v0.33 cwd_walk_up tier fires before repo_root when running from inside the
gbrain repo — same skills/ dir matched, different source label. Behavior
unchanged; the legacy repo_root tier is now functionally subsumed (kept in
the type union for back-compat).
CI shard 3 failure: test/check-resolvable-cli.test.ts:171.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(test): pin clock in sync_freshness boundary tests (CI flake)
The 24h and 72h exact-boundary tests scheduled last_sync_at relative to
Date.now() at construction time, then let the check call Date.now() again
internally. CI scheduler jitter between the two reads pushed ageMs past
the strict > thresholds by microseconds, dropping the 72h-boundary case
into the fail branch instead of warn.
Fix: add an optional `opts.now` test seam to checkSyncFreshness. The two
boundary tests now capture t0 once and pass it both to the timestamp
constructor and to the check, making ageMs deterministically equal to
the boundary. The non-boundary tests (4d, 30h, 2h, etc.) don't need
pinning — they're comfortably away from the > comparison.
CI shard 1 flake: test/doctor.test.ts:479. Locally 48/48 doctor tests pass.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(skillpack): agent-onboarding readme + next-action hints on every CLI surface (DX review)
DX audit of the v0.36 scaffold model surfaced one structural gap and four
output gaps. When scaffolded files land on a downstream agent's disk, the
agent had no agent-facing manifest telling it what to do — no routing
contract, no upgrade flow, no two-way merge warning at the right surface.
Fixes:
1. **New shared dep: skills/_AGENT_README.md.** Lands on every scaffold +
migrate-fence alongside the existing _brain-filing-rules.md and
_output-rules.md. Short, agent-readable contract: walk *.SKILL.md
frontmatter triggers: for routing, gbrain is reference not law on
upgrade, no managed-block fence anymore, two-way merge has known
limitations. Single source of truth for the agent operating contract.
2. **scaffold stdout** prints a next-action hint pointing at the readme
(with absolute path) and the reference --all upgrade-sweep command.
3. **reference stdout** adds per-category decision policy:
- missing → scaffold again
- differs → was edit intentional? keep it. Accidental? patch by hand or
apply-clean-hunks after reading the two-way warning.
4. **reference --apply-clean-hunks** prints the two-way merge WARNING
BEFORE the apply (to stderr, survives stdout redirect). Spells out
that gbrain has no scaffold-time base and local edits in differing
sections WILL be aligned to gbrain. Skipped in --json mode for
machine consumers. On conflicts, prints how to inspect and patch.
5. **migrate-fence stdout** tells the agent its routing model just
changed (fence gone, walk frontmatter now) and points at
scrub-legacy-fence-rows as the eventual cleanup. References the new
_AGENT_README for fresh-install agents.
Smoke verified end-to-end: 16 files land (was 15, +1 for _AGENT_README),
hint prints with absolute path, readme lands on disk. Tests + verify gate
pass clean.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(skillpack): upgrade-time reference sweep + reference --since version filter (DX deferred items)
Closes the last two DX gaps from the v0.36 audit:
1. **Post-upgrade reference sweep.** New `postUpgradeReferenceSweep`
helper called at the end of `gbrain post-upgrade`. After migrations
apply, auto-runs `reference --all` against the detected host
workspace and prints a one-line-per-skill summary of drift. Five
gates: GBRAIN_SKIP_REFERENCE_SWEEP env-var bypass, no detected
workspace (silent), workspace IS gbrain repo (dev-mode silent),
zero drift (silent), and pure-missing skills the host never
scaffolded are filtered out as noise. All errors swallowed —
never blocks post-upgrade. Helper accepts test-seam opts
(gbrainRoot, targetWorkspace) for unit testability.
2. **`reference --all --since <version>`.** Filters the sweep to
skills whose source actually changed in gbrain between
<version> and HEAD, using a new `changedSlugsSinceVersion`
helper in bundle.ts. Pure-JS git wrapper (spawnSync), no deps.
Accepts bare '0.X.Y.Z' or 'v0.X.Y.Z' or commit SHA. Falls back
loudly to full sweep when git can't resolve the ref (tarball
install, missing tag).
Test coverage added — total +32 new test cases:
UNIT (15 cases):
- test/skillpack-changed-since-version.test.ts (9 cases): git-aware
filter against a fixture git repo. Covers null on non-repo,
null on bad tag, empty array on no changes, single + multi-slug
drift (deduped + sorted), bare + v-prefix version forms, non-
skills/ path filtering, SHA-prefix ref form.
- test/upgrade-reference-sweep.test.ts (6 cases): gate logic.
Covers env-var bypass, zero drift, empty-host suppression,
drift-detected output shape, dev-mode workspace==gbrain guard,
error-swallowing contract.
E2E (8 new cases in test/e2e/skillpack-flow.test.ts):
- 10: scaffold lands skills/_AGENT_README.md
- 11: scaffold stdout prints the Next: hint
- 12: scaffold re-run (skipped-existing) suppresses the hint
- 13: reference stdout prints per-category decision policy
- 14: --apply-clean-hunks WARNING on stderr, not stdout
- 15: --apply-clean-hunks --json suppresses the WARNING (bug fix
surfaced here: code originally printed unconditionally, now
gated on !json)
- 16: migrate-fence stdout points at the new routing model
- 17: --since with a bad tag falls back to full sweep with warn
Local sweep: 579/579 pass across 18 affected test files, verify
gate EXIT=0, llms regenerated.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* docs(README): zero-base rewrite — 921 → 422 lines, refreshed catalog, MECE structure
The README had drifted into a changelog dumping ground. Four 'New in vX.Y'
paragraphs competed for the lead, 16 version tags scattered through
headings, the production-numbers hook (17,888 pages, 4,383 people) was
six months stale, and skills were described in three places (Skills section,
Commands section, inline marketing prose).
Zero-based rewrite:
**Refreshed catalog** (surveyed live brain + live agent fork, broad strokes
per CLAUDE.md privacy rules):
- ~100K total brain items (was 17,888 in the old README — 6x stale)
- ~16K people (was 4,383)
- ~5K companies (was 723)
- ~8K concepts, ~4K originals, ~3.5K daily notes
- ~31K media (30K tweets, 179 books, papers/films/games/interviews)
- 108 cron jobs running (was 21)
- 273 skills in the live agent fork (35 bundled + 238 user-built)
**Structure** — MECE, single source of truth per concept:
1. Hook + at-a-glance table (refreshed numbers)
2. Install (3 paths, terse)
3. What it does (5 capability areas — replaces 12 scattered sections)
4. Skills (categorized one-liners — 35 lines, was ~200)
5. How it works (one coherent flow — replaces 4 overlapping sections:
Architecture, Knowledge Model, Knowledge Graph, Search, Why It Works)
6. Commands (terse cheatsheet — every command, one line each)
7. Docs (link map — points to docs/ for the heavy stuff)
8. Origin / Contributing / License
**Cut entirely** (moved or deleted):
- 4 'New in vX.Y' leads (→ CHANGELOG.md is the changelog)
- 16 (vX.Y) version tags in section headings
- Minions stats subsection (subsumed into hook + 'durable background work')
- Voice section (was 12 lines of brand prose)
- Engine Architecture detail (→ docs/architecture/)
- File Storage section (→ docs/guides/storage-tiering.md)
- Per-skill marketing prose (one-liner per skill in the table)
The README is no longer the changelog. Future releases append to
CHANGELOG.md; the README only changes when a structural capability does.
llms-full.txt regenerated. Privacy check + verify gate pass.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* docs(README): fix line-start '+' rendering bug + lead with eval evidence
Two fixes in one:
1. **Markdown bug fix.** The OAuth 2.1 paragraph had `+ PKCE,` on a line
start (column 1), which GitHub-flavored markdown interprets as a list
marker — the line break before it broke the paragraph and rendered as
an orphan first line followed by a bullet. Rewrote the OAuth 2.1
capabilities as inline-comma-separated, escaped the `+` semantics.
Swept the whole file for the same bug class — no other instances.
2. **Maximum-sell mode for evals.** Surveyed every published benchmark
in both this repo and ~/git/gbrain-evals. Strongest evidence pulled
to the top:
- **97.60% R@5 on the public LongMemEval _s (500 questions).** No LLM
in the retrieval loop. $0.50 per 1000 queries. Beats MemPalace raw
by a point on the same dataset, beats every academic dense
retriever (Stella, Contriever, BM25). Mastra/Supermemory measure
a different metric (QA accuracy with LLM judge) — flagged honestly.
- **+31.4 points P@5 from the self-wiring knowledge graph** on
BrainBench v0.20.0 (240-page rich-prose corpus, 145 relational
gold queries). Separable, measured, load-bearing. Zero retrieval
regression across seven releases (v0.16 → v0.20).
New '## Benchmarks' section after Install:
- Public benchmark table with cross-system comparison
- In-house BrainBench scorecard with per-adapter Δ vs gbrain
- Source-swamp resistance result (93.3% top-1 vs 80% grep-only)
- Skill/prompt compression: 25KB → 13KB AGENTS.md, +13-17pp accuracy
across Opus 4.7 / Sonnet 4.6 / Haiku 4.5
- 'Run your own evals' subsection with copy-pasteable commands for
every eval surface (longmemeval, cross-modal, eval capture/replay,
BrainBench)
Tightened the lead's cost-comparison claim to what's defensible per
the underlying eval doc (MemPal LLM-rerank $0.001/q vs gbrain
$0.0005/q; dropped the overstated '6x' I'd written initially).
Privacy + verify gate + build-llms test all pass.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* docs(README): integrate the eval story into the lead, move jargon into 'Receipts on the evals'
Previous lead dumped metric acronyms (R@5, P@5, P@5 deltas, MemPalace,
Stella, Contriever, BM25) before the reader knew what gbrain does. A
'somewhat technical' reader hits the wall of jargon and bounces.
Rewritten:
**Lead (jargon-free, 3 paragraphs)** — describes the value in plain
English, with two anchor numbers:
- 'right answer in top 5 results 97.6% of the time' (not 'R@5 97.60%')
- 'roughly 4x more relevant than plain vector RAG' (not '+31.4 pts P@5')
- 'better than every comparable system that doesn't pay for a language-
model call on every retrieval' (the load-bearing honest framing,
without naming the competitors mid-hook)
- ends with '[Receipts on the evals →]' linking down
**'## Benchmarks' renamed '## Receipts on the evals'** with a glossary
at the top defining R@5, P@5, and 'no LLM in the loop' in one line each.
Then the full tables: LongMemEval cross-system (with the metric-mismatch
flag for Mastra/Supermemory), in-house BrainBench scorecard, source-swamp
resistance, and prompt compression. The competitor names + metrics stay
here where readers who want the receipts can find them, with the
glossary so the acronyms don't tax cold readers.
Net: lead reads as 'here's what it does and the proof' instead of 'here
are the benchmark numbers, figure out what they mean.' Comparison facts
unchanged.
Privacy + verify gate + build-llms test all pass.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* docs(README): name LongMemEval explicitly + first-person voice in lead
Two specific edits from user feedback:
1. 'the standard public benchmark for AI memory systems' → 'LongMemEval'
(linked to the HuggingFace dataset). The benchmark has a name; use it.
2. 'Built by the President and CEO of Y Combinator to run his own AI
agents' (passive third-person) → 'I'm the President and CEO of Y
Combinator, and I use this 16 hours a day' (active first-person).
Carried the voice change through the rest of the README — the
downstream 'Garry's personal agent' line and the Origin section's
'Garry Tan needed... he'd ever drafted... so he built one' all flip
to first person ('my personal agent', 'I needed', 'I'd ever drafted',
'so I built one'). The README is now consistently first-person from
the author's voice instead of a hagiographic third-person framing.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* docs(README): add Multi-player and company brains section
Three deployment patterns documented:
1. Single GBrain server + thin MCP clients (recommended). Tailscale
private networking, OAuth scope, source-scoped clients, exhaustive
what-clients-can/cannot-do lists.
2. Local PGLite + GStack for per-worktree code search.
3. Federated repos (advanced) — multiple servers indexing the same
brain repo.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* docs(README): tighten install path + add tech-orientation block + visceral query example
Self-eval as a cold reader surfaced four gaps blocking a 10/10 first read:
1. Lead never says WHAT it is technically — CLI? service? cloud? local?
Added a "What it is, technically" block right after the hook: open-source
MIT, Bun CLI + MCP server, local-first, data stays on disk, MCP-native.
2. Install path optimized for committed users not evaluators. The old
"recommended" path (deploy OpenClaw on Render, 8GB RAM) blocked anyone
trying gbrain for the first time. Reordered into 3 paths by commitment:
60-second standalone CLI first, MCP for Claude Code / Cursor second,
full agentic install third.
3. No example output showing what success looks like. Added a real sample
`gbrain query` invocation with the hybrid-search result format so a
reader can feel the experience before they install.
4. Privacy / data-locality unaddressed in lead. Now stated up front:
embedding calls only hit external APIs if you configure them.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
31 KiB
GBrain
Your AI agent is smart but forgetful. GBrain gives it a brain.
Ask your agent about a meeting from six weeks ago, a paper you skimmed in March, an idea you jotted down late one night. GBrain finds it. And it knows the connections — who attended that meeting, who that paper's author has invested in, what other ideas in your brain it overlaps with.
On LongMemEval, the public benchmark for AI memory systems, the right answer lands in gbrain's top 5 results 97.6% of the time. Better than every comparable system that doesn't pay for a language-model call on every retrieval, at $0.50 per thousand queries.
For relational questions ("who works at this company?", "what did this
founder invest in this quarter?"), gbrain's self-wiring knowledge graph
makes the answer roughly 4× more relevant than plain vector RAG. The
graph isn't hand-curated. Every page write extracts entity references and
creates typed edges (works_at, attended, invested_in, founded,
advises) with zero language-model calls.
I'm the President and CEO of Y Combinator, and I use this 16 hours a day. The production brain powering my OpenClaw and Hermes deployments has grown into the largest documented personal-AI knowledge graph in active use:
| ~100K | total items in the brain |
| ~16,000 | people pages, auto-enriched |
| ~5,000 | companies |
| ~8,000 | concepts |
| ~4,000 | original essays + ideas + drafts |
| ~3,500 | daily notes |
| ~31,000 | media items (tweets, books, papers, interviews, films, articles, calls) |
| ~2,200 | LLM-conversation transcripts (ChatGPT, Claude, Perplexity, agent forks) |
| 108 | cron jobs running autonomously |
| 273 | skills in the live agent fork (35 from gbrain bundle + 238 user-built on top) |
The agent ingests meetings, emails, tweets, voice calls, books, papers, and original ideas while you sleep. It enriches every person and company it encounters. It fixes its own citations, consolidates memory overnight, detects contradictions in your typed claims about people and companies, and flags trajectory regressions. You wake up and the brain is smarter than when you went to bed.
GBrain is those patterns, generalized. As my personal agent gets smarter, so does yours.
What it is, technically
- Open-source (MIT) TypeScript CLI + MCP server. One binary, no service to host. Mac and Linux. Requires Bun 1.3+.
- Local-first. Your brain lives in
~/.gbrainon your machine. Embedded Postgres (PGLite via WASM) so there's no database to install — ready in ~2 seconds. Or point at your own Postgres / Supabase for big brains. - Your data stays on disk. Embedding calls hit OpenAI / Voyage / Anthropic only if you configure those keys. Sync, search, and graph extraction all run locally with zero outbound traffic.
- Speaks MCP. Plugs into Claude Code, Cursor, Windsurf, ChatGPT desktop, and any agent that consumes the Model Context Protocol — stdio for local, HTTP + OAuth 2.1 for multi-user.
LLMs: fetch
llms.txtfor the doc map, orllms-full.txtfor the map with core docs inlined. Agents: start withAGENTS.md(orCLAUDE.mdfor Claude Code).
Install
Three paths, ordered by how much you're committing.
Path 1 — 60 seconds, just try it (standalone CLI)
git clone https://github.com/garrytan/gbrain.git
cd gbrain && bun install && bun link
gbrain init # brain ready in ~2 seconds (PGLite)
gbrain import ~/notes/ # index any directory of markdown
gbrain query "what themes show up across my notes?"
What you'll see — gbrain finds the relevant pages, ranks them by hybrid search, and prints the top hits with snippets:
$ gbrain query "what themes show up across my notes?"
Found 8 results in 124ms (hybrid: vector + keyword + RRF)
1. concepts/durable-systems.md (score 0.91)
"Software that survives its maintainers has three properties: ..."
2. essays/2025-thinking-out-loud.md (score 0.87)
"I keep coming back to the idea that the best companies ..."
3. meetings/2026-02-12-alice-call.md (score 0.83)
"Discussed how Alice's framework for ..."
...
Add gbrain extract all after import to build the knowledge graph
(entity links + timeline edges). gbrain dream runs the full 9-phase
maintenance cycle.
Path 2 — Plug it into Claude Code / Cursor (MCP)
# Local single-user via stdio MCP
claude mcp add gbrain "$(which gbrain) serve"
# Multi-user via HTTP MCP with OAuth 2.1 + admin dashboard
gbrain serve --http # prints admin bootstrap token
gbrain serve --http --bind 0.0.0.0 --public-url https://brain.example.com
Now ask Claude / Cursor "what did Alice and I discuss last quarter?"
and it queries your brain. The HTTP server supports OAuth 2.1
(client_credentials, authorization_code with PKCE, refresh rotation,
revocation, RFC 7591 DCR). Source-scoped clients (--source dept-x) tie
write authority to one source; --federated-read S1,S2,S3 adds orthogonal
read scopes. Loopback bind by default — pass --bind 0.0.0.0 to publish.
Path 3 — Full agentic install (~30 min)
If you want the nightly auto-enrichment, cron jobs, and overnight synthesis I described above, the brain needs an agent to drive it.
- OpenClaw — deploy AlphaClaw on Render (one click, 8GB+ RAM)
- Hermes Agent — deploy on Railway (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
It clones the repo, installs GBrain, sets up the brain, scaffolds 35 skills, configures recurring jobs, and asks you for the API keys it needs. Budget ~30 minutes for the conversation.
Receipts on the evals
The lead's numbers come from published, reproducible eval runs. Sibling repo gbrain-evals has the full reports, corpora, and cross-system tables. Glossary so the metric jargon below doesn't get in the way:
- R@5 — did the right answer land in gbrain's top 5? Higher is better.
- P@5 — what fraction of the top 5 are actually correct? Higher is better.
- No LLM in the loop — retrieval uses embeddings + keyword search + ranking, with no language model called per query. Cheaper, deterministic, reproducible.
LongMemEval — the standard public memory benchmark
500 questions across 6 question types, each against a haystack of ~50 conversation sessions. Built by Wu et al., the published yardstick for memory systems.
| System | R@5 | LLM in retrieval? | Notes |
|---|---|---|---|
| gbrain-hybrid | 97.60% | no | this run, 2026-05-07 |
| MemPalace hybrid+rerank (held-out) | 98.4% | yes | 0.8pt ahead because they pay for an LLM call per query |
| MemPalace raw | 96.6% | no | gbrain wins this head-to-head by 1pt |
| Hindsight | 91.4% | yes | per their release |
| Stella (academic) | ~85% | no | dense retriever |
| Contriever (academic) | ~78% | no | dense retriever |
| BM25 (sparse) | ~70% | no | keyword baseline |
Mastra (94.87%) and Supermemory (~99%) publish on this dataset but measure end-to-end QA accuracy with an LLM judge, which is a different thing than "did retrieval find the right session." Not directly comparable; flagged honestly in the cross-system table. Reports + reproduction: 2026-05-07 LongMemEval.
BrainBench — relational queries (in-house corpus)
LongMemEval is conversation-style. The other half of the proof is relational questions over a structured knowledge base. We built a 240-page rich-prose corpus (80 people, 80 companies, 50 meetings, 30 concepts) and wrote 145 relational gold queries — "who attended this meeting?", "what's this person invested in?" — against it. Reproducible, deterministic.
| Retrieval system | P@5 | Δ vs gbrain |
|---|---|---|
| gbrain (hybrid + knowledge graph) | 49.1% | — |
| Vector + keyword RRF (graph turned off) | 17.8% | −31.4 |
| Keyword search only (BM25) | 17.1% | −32.0 |
| Vector-only RAG | 10.8% | −38.4 |
The knowledge graph layer is worth 31 points P@5 on these queries. Separable, measured, load-bearing. Flat across seven releases (v0.16 → v0.20) — zero retrieval regression while ops + infra changed underneath. Full report.
Curated content vs bulk swamp
Personal brains accumulate bulk content (tweet dumps, daily chat transcripts, archived articles). When a query phrase appears in both a short curated essay AND a long chat dump, which wins? Source-aware ranking keeps the essay on top. 93.3% top-1 hit (vs 80% on grep-only). Report.
Prompt compression
Routing rule: the functional-area-resolver skill compresses a fat
AGENTS.md into a two-layer dispatch table. A real-world 25KB resolver
compressed to 13KB (48% the size) and gained 13–17 percentage points of
routing accuracy across Opus 4.7, Sonnet 4.6, and Haiku 4.5. The
(dispatcher for: ...) clause is load-bearing — strip it (same
compression, no dispatcher signal) and Sonnet's accuracy collapses to
41.7%. Cross-model receipts in this repo.
Run your own evals
# Public benchmark, in-process, ~30s warm
gbrain eval longmemeval ~/Downloads/longmemeval_s.jsonl
# Multi-model output quality gate (3 frontier models score the same output)
gbrain eval cross-modal --task "..." --output report.md
# Capture real query/search traffic as regression-eval data
GBRAIN_CONTRIBUTOR_MODE=1 gbrain eval export > snapshot.ndjson
gbrain eval replay --against snapshot.ndjson
# In-house BrainBench corpus + multi-adapter runner
cd ~/git/gbrain-evals && bun eval/runner/multi-adapter.ts
Full BrainBench corpus + per-category scorecards (Cats 1–13) in the sibling gbrain-evals repo.
What it does
1. Ingests everything, enriches automatically
Markdown sync from a git brain. Meeting transcripts (Whisper / Groq Whisper).
EPUB / PDF books (book-mirror produces personalized chapter-by-chapter
analysis). PDFs of academic papers with citation extraction. Articles via
Reader / Perplexity / archive.is. Tweets (timeline + bookmarks). Voice notes.
ChatGPT / Claude / Perplexity / agent-fork conversation exports. Email
threads. Calendar events. Foursquare exports. Slack channel archives.
Every page write extracts entity references → typed links (attended,
works_at, invested_in, founded, advises, mentions) with zero LLM
calls. The graph wires itself.
2. Hybrid search that beats vector-only RAG
Per-query: vector + keyword + RRF fusion + multi-query expansion (Haiku) +
source-aware ranking + reranking (ZeroEntropy, optional). Two-stage CTE so
the HNSW index stays usable when source-boost re-ranks the top-K. Hard
exclude prefixes (test/, archive/, etc.) at retrieval. Intent classifier
auto-selects detail level by query type (entity / temporal / event /
general). P@5 49.1%, R@5 97.9% on the BrainBench corpus.
3. Self-maintaining via the dream cycle
A 9-phase nightly cycle: lint → backlinks → sync → synthesize → extract → patterns → recompute_emotional_weight → embed → orphans (+ a purge phase
for the destructive-guard lifecycle). Each phase is independently runnable
via gbrain dream --phase <name>. Subagents fan out under a rate-leased
Anthropic client; protected job names gate trust; per-job + per-cycle
timeouts; auto-replay on stalled jobs. Conversation transcripts become brain
pages with content-hash dedup so re-runs are no-ops.
4. Multi-source brains + temporal trajectory
gbrain sources add <id> --local-path <path> mounts additional brains
alongside your host brain (team-published, CEO-class, departmental). Each
source has its own RLS-isolated DB rows. OAuth clients can write to one
source and read federated.
Author typed claims in the ## Facts fence: mrr=50000, arr=2000000,
team_size=12, valuation_usd=15000000. gbrain eval trajectory companies/<slug> prints the chronological history with regressions
auto-flagged. gbrain founder scorecard <entity> rolls up claim accuracy,
consistency, growth direction, and red flags into a stable JSON contract.
5. Durable background work
gbrain agent run <prompt> submits LLM-loop subagents. gbrain jobs submit shell --params '{"cmd":"..."}' (operator-only) submits shell jobs.
gbrain jobs supervisor start runs a self-restarting worker daemon with
crash-cause classification, OOM detection, RSS watchdog, and per-cause
metrics surfaced in gbrain doctor. gbrain autopilot --install registers
the dream cycle as a launchd / systemd job.
Children + aggregator parents, child_done inbox for fan-in, per-job
timeouts, idempotency keys, cascade-kill. Supervisor classifies exit codes
into runtime_error / oom_or_external_kill / graceful_shutdown / clean_exit
so 120 crashes/24h reads correctly instead of false-alarming on clean
worker drains.
Multi-player and company brains
Three ways to share a brain across multiple agents, machines, or teammates. Most setups want pattern 1 (single server, multiple MCP clients). The other two patterns exist for specific reasons.
Pattern 1 — One GBrain server, many MCP clients (recommended)
The GBrain server runs on the same machine or container as your primary agent (OpenClaw, Hermes, AlphaClaw). It publishes an MCP endpoint over HTTP with OAuth 2.1. Other agents — on other machines, in other apps, across teammates' laptops — connect as thin MCP clients.
# On the box that hosts your brain + primary agent:
gbrain serve --http --bind 0.0.0.0 --public-url https://brain.example.com
# Prints a one-time admin bootstrap token; paste it into the admin UI
# at /admin to register OAuth clients.
# On any other machine, set up a thin client:
gbrain init --mcp-only
# Walks you through pointing at the server URL + OAuth credentials.
# No local database, no scaffolded skills — just a routing shim.
Network: use Tailscale. Run the server on a Tailscale-private address so the brain is reachable from your other machines without exposing anything to the public internet. Public-internet exposure works fine (OAuth + loopback-bind-by-default + admin dashboard handle it), it's just a larger blast radius. For teams, Tailscale + OAuth is the cheap path to "my engineering team's agents all read from one shared brain."
What thin clients CAN do (subject to OAuth scope: read / write / admin):
search,query,think— full retrieval pipeline, including the knowledge graph + rerankingget_page,list_pages,put_page,delete_page,restore_page— page CRUD (put_page/delete_pagerequirewritescope)find_experts(whoknows),find_trajectory,find_orphans,find_anomalies,find_contradictions— the analytical surfacesget_recent_salience,get_brain_identity— observabilityapply-migrations,restore_page— admin scope, OAuth-gated- Anything else marked
localOnly: falseinsrc/core/operations.ts
What thin clients CANNOT do (server-side only, by design):
sync_brain— needs filesystem access to the git brain repofile_upload,file_list,file_url— server-side S3 / Supabase Storage credentials don't cross the trust boundaryget_recent_transcripts— raw.txttranscripts; privacy gate keeps these localpurge_deleted_pages— destructive, admin-only, local-onlycode_traversal_cache_clear— local maintenance
If a thin client tries one of these, the server returns a clear "local-only" error pointing at the local CLI.
Source-scoped clients (v0.34+). A teammate's OAuth client can be tied
to a single source with --source dept-x; its writes are isolated to
that source's RLS-protected rows. --federated-read S1,S2,S3 adds
orthogonal read scopes so the client can read across departments while
writing to one canon. Useful when a team has a shared brain AND
contributes back to a CEO-class brain.
Pattern 2 — Local PGLite for code search (GStack)
For an engineering agent that wants symbol-aware code search on the repo it's currently working in, run a local PGLite instance instead of hitting a central GBrain server. GStack supports this directly: one PGLite per worktree, indexed against that worktree's source tree.
# In the worktree you want to index:
gbrain init --pglite # ~2 seconds, no server, no creds
gbrain import . # indexes the worktree's code
echo "$(pwd)" > .gbrain-source # pins this PGLite to this worktree
/sync-gbrain (a GStack skill) keeps the PGLite current as you work.
Code-aware queries (gbrain code-def, gbrain code-refs,
gbrain code-callers) walk tree-sitter call-graph edges across 29
languages. Symbol-aware retrieval works better than grep for "where
is X defined" / "what calls Y" queries.
Don't use this pattern for shared knowledge. PGLite is single-process, worktree-scoped, no concurrent writers. The right tool for "my agent needs the brain my team uses" is pattern 1.
Pattern 3 — Federated repos (advanced)
Multiple GBrain servers, each indexing the same brain repo from its
own git clone. Each server has its own DB; they sync to the same
markdown source of truth via gbrain sync.
Use this when:
- You want a personal brain AND a team brain that share some content (the team's knowledge wiki) but diverge on private notes.
- You're crossing a hard trust boundary (your personal brain is read-write to you; the team brain is read-only to most teammates, write-gated to a few).
- The shared content is genuinely repo-shaped (markdown files in git), not "we both query each other's brains via MCP."
The mechanics: clone the same brain repo on each server, run
gbrain init against each, configure both to sync from the same git
remote. Pages land in both databases; the knowledge graph wires
independently on each side from the same source markdown.
Most teams should NOT pick this. The MCP-client path (pattern 1) gives you one source of truth, one set of skills, one knowledge graph, and OAuth-gated multi-user access. Federated repos make sense when the shared content is the source of truth (a published team wiki) and the agents are operating against their own private overlays.
My personal setup runs both: a personal brain on my laptop and a team brain on a separate box, indexing two different git repos. The team brain is what teammates' thin MCP clients connect to; the personal brain stays local.
Skills
35 curated skills ship in the bundle. The agent installs them via
gbrain skillpack scaffold <name> (one-time additive copy — you own the
files after). See docs/guides/skillpacks-as-scaffolding.md
for the model.
Always-on
| Skill | What it does |
|---|---|
signal-detector |
Catches ideas, entities, and TODOs on every message — the always-on capture surface. |
brain-ops |
Brain-first lookup before web search. Enforces the read-enrich-write loop. |
repo-architecture |
File-placement decisions follow the primary subject, not the format. |
Content ingestion
| Skill | What it does |
|---|---|
idea-ingest |
Links / articles / tweets. Mandatory people page for the author. |
media-ingest |
Video / audio / PDF / book with entity extraction. |
meeting-ingestion |
Transcripts → attendee enrichment chaining. |
voice-note-ingest |
Whisper → brain page with entity refs. |
book-mirror |
EPUB / PDF → personalized chapter-by-chapter two-column analysis. |
book-mirror-extreme |
Synthesis pass: lift the book's principles into your own framework. |
brain-pdf |
Render any brain page as a publication-quality PDF. |
Research + synthesis
| Skill | What it does |
|---|---|
perplexity-research |
Bounded Perplexity calls with brain-side dedup. |
academic-verify |
Citation verification + DOI resolution + claim cross-check. |
strategic-reading |
Reading-list curation tuned to active concept clusters. |
archive-crawler |
Crawl + extract from archive.is / archive-org bookmarks. |
article-enrichment |
Article → people / companies / concepts links. |
concept-synthesis |
Cross-source synthesis: 3+ pages on one concept → unified writeup. |
data-research |
Email-to-tracker pipeline with parameterized YAML recipes. |
Brain operations
| Skill | What it does |
|---|---|
query |
The default query path. Walks intent classifier + hybrid search. |
enrich |
Tier-escalating enrichment for people / companies / deals. |
maintain |
Background brain hygiene: backlinks, citations, orphans. |
citation-fixer |
Audit and fix citation format issues across the brain. |
frontmatter-guard |
Validate every page's frontmatter against the contract. |
Operational
| Skill | What it does |
|---|---|
daily-task-manager |
Task lifecycle with priority levels (P0–P4). |
daily-task-prep |
Morning prep with calendar context + agenda generation. |
cron-scheduler |
Schedule staggering, quiet hours, idempotency keys. |
reports |
Timestamped reports with keyword routing. |
cross-modal-review |
Quality gate via second model. |
webhook-transforms |
External events → brain signals. |
minion-orchestrator |
Background work: shell jobs + LLM subagents. |
Identity + meta
| Skill | What it does |
|---|---|
soul-audit |
6-phase interview → SOUL.md / USER.md / ACCESS_POLICY.md / HEARTBEAT.md. |
testing |
Skill validation framework. |
skillify |
The meta-skill: turn any feature into a properly-skilled, tested unit. |
skill-creator |
Create conforming skills with MECE check. |
skillpack-check |
Agent-readable bundle health report. |
skillpack-harvest |
Lift a proven skill from your fork back into gbrain (privacy-linted). |
functional-area-resolver |
Two-layer dispatch for compressing AGENTS.md / RESOLVER.md. |
Conventions (shared deps, installed alongside every skill)
_AGENT_README.md— agent operating contract: how to discover skills via frontmatter_brain-filing-rules.md— file-placement rules (primary subject wins)_output-rules.md— output quality standards (no LLM slop)_friction-protocol.md— log user friction to~/.gstack/friction/conventions/— cross-cutting rules (quality, brain-first, model-routing, test-before-bulk, cross-modal)
How it works
Architecture
Contract-first: src/core/operations.ts defines ~47 shared operations. CLI
and MCP server are both generated from that one source. Engine factory
dynamically imports the configured engine (pglite for zero-config local,
postgres for Supabase / self-hosted).
Trust boundary: OperationContext.remote distinguishes trusted local
CLI (remote: false) from untrusted agent-facing callers (remote: true).
Security-sensitive operations tighten when remote: true is set.
Knowledge model
Every brain page is markdown with YAML frontmatter:
- Frontmatter:
name,type(person / company / deal / concept / ...),tags, optionalsources:,triggers:(for skills),## Factsfenced block with typed claims (mrr=50000,arr=2000000). - Compiled truth: stable section the agent updates with consensus knowledge.
- Timeline: append-only event log, sentinel-separated (
<!-- timeline -->).
Pages are chunked by recursive markdown structure (default) or LLM-guided (opt-in). 29 programming languages get tree-sitter semantic chunking with embedded WASM grammars and tiktoken token budgeting.
Knowledge graph
Every page write fires extract.ts:
- Matches
[Name](people/slug)markdown links AND[[people/slug|Name]]Obsidian wikilinks. - Heuristics infer link type:
attended,works_at,invested_in,founded,advises,source,mentions. - Bulk-insert via
unnest()arrays — 4-5 params regardless of batch size, sidesteps the 65535-param cap.
Query: gbrain graph-query alice --depth 2 --direction in returns who
attended what with Alice, transitively.
Search
Per-query pipeline:
- Query intent classifier (entity / temporal / event / general) selects detail level.
- Multi-query expansion via Haiku (deterministic, off by default in
conservativemode). - Hybrid: keyword (
ts_rank× source-factor) + vector (HNSW + source-boost re-rank) + RRF fusion. - Optional reranker (ZeroEntropy
zerank-2flagship orzerank-1). - Source-aware ranking: curated content (
originals/,concepts/,writing/) outranks bulk content (chat transcripts,daily/,media/x/). Hard-excludetest/,archive/,attachments/by default. - Dedup + token budget enforcement per mode.
Engines
- PGLite — embedded Postgres 17.5 via WASM. Zero-config default. Single- file backup. Forward-reference bootstrap walks schema migrations cleanly across the v0.13–v0.35 wave.
- Postgres + pgvector — Supabase / self-hosted.
pg_trgm+ HNSW indexes. Migrations include 60+ schema bumps withsqlFor.postgres/sqlFor.pglitebranches for engine-specific DDL.
gbrain migrate --to supabase / --to pglite does the round-trip.
Storage tiering
For brains crossing 100K files where bulk machine-generated content
dominates the size: declare which directories are db_tracked (committed)
vs db_only (DB-only, gitignored). gbrain sync manages .gitignore
automatically; gbrain export --restore-only repopulates missing DB-only
files from the database.
See docs/guides/storage-tiering.md for the config shape and per-tier defaults.
Commands
SETUP
gbrain init [--pglite | --supabase] Set up a brain. Picks search mode.
gbrain migrate --to {supabase,pglite} Round-trip between engines.
gbrain doctor [--fast] [--fix] Health check + auto-repair.
CONTENT
gbrain sync [--workers N] Pull from the git brain.
gbrain import <path> Index any directory of markdown.
gbrain embed [--stale] Compute / refresh embeddings.
gbrain extract {links,timeline,all} Build the knowledge graph.
SEARCH + QUERY
gbrain query "<question>" Hybrid search + RRF + reranking.
gbrain search "<text>" Lower-level: vector | keyword | hybrid.
gbrain whoknows <topic> Expertise routing across the graph.
gbrain graph-query <slug> Typed-edge traversal.
gbrain orphans Pages with zero inbound links.
gbrain salience [--days N] Pages ranked by emotional + activity.
gbrain anomalies [--lookback-days N] Cohort-level outlier detection.
AGENTS + JOBS
gbrain agent run "<prompt>" Submit a subagent run.
gbrain agent logs <id> Tail the run's heartbeat + transcript.
gbrain jobs submit shell --params ... Submit a shell job (operator-only).
gbrain jobs supervisor start Self-restarting worker daemon.
CYCLE + AUTOPILOT
gbrain dream [--phase NAME] Run the 9-phase brain cycle.
gbrain autopilot --install Register cycle as launchd / systemd job.
SKILLPACK
gbrain skillpack list What's in the bundle.
gbrain skillpack scaffold <name> Copy a skill into your agent repo.
gbrain skillpack reference <name> Diff vs bundle. Or --all --since <ver>.
gbrain skillpack migrate-fence One-shot upgrade from pre-v0.36 model.
gbrain skillpack harvest <slug> --from <host>
Lift a proven fork skill into gbrain.
SERVE
gbrain serve Stdio MCP (single-user, Claude Code).
gbrain serve --http [--bind HOST] HTTP MCP + OAuth 2.1 + admin dashboard.
EVAL + TRAJECTORY
gbrain eval longmemeval <dataset> LongMemEval benchmark, in-memory PGLite.
gbrain eval cross-modal --task "..." 3 frontier models score the same output.
gbrain eval whoknows <fixture> Two-layer gate for whoknows accuracy.
gbrain eval suspected-contradictions Cached contradiction probe.
gbrain eval trajectory <entity> Typed-claim history + regression flags.
gbrain founder scorecard <entity> Claim accuracy / consistency / growth.
INTEGRATIONS + SOURCES
gbrain integrations list Recipe catalog (Reader, Perplexity, etc).
gbrain sources {list,add,remove,...} Multi-source brain management.
gbrain auth register-client <name> Mint an OAuth client for the HTTP MCP.
Run gbrain <command> --help for per-command options.
Docs
- Architecture:
docs/architecture/ - Skills as scaffolding (v0.36):
docs/guides/skillpacks-as-scaffolding.md - Search modes + cost matrix:
docs/eval/SEARCH_MODE_METHODOLOGY.md - Storage tiering:
docs/guides/storage-tiering.md - Embedding providers (14 recipes):
docs/integrations/embedding-providers.md - Eval capture (BrainBench-Real):
docs/eval-bench.md - MCP per-client setup:
docs/mcp/ - Two-repo pattern (agent vs brain):
docs/guides/repo-architecture.md - Skill development cycle:
docs/guides/skill-development.md - Per-agent install guide:
AGENTS.md,CLAUDE.md,INSTALL_FOR_AGENTS.md - Full changelog:
CHANGELOG.md
Origin story
I needed a brain that could remember every meeting, every founder encounter, every essay I'd ever drafted, every idea I wanted to chase later. Off-the-shelf knowledge tools (Roam, Obsidian, Notion) handle storage. None of them ingest a meeting, enrich the attendees, build the graph, fix the citations, and surface the connection three weeks later when it matters. So I built one. The first 12 days produced a working brain. The next 12 months produced 100,000 pages, a self-wiring knowledge graph, 108 cron jobs, and the multi-engine architecture that ships here.
GBrain is the generalized version of that work. You scaffold the skills. You bring your data. Your agent runs the patterns. The brain compounds nightly.
Contributing
PRs welcome. See CONTRIBUTING.md for the dev loop,
test taxonomy, and how to ship. Privacy rules in CLAUDE.md
are non-negotiable — no real names, fork names, or private references in
public artifacts. The harvest CLI's privacy linter exists to catch
accidental leaks before they merge.
License
MIT.