GBrain is a memory and retrieval layer for AI agents that searches, connects, and synthesizes information from stored sources. It is used to give coding agents and autonomous agents access to knowledge beyond their current code, including shared company information with access controls. The catalogue add-ons help agents operate GBrain and connect it to agent workflows.
Borrowing it
Nothing to install: this file belongs to garrytan/gbrain. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/garrytan/gbrain/master/CLAUDE.mdgit clone --depth 1 https://github.com/garrytan/gbrainWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/instructions/garrytan/gbrain/claude-md)<a href="https://agentmods.dev/instructions/garrytan/gbrain/claude-md"><img src="https://agentmods.dev/badge/instructions/garrytan/gbrain/claude-md/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/instructions/garrytan/gbrain/claude-md"><img src="https://agentmods.dev/badge/instructions/garrytan/gbrain/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.03179 | $0.03179 |
| Opus 5.5 | $0.01272 | $0.01272 |
| Sonnet 5.5 | $0.00636 | $0.00636 |
| Haiku 4.5 | $0.00318 | $0.00318 |
Grade A, and why
gbrain CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
Copies of this mod
1 near-identical copy found in the catalogue:
- GBrain CLAUDE.md — 91% identical, 880 lines differ
How it starts
The opening of the file, as written. The whole thing — 86 lines — stays where its author put it; the contents beside it link to each section on GitHub.
CLAUDE.md
Start with AGENTS.md for the canonical agent contract (install, memory operating protocol, lookup table, shared-checkout Git rules, operator error contract, and trust boundary). This file holds the Claude Code and contributor delta: architecture invariants, the on-demand reference map, and inline ship rules.
North Star & Two Axes
GBrain aims to be the next Postgres for memory — judged whole-system across BrainBench (retrieval, LongMemEval, calibration), never by isolated algorithm bake-offs.
Every query routes on two orthogonal axes (6-tier resolution; brains-and-sources.md, brain-routing.md):
- Brain — which database (
hostdefault; mounted brains via--brain,GBRAIN_BRAIN_ID,.gbrain-mount). - Source — which repo inside a database (slugs scope per source;
--source,GBRAIN_SOURCE,.gbrain-source).
Architecture and cross-cutting invariants
Per-file detail loads on demand from KEY_FILES.md. These invariants apply across every change:
- Contract-first.
src/core/operations.tsis the single source for CLI and MCP (includingvolunteer_contextand the seven frozenMEMORY_VERBSrecall/remember/entity/synthesize/forget/context_pack/delta,protocol_version: 1, servable viagbrain serve --surface verbs). Every op declaresscope: 'read'|'write'|'admin'and optionallocalOnly, enforced before HTTP dispatch. - Trust is fail-closed.
OperationContext.remoteis required on the type; only strictctx.remote === false(src/cli.ts) is trusted local. Never default it falsy. - Source isolation. Route every read-side op through
sourceScopeOpts(ctx)(ctx.auth.allowedSources>ctx.sourceId> unscoped). Existence check + write pairs must scope reads to the write's source (getPage(slug, { sourceId: x ?? 'default' }); guarded byscripts/check-getpage-scoped-write.mjs, opt-outgbrain-allow-unscoped-getpage). - JSONB trap: never
JSON.stringifyinto a::jsonbcast. postgres.js double-encodes it (both template${JSON.stringify(x)}::jsonband positional$N::jsonb); PGLite hides it. Pass raw objects toengine.executeRaw/executeRawJsonb/sql.json(), or cast$N::text::jsonb. Guarded byscripts/check-jsonb-pattern.sh,scripts/check-jsonb-params.mjs, and Postgres E2E (ENGINES.md). - Engine parity & static imports. Migrated storage domains keep shared SQL once in
src/core/engine-sql/<domain>.ts(check:engine-sql-ratchet; dialect-only lines take// engine-sql-ok: <reason>); forward-referenced columns/indexes go insrc/core/engine-sql/bootstrap.ts. Avoid runtime dynamicimport()/require()in engine-live paths unless markedengine-dynamic-import-ok(scripts/check-engine-dynamic-import.sh). - Schema & migrations. One file per migration in
src/core/schema-migrations/(bun run new:migration <name>; regenerateregistry.generated.ts). Edit DDL only insrc/schema.sql+ TS fragments and runbun run build:schema.CREATE INDEX CONCURRENTLYneedstransaction: falseand plainCREATE INDEXon PGLite viasqlFor.pglite. - Multi-source keys. Slug uniqueness is
(source_id, slug); callvalidateSourceIdbefore anysource_idpath join. - One canonical chat-pricing table. Paid-cloud chat prices live once in
src/core/model-pricing.ts(CANONICAL_PRICING; pinned bytest/model-pricing.test.ts). Embeddings price separately insrc/core/embedding-pricing.ts. - Size ratchets & peeled façades.
scripts/module-size-limits.tsv(check:module-size) andscripts/function-size-baseline.tsv(check:function-size, <=300 lines/fn) ratchet file/function sizes. Peeled façades (operations.ts, engines,migrate.ts,doctor.ts,sync.ts,serve-http.ts,cli.ts,jobs.ts,hybrid.ts,autopilot.ts,skillpack.ts) keep their re-exports; new code goes into the module dirs (CONTRIBUTING.md). - Progress, build, coverage, search & skills. Bulk commands report progress to stderr via
src/core/progress.ts(progress-events.md). Compile binary withbun build --compile --no-compile-autoload-bunfig --outfile bin/gbrain src/cli.ts. Coverage merges per-lane lcov viascripts/merge-lcov.ts(unique--coverage-dirper process).gbrain querynever expands by default (search.expansion trueopts in; search-modes.md). Shared brain skills keep publication, following, and editing authorities separate (shared-brain-skills.md).
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- today Changed · -428 lines · -5,417 tokens per session 0785baa90cd1
- yesterday Changed · -3 lines · -53 tokens per session e3814e1026db
- 5d ago Changed · +8 tokens per session 52bb9495b7b0
- 22d ago Changed · -1 lines · +15 tokens per session b7d2c7e7cc66
- 1mo ago Changed · -2 tokens per session 18e08b46015d
- 1mo ago Changed · +1 tokens per session 8fd346c4a27c
- 1mo ago Changed · +18 tokens per session b084256f0af6
- 1mo ago Changed · +1 lines · +3 tokens per session 4aea0efe1a4a
- 2mo ago Changed · -1 lines · -23 tokens per session 6cb09eda8e95
- 2mo ago First seen · 518 lines · 8,629 tokens per session scan A 692f33737c3d
gbrain CLAUDE.md is an instructions file published in the GitHub repository garrytan/gbrain (33,897 stars, last pushed today), licensed MIT. It adds 3,179 tokens to every session, about $0.0127 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
gbrain CLAUDE.md compared with instructions from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| gbrain CLAUDE.mdgarrytan/gbrain | Instructions file | 34k | today | MIT | A | 3,179 | Claude Code |
| vscode buildNext.instructions.mdmicrosoft/vscode | Instructions file | 195k | today | MIT | A | 9,887 | GitHub Copilot |
| next.js AGENTS.mdvercel/next.js | Instructions file | 144k | today | MIT | A | 7,230 | Codex, OpenCode |
| langchain AGENTS.mdlangchain-ai/langchain | Instructions file | 150k | today | MIT | A | 4,951 | Codex, OpenCode |
| vscode oss-third-party-notices.instructions.mdmicrosoft/vscode | Instructions file | 195k | today | MIT | A | 5,685 | GitHub Copilot |
| vscode copilot-instructions.mdmicrosoft/vscode | Instructions file | 195k | today | MIT | A | 3,303 | GitHub Copilot |
| deno copilot-instructions.mddenoland/deno | Instructions file | 109k | yesterday | MIT | A | 3,077 | GitHub Copilot |