gbrain: Instructions file for Claude Code

CLAUDE.md

gbrain CLAUDE.md is an instructions file for Claude Code from garrytan/gbrain. It costs 3,179 tokens per session, scanned A, original, MIT.

A project instruction file for Claude Code, an agent that works on software repositories. It describes GBrain's architecture, purpose, storage options, and where to find further documentation.

In plain words
What is it for?
Understanding the GBrain codebase, choosing between embedded and hosted database setups, and checking the project's architectural reference map.
Why use it?
It gives the coding agent the project's design context and helps it load detailed information only when needed.

Instructions file for Claude Code

Written for Claude Code: the file is CLAUDE.md. Also seen: mentions .claude-plugin; mentions CLAUDE.md; mentions Claude Code.

This is garrytan/gbrain's own configuration. It tells Claude Code how to work on gbrain itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything gbrain configures →

About the project

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.

garrytan/gbrain · 33,897 stars · on GitHub

Reuse

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.

Copy the file
curl -O https://raw.githubusercontent.com/garrytan/gbrain/master/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/garrytan/gbrain

Made for: Claude Code.

Wrote 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.

agentmods badge for gbrain CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/garrytan/gbrain/claude-md/github.svg)](https://agentmods.dev/instructions/garrytan/gbrain/claude-md)
Your own site
<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.

agentmods 80×15 button for gbrain CLAUDE.md

Your own site · 80×15
<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>
Per session 3,179 This file is loaded in full into every session.
When invoked 3,179 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce 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

Measured today against content hash 0785baa90cd1, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

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.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

CLAUDE.md · 86 lines

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 (host default; 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.ts is the single source for CLI and MCP (including volunteer_context and the seven frozen MEMORY_VERBS recall/remember/entity/synthesize/forget/context_pack/delta, protocol_version: 1, servable via gbrain serve --surface verbs). Every op declares scope: 'read'|'write'|'admin' and optional localOnly, enforced before HTTP dispatch.
  • Trust is fail-closed. OperationContext.remote is required on the type; only strict ctx.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 by scripts/check-getpage-scoped-write.mjs, opt-out gbrain-allow-unscoped-getpage).
  • JSONB trap: never JSON.stringify into a ::jsonb cast. postgres.js double-encodes it (both template ${JSON.stringify(x)}::jsonb and positional $N::jsonb); PGLite hides it. Pass raw objects to engine.executeRaw / executeRawJsonb / sql.json(), or cast $N::text::jsonb. Guarded by scripts/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 in src/core/engine-sql/bootstrap.ts. Avoid runtime dynamic import()/require() in engine-live paths unless marked engine-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>; regenerate registry.generated.ts). Edit DDL only in src/schema.sql + TS fragments and run bun run build:schema. CREATE INDEX CONCURRENTLY needs transaction: false and plain CREATE INDEX on PGLite via sqlFor.pglite.
  • Multi-source keys. Slug uniqueness is (source_id, slug); call validateSourceId before any source_id path join.
  • One canonical chat-pricing table. Paid-cloud chat prices live once in src/core/model-pricing.ts (CANONICAL_PRICING; pinned by test/model-pricing.test.ts). Embeddings price separately in src/core/embedding-pricing.ts.
  • Size ratchets & peeled façades. scripts/module-size-limits.tsv (check:module-size) and scripts/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 with bun build --compile --no-compile-autoload-bunfig --outfile bin/gbrain src/cli.ts. Coverage merges per-lane lcov via scripts/merge-lcov.ts (unique --coverage-dir per process). gbrain query never expands by default (search.expansion true opts in; search-modes.md). Shared brain skills keep publication, following, and editing authorities separate (shared-brain-skills.md).

Read the full file on GitHub · 86 lines

Changes

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.

  1. today Changed · -428 lines · -5,417 tokens per session 0785baa90cd1
  2. yesterday Changed · -3 lines · -53 tokens per session e3814e1026db
  3. 5d ago Changed · +8 tokens per session 52bb9495b7b0
  4. 22d ago Changed · -1 lines · +15 tokens per session b7d2c7e7cc66
  5. 1mo ago Changed · -2 tokens per session 18e08b46015d
  6. 1mo ago Changed · +1 tokens per session 8fd346c4a27c
  7. 1mo ago Changed · +18 tokens per session b084256f0af6
  8. 1mo ago Changed · +1 lines · +3 tokens per session 4aea0efe1a4a
  9. 2mo ago Changed · -1 lines · -23 tokens per session 6cb09eda8e95
  10. 2mo ago First seen · 518 lines · 8,629 tokens per session scan A 692f33737c3d

Subscribe to this mod's changes

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.

Related

gbrain CLAUDE.md compared with instructions from other repositories

gbrain CLAUDE.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
gbrain CLAUDE.mdgarrytan/gbrainInstructions file34ktodayMITA3,179Claude Code
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA9,887GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file144ktodayMITA7,230Codex, OpenCode
langchain AGENTS.mdlangchain-ai/langchainInstructions file150ktodayMITA4,951Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA5,685GitHub Copilot
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA3,303GitHub Copilot
deno copilot-instructions.mddenoland/denoInstructions file109kyesterdayMITA3,077GitHub Copilot