# Brain Ops > Operaciones del brain: búsqueda primero, ciclo leer-enriquecer-escribir, atribución de fuentes, enriquecimiento ambiental y back-linking. Leer antes de cualquier interacción con el brain. Fuente: https://skillsagentes.com/skills/garrytan/gbrain/brain-ops Markdown: https://skillsagentes.com/skills/garrytan/gbrain/brain-ops.md Repositorio: https://github.com/garrytan/gbrain Autor: garrytan Licencia: MIT Actualizado: hace 3 días Coste de contexto: 49 tok instalada, 2.6k tok al activarse, 2.6k tok con todos los archivos del bundle Bundle: 1 archivo, 10 KB Permisos que pide: search, query, get_page, put_page, add_link, add_timeline_entry, get_backlinks, sync_brain ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add garrytan/gbrain --skill brain-ops --agent claude-code # Cursor npx -y skills add garrytan/gbrain --skill brain-ops --agent cursor # Codex npx -y skills add garrytan/gbrain --skill brain-ops --agent codex # Gemini CLI npx -y skills add garrytan/gbrain --skill brain-ops --agent gemini # Windsurf npx -y skills add garrytan/gbrain --skill brain-ops --agent windsurf # Cline npx -y skills add garrytan/gbrain --skill brain-ops --agent cline ``` ## Qué hace - Impone el ciclo brain-first: consulta la base de conocimiento antes de usar cualquier API externa - Ejecuta el bucle READ → ENRICH → WRITE en cada señal entrante (mensaje, reunión, email) - Escribe hechos con citas de fuente en línea `[Source: ...]` y mantiene back-links obligatorios - Auto-extrae referencias de entidades en cada `put_page` y actualiza el grafo de enlaces - Usa `gbrain think` para preguntas analíticas que requieren síntesis o contexto temporal ## Cuándo usarla - Antes de investigar a una persona, empresa o tema con una API externa - En cada mensaje, reunión o email que mencione una persona, empresa o trato - Al responder cualquier pregunta sobre una entidad que pueda tener página en el brain - Para preguntas de síntesis como 'cuándo levantó capital X' o 'qué cambió desde Q1' ## Qué la activa - "Busca en el brain qué sabemos de acme-example antes de investigar externamente" - "Actualiza la página de esta persona con lo que acaba de decir en la llamada" - "¿Cuándo fue la última ronda de financiación de esta empresa según el brain?" - "Resume nuestra relación con esta empresa usando el brain" ## Antes de instalar - Requiere acceso a gbrain/MCP con las herramientas search, query, get_page, put_page, add_link, add_timeline_entry, get_backlinks y sync_brain. ## Archivos - SKILL.md — 10 KB ## SKILL.md Reproducido tal cual desde garrytan/gbrain bajo MIT. Esta sección es el documento original y está en inglés. # Brain Operations — The Ambient Context Layer The brain is not an archive. It is a live context membrane that every interaction flows through in both directions. > **Convention:** See `skills/conventions/brain-first.md` for the 5-step lookup protocol. > **Convention:** See `skills/conventions/quality.md` for citation and back-link rules. > **Memory verbs (MEMORY_VERBS v1, gbrain ≥ 0.43).** Over MCP, prefer the five > frozen memory verbs for the read/write cycle: **`remember(fact, provenance, > ttl?)`** to save a single durable fact (mandatory provenance; dedupes + > supersedes), **`recall(query | entity, budget_tokens)`** to read it back > budget-packed, **`entity(name)`** for a zero-LLM card, **`synthesize(question)`** > for the expensive cross-page answer, **`forget(id)`** to expire a fact. Use > `remember` instead of `extract_facts` when you already have ONE formed fact; > `put_page` / `add_link` / `add_timeline_entry` stay the page/graph write path. > Fall back to the classic ops when the verbs aren't on the surface. Contract: > `docs/protocol/MEMORY_VERBS_v1.md`. > > **Keyless brains:** when `extract_facts` returns `skipped: > extraction_unavailable`, YOU are the extractor — pull the facts from the turn > yourself and write each one via `remember` with `kind` set (event | preference > | commitment | belief) and the visibility the envelope's `agent_action` names > (default private — pin it; `remember` defaults to world), or author a > `## Facts` fence on the entity page. A `skipped: extraction_failed` envelope > (server-side extractor errored on this turn; `reason` names why) invites the > same manual `remember` fallback for that turn — automatic extraction stays > on for future writes. ## Contract This skill guarantees: - Brain is checked BEFORE any external API call (brain-first lookup) - Every inbound signal triggers the READ → ENRICH → WRITE loop - Every outbound response checks brain for relevant context - Source attribution on every fact written (inline `[Source: ...]` citations) - User's direct statements are highest-authority data - Back-links maintained on every brain write (Iron Law) ## Iron Law: Back-Linking (MANDATORY) Every mention of a person or company with a brain page MUST create a back-link FROM that entity's page TO the page mentioning them. An unlinked mention is a broken brain. See `skills/conventions/quality.md` for format. ## Phases ### Phase 1: Brain-First Lookup (MANDATORY) Before using ANY external API to research a person, company, or topic: 1. `gbrain entity ""` (v0.43+) — ONE known person/company/project → full card (description, aliases, open threads, recent events, edges, backlink/fact counts). Zero LLM calls, sub-100ms. This one call replaces steps 2–6 for known-entity lookups; near-misses return suggestions. 2. `gbrain search "name"` — exact-token lookup for existing pages (cheap hybrid, no expansion) 3. `gbrain query "natural question about name"` — concept/landscape questions go here FIRST (expansion recovers synonym phrasings; a nonzero `search` count is not proof of completeness) 4. `gbrain get ` — if you know the slug, read the full page 5. Check backlinks: who references this entity? 6. Check timeline: recent events involving this entity The brain almost always has something. External APIs fill gaps, not start from scratch. **⚠️ NEVER scope/count a corpus with shallow `ls` — query gbrain or `find`.** Federated sources often carry MULTIPLE coexisting directory conventions — a flat legacy layer AND a date-nested `meetings/YYYY/MM/` layer. A non-recursive `ls dir/*.md` sees only one and undercounts massively. Real example: a shallow `ls` of one source's `meetings/` counted 132 files, almost all the user's, and concluded that WAS the corpus — missing thousands of transcripts nested under `meetings/YYYY/MM/`. To count/scope a brain corpus: - **Best:** `gbrain sources list` (shows per-source indexed page counts) + `gbrain query`. gbrain indexes ALL federated sources correctly; trust its index, not the filesystem. - **If you must hit the FS:** `find -name '*.md' | wc -l`, never `ls *.md`. Then map the layout: `find -name '*.md' | sed -E 's#(.*/)[^/]+$#\1#' | sort | uniq -c`. - The bug is never "gbrain can't see the source" — it's almost always a shallow FS glob. Verify against `gbrain sources list` before believing a low count. ### Phase 1.5: Analytical Queries (gbrain think) For questions that need synthesis, temporal grounding, or analytical answers — not just "find the page" but "answer the question": 1. Use `gbrain think ""` — multi-hop synthesis across pages + takes + the graph. Temporal questions route through trajectory analysis; everything else gets an LLM-synthesized, cited answer with conflict + gap analysis. Returns a grounded answer, not just a list of matching pages. 2. Best for: "when did acme-example last raise", "what was the ARR in March", "what changed since Q1", "who is alice-example's cofounder and what are they working on", "summarize our relationship with acme-example". 3. Falls back gracefully to standard retrieval when no timeline facts match. 4. Cost: LLM calls per question — this is the expensive path. Use `query` for simple page lookups where you just need the slug or a quick context check. ### Phase 2: On Every Inbound Signal (READ → ENRICH → WRITE) Every message, meeting, email, or conversation that references a person or company: 1. **Detect entities** — people, companies, deals mentioned 2. **Load brain pages** — read existing pages for context before responding 3. **Identify new information** — what does this signal tell us that the page doesn't know? 4. **Write it back** — update the brain page with new info + timeline entry + source citation 5. **Create if missing** — if notable and no page exists, create via enrich skill **User's direct statements are the highest-value data source.** Write them to brain pages immediately with attribution `[Source: User, YYYY-MM-DD]`. ### Phase 2.5: Structured Graph Updates (automatic) Every `put_page` call automatically extracts entity references and writes them to the graph (`links` table) with inferred relationship types. Stale links (refs no longer in the page text) are removed in the same call. This is "auto-link" reconciliation. - No manual `add_link` calls needed for ordinary page writes. - Inferred link types: `attended` (meeting -> person), `works_at`, `invested_in`, `founded`, `advises`, `source` (frontmatter), `mentions` (default). - The `put_page` MCP response includes `auto_links: { created, removed, errors }` so the agent can verify outcomes. - To disable: `gbrain config set auto_link false`. Default is on. - Timeline entries with specific dates still need explicit `gbrain timeline-add` (or batch via `gbrain extract timeline --source db`). ### Phase 3: On Every Outbound Response (READ → PULL → RESPOND) Before answering any question about a person, company, or topic: 1. **Check the brain** — read relevant pages 2. **Pull context** — use compiled truth + recent timeline 3. **Respond with context** — the brain makes every answer better Don't answer from general knowledge when a brain page exists. ### Phase 4: Ambient Enrichment This is not a special mode. This is the default. Everything the user says is an ingest event. - Person mentioned → check brain, create/enrich if needed (spawn background) - Company mentioned → same - Link shared → ingest it (delegate to idea-ingest) - Data shared → delegate to appropriate skill **Rules:** - Never interrupt the conversation to do enrichment - Spawn sub-agents for anything that would slow down the response - Never announce "I'm enriching the brain" — just do it silently ## Output Format No separate output. Brain-ops is an always-on behavior layer, not a report generator. The output is updated brain pages and enriched responses. ## Cross-source citation format (v0.18.0+) When a brain has multiple sources (wiki, gstack, yc-media, etc.), every citation MUST include the source id: `[source-id:slug]`. Example: > You told me about the retry budget approach — see > [wiki:topics/resilience] and [gstack:plans/retry-policy] for where > this came from. Rules: - The key is `sources.id` (immutable), never `sources.name` (mutable display). - Single-source brains still write `[default:slug]` OR may omit the prefix for backward compat. - Every page payload returned by `search`, `query`, `get_page`, `list_pages` carries `source_id` — always use it when citing, never guess. If a search result has `source_id: "gstack"` and `slug: "plans/foo"`, the citation is `[gstack:plans/foo]`. That's the whole rule. ## Anti-Patterns - Answering questions about people/companies without checking the brain first - Using external APIs before checking the brain - Writing facts without inline `[Source: ...]` citations - Blocking the response to do enrichment - Overwriting user's direct statements with lower-authority sources - Creating brain pages for non-notable entities - Creating duplicate pages for the same entity — always check first before creating: `gbrain entity ""` (catches aliases + near-misses), then `query` with name variants ## Tools Used - `search` — cheap hybrid search (vector + keyword, no expansion) - `query` — hybrid search + LLM multi-query expansion (concept/landscape questions) - `get_page` — read a brain page - `put_page` — create/update brain pages - `add_link` — cross-reference entities - `add_timeline_entry` — record events - `get_backlinks` — check who references an entity - `sync_brain` — sync changes to the index ## Dónde encaja - Categoría: [Productividad](https://skillsagentes.com/categorias/productividad.md) — Planificación, toma de notas y automatización de flujos personales. - Creador: [garrytan](https://skillsagentes.com/creators/garrytan.md) — 134 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [Setup](https://skillsagentes.com/skills/garrytan/gbrain/setup.md): Configura GBrain con auto-aprovisionamiento de Supabase o PGLite, inyección en AGENTS.md y primera importación. - [Maintain](https://skillsagentes.com/skills/garrytan/gbrain/maintain.md): Chequeos de salud del brain: aplicación de back-links, auditoría de citas, validación de filing, detección de info obsoleta, páginas huérfanas y benchmarks. - [Schema Unify](https://skillsagentes.com/skills/garrytan/gbrain/schema-unify.md): Migra un brain de gbrain-base a la taxonomía de 14 tipos canónicos de gbrain-base-v2 usando gbrain onboard --check y el handler Minion unify-types. - [Retrieval Reflex](https://skillsagentes.com/skills/garrytan/gbrain/retrieval-reflex.md): Cuándo y qué recuperar: abre la página del brain de una entidad relevante antes de responder desde memoria. - [Minion Orchestrator](https://skillsagentes.com/skills/garrytan/gbrain/minion-orchestrator.md): Skill unificado de Minions para jobs deterministas de shell y orquestación de subagentes LLM: cola durable, observable y controlable, más la doctrina de ejecución durable para operaciones largas. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)