# GBrain Your AI agent is smart but it doesn't know anything about your life. GBrain fixes that. Meetings, emails, tweets, calendar events, voice calls, original ideas... all of it flows into a searchable knowledge base that your agent reads before every response and writes to after every conversation. The agent gets smarter every day. > **Requires a frontier model.** Tested with **Claude Opus 4.6** and **GPT-5.4 Thinking**. Likely to break with smaller models. ## Start here: paste this into your agent Copy this block into [OpenClaw](https://openclaw.ai) or [Hermes Agent](https://github.com/NousResearch/hermes-agent). The agent will install GBrain, set up your database, import your files, and verify everything works. ``` GOAL: Install GBrain so I can search my own markdown files with hybrid search (keyword + vector). Do not skip steps. Verify each step before proceeding. If a step fails, stop and fix it. STEP 1 — INSTALL curl -fsSL https://bun.sh/install | bash && source ~/.bashrc bun add github:garrytan/gbrain Verify: gbrain --version STEP 2 — DATABASE Run: gbrain init --supabase Ask the user for their Supabase Shared Pooler connection string: "Go to https://supabase.com → your project → Get Connected → Direct Connection String → Session Pooler → copy Shared Pooler" Do NOT ask for the anon key or project URL. Those are wrong. Verify: gbrain doctor --json (all checks pass) STEP 3 — IMPORT Find markdown: find ~/git ~/Documents ~/notes -maxdepth 3 -name "*.md" | head -30 Tell user what you found. Import: gbrain import /path/ --no-embed Verify: gbrain stats (page count > 0) STEP 4 — SEARCH Run: gbrain embed --stale (generates vector embeddings, ~1 min per 1000 pages) Then: gbrain query "what are the key themes across these documents?" Show the user the results. This is the magic moment. Verify: results include semantic matches, not just keyword hits STEP 5 — GO LIVE a. Read docs/GBRAIN_SKILLPACK.md — adopt brain-first lookup, entity detection, and back-linking into your behavior immediately b. Set up live sync: gbrain sync --repo /path/ && gbrain embed --stale (see docs/guides/live-sync.md for cron/watch/webhook options) c. Set up auto-update: gbrain check-update --json on a daily cron (never auto-install — always ask the user first) d. Show available integrations: gbrain integrations e. Run verification: read and execute docs/GBRAIN_VERIFY.md DONE. Tell the user: "GBrain is live. You have [N] pages with hybrid search. I now check the brain before answering questions. Run 'gbrain integrations' to add voice, email, calendar, or Twitter." ``` ### Without an agent (standalone CLI) ```bash bun add -g github:garrytan/gbrain gbrain init --supabase # guided wizard gbrain import ~/git/brain/ # index your markdown gbrain query "what do we know about competitive dynamics?" ``` Run `gbrain --help` for all commands. See [MCP setup](docs/mcp/DEPLOY.md) for connecting Claude Desktop, Perplexity, etc. ## Getting Data In Once GBrain is installed, your agent needs data flowing in. GBrain ships integration recipes that your agent sets up for you. It reads the recipe, asks for API keys, validates each one, and runs a smoke test. [Markdown is code](docs/ethos/THIN_HARNESS_FAT_SKILLS.md)... the recipe IS the installer. | Recipe | Requires | What It Does | |--------|----------|-------------| | [Public Tunnel](recipes/ngrok-tunnel.md) | — | Fixed URL for MCP + voice (ngrok Hobby $8/mo) | | [Credential Gateway](recipes/credential-gateway.md) | — | Gmail + Calendar access (ClawVisor or Google OAuth) | | [Voice-to-Brain](recipes/twilio-voice-brain.md) | ngrok-tunnel | Phone calls → brain pages (Twilio + OpenAI Realtime) | | [Email-to-Brain](recipes/email-to-brain.md) | credential-gateway | Gmail → entity pages (deterministic collector) | | [X-to-Brain](recipes/x-to-brain.md) | — | Twitter → brain pages (timeline + mentions + deletions) | | [Calendar-to-Brain](recipes/calendar-to-brain.md) | credential-gateway | Google Calendar → searchable daily pages | | [Meeting Sync](recipes/meeting-sync.md) | — | Circleback transcripts → brain pages with attendees | Run `gbrain integrations` to see status. Dependencies resolve automatically. See [Getting Data In](docs/integrations/README.md) for the full guide. ## The Compounding Thesis Most tools help you find things. GBrain makes you smarter over time. ``` Signal arrives (meeting, email, tweet, link) → Agent detects entities (people, companies, ideas) → READ: check the brain first (gbrain search, gbrain get) → Respond with full context → WRITE: update brain pages with new information → Sync: gbrain indexes changes for next query ``` Every cycle through this loop adds knowledge. The agent enriches a person page after a meeting. Next time that person comes up, the agent already has context. You never start from zero. An agent without this loop answers from stale context. An agent with it gets smarter every conversation. The difference compounds daily. > "Who should I invite to dinner who knows both Pedro and Diana?" > — cross-references the social graph across 3,000+ people pages > "What have I said about the relationship between shame and founder performance?" > — searches YOUR thinking, not the internet > "Prep me for my meeting with Jordan in 30 minutes" > — pulls dossier, shared history, recent activity, open threads ## How this happened I was setting up my [OpenClaw](https://openclaw.ai) agent and started a markdown brain repo. One page per person, one page per company, compiled truth on top, append-only timeline on the bottom. The agent got smarter the more it knew, so I kept feeding it. Within a week I had 10,000+ markdown files, 3,000+ people with compiled dossiers, 13 years of calendar data, 280+ meeting transcripts, and 300+ captured original ideas. The agent runs while I sleep. The dream cycle scans every conversation, enriches missing entities, fixes broken citations, and consolidates memory. I wake up and the brain is smarter than when I went to sleep. See the [cron schedule guide](docs/guides/cron-schedule.md) for setup. **You don't need Postgres to start.** The knowledge model is just markdown files in a git repo. The [skills](docs/GBRAIN_SKILLPACK.md) and [schema](docs/GBRAIN_RECOMMENDED_SCHEMA.md) work with any AI agent that can read and write files. **When you need Postgres:** at 1,000+ files, `grep` stops working. GBrain adds hybrid search (keyword + vector + RRF fusion) on top of Postgres + pgvector. The CLI and MCP layer handle chunking, embedding, and incremental sync. Add Postgres when search speed matters, or when you want Claude Desktop, ChatGPT, Perplexity, or other MCP clients to connect to your brain remotely. ## Architecture ``` ┌──────────────────┐ ┌───────────────┐ ┌──────────────────┐ │ Brain Repo │ │ GBrain │ │ AI Agent │ │ (git) │ │ (retrieval) │ │ (read/write) │ │ │ │ │ │ │ │ markdown files │───>│ Postgres + │<──>│ skills define │ │ = source of │ │ pgvector │ │ HOW to use the │ │ truth │ │ │ │ brain │ │ │<───│ hybrid │ │ │ │ human can │ │ search │ │ entity detect │ │ always read │ │ (vector + │ │ enrich │ │ & edit │ │ keyword + │ │ ingest │ │ │ │ RRF) │ │ brief │ └──────────────────┘ └───────────────┘ └──────────────────┘ ``` The repo is the system of record. GBrain is the retrieval layer. The agent reads and writes through both. Human always wins — you can edit any markdown file directly and `gbrain sync` picks up the changes. ## What a Production Agent Looks Like The numbers above aren't theoretical. They come from a real deployment documented in [GBRAIN_SKILLPACK.md](docs/GBRAIN_SKILLPACK.md) — a reference architecture for how a production AI agent uses gbrain as its knowledge backbone. **Read the skillpack.** It's the most important doc in this repo. It tells your agent HOW to use gbrain, not just what commands exist: - **The brain-agent loop** — the read-write cycle that makes knowledge compound - **Entity detection** — spawn on every message, capture people/companies/original ideas - **Enrichment pipeline** — 7-step protocol with tiered API spend - **Meeting ingestion** — transcript to brain pages with entity propagation - **Source attribution** — every fact traceable to where it came from - **Reference cron schedule** — 20+ recurring jobs that keep the brain alive Without the skillpack, your agent has tools but no playbook. With it, the agent knows when to read, when to write, how to enrich, and how to keep the brain alive autonomously. It's a pattern book, not a tutorial. "Here's what works, here's why." ## How gbrain fits with OpenClaw/Hermes GBrain is world knowledge — people, companies, deals, meetings, concepts, your original thinking. It's the long-term memory of what you know about the world. [OpenClaw](https://openclaw.ai) agent memory (`memory_search`) is operational state — preferences, decisions, session context, how the agent should behave. They're complementary: | Layer | What it stores | How to query | |-------|---------------|-------------| | **gbrain** | People, companies, meetings, ideas, media | `gbrain search`, `gbrain query`, `gbrain get` | | **Agent memory** | Preferences, decisions, operational config | `memory_search` | | **Session context** | Current conversation | (automatic) | All three should be checked. GBrain for facts about the world. Memory for agent config. Session for immediate context. Install via `openclaw skills install gbrain`. ## Try it: your files, searchable in 90 seconds GBrain doesn't ship with demo data. It finds YOUR markdown and makes it searchable. **Act 1: Discovery.** GBrain scans your machine for markdown repos. ``` === GBrain Environment Discovery === ~/git/brain (2.3GB, 342 .md files, 87 binary files) Type: Plain markdown (ready for import) ~/Documents/obsidian-vault (180MB, 1,203 .md files, 0 binary files) Type: Obsidian vault (wikilink conversion available) === Discovery Complete === ``` **Act 2: Import.** Your files move from the repo into Supabase. ```bash gbrain import ~/git/brain/ # Imported 342 files into Supabase (1,847 chunks). Embedding in background... gbrain stats # Pages: 342, Chunks: 1,847, Embedded: 0 (embedding...), Links: 0 ``` **Act 3: Search.** The agent picks a query from your actual content. ```bash # The agent reads your corpus and picks a relevant query gbrain query "what do we know about competitive dynamics?" # 3 results, scored by hybrid search (vector + keyword + RRF fusion) # 30 seconds later, embeddings finish: gbrain stats # Pages: 342, Chunks: 1,847, Embedded: 1,847, Links: 0 # Now semantic search is live too gbrain query "what are our biggest risks right now?" # Finds pages about moats, board prep, and strategy -- by meaning, not keywords ``` Your file count will be different. Your queries will be different. The agent picks them based on what it imported. That's the point: this is YOUR brain, not a demo. **The compounding effect.** Search for Pedro. The agent pulls his page, his relationship history, his company. Next time Brex comes up in conversation, the agent already knows Pedro co-founded it, what you discussed last, and what's on your open threads. You didn't do anything — the brain already had it. ## Upgrade Upgrade depends on how you installed: ```bash # Installed via bun (standalone or library) bun update gbrain # Installed via ClawHub clawhub update gbrain # Compiled binary # Download the latest from https://github.com/garrytan/gbrain/releases ``` After upgrading, run `gbrain init` again to apply any schema migrations (idempotent, safe to re-run). ## Setup After installing via CLI or library path, run the setup wizard: ```bash # Guided wizard: auto-provisions Supabase or accepts a connection URL gbrain init --supabase # Or connect to any Postgres with pgvector gbrain init --url postgresql://user:pass@host:5432/dbname ``` The init wizard: 1. Checks for Supabase CLI, offers auto-provisioning 2. Falls back to manual connection URL if CLI isn't available 3. Runs the full schema migration (tables, indexes, triggers, extensions) 4. Verifies the connection and confirms the database is ready for import Config is saved to `~/.gbrain/config.json` with 0600 permissions. OpenClaw users skip this step. The orchestrator runs the wizard for you during install. ## First import ```bash # Import your markdown wiki (auto-chunks and auto-embeds) gbrain import /path/to/brain/ # Skip embedding if you want to import fast and embed later gbrain import /path/to/brain/ --no-embed # Backfill embeddings for pages that don't have them gbrain embed --stale ``` Import is idempotent. Re-running it skips unchanged files (compared by SHA-256 content hash). Progress bar shows status. ~30s for text import of 7,000 files, ~10-15 min for embedding. ## File storage and migration Brain repos accumulate binary files: images, PDFs, audio recordings, raw API responses. A repo with 3,000 markdown pages might have 2GB of binaries making `git clone` painful. GBrain has a three-stage migration lifecycle that moves binaries to cloud storage while preserving every reference: ``` Local files in git repo │ ▼ gbrain files mirror