# cerebro-code-memory - Doramagic AI Context Pack

> Positioning: a pre-install experience and judgment asset. It helps the host AI get off to a good start, but it does not mean the project has already been installed, run, or validated.

## Sufficiency Principle

- **Sufficiency over compression**: The AI Context Pack should be sufficient for the host AI to understand the project's value, capability boundaries, entrypoints, risks, and evidence sources before starting work; it may be layered, but it does not aim for the shortest possible summary.
- **Compression policy**: Compress only noise and duplication, never context that affects judgment or the quality of the work.

## How the Host AI Should Use This

You are reading the AI Context Pack that Doramagic compiled for cerebro-code-memory. Treat it as pre-work context: help the user understand who it fits, what it can do, how to start, what must be verified after install, and where the risks are. Do not claim that you have already installed, run, or executed the target project.

## Claim Consumption Rules

- **Fact source**: Repo Evidence + Claim/Evidence Graph; the Human Wiki only supplies salience, terminology, and narrative structure.
- **Minimum status for a fact**: `supported`
- `supported`: May be used as a project fact, but the answer must cite the claim_id and evidence path.
- `weak`: Usable only as a low-confidence lead; the user must be asked to keep verifying.
- `inferred`: Usable only for risk notes or open questions; must not be packaged as a project fact.
- `unverified`: Must not be used as fact; state clearly that evidence is insufficient.
- `contradicted`: Must show the conflicting sources and must not force a single version on the user's behalf.

## Who It Fits Best

- **Developers already using host AIs such as Claude/Codex/Cursor/Gemini**: The README or plugin config mentions multiple host AIs. Evidence: `README.md` Claim: `clm_0004` supported 0.86
- **Users who want to bring professional workflows into a host AI**: The repo contains Skill documents. Evidence: `plugin/skills/cerebro/SKILL.md` Claim: `clm_0005` supported 0.86

## What It Can Do

- **AI Skill / Agent Instruction Asset Library** (Previewable before install): The project contains Skill or Agent instruction files that a host AI can read, useful for bringing professional workflows into hosts like Claude, Codex, or Cursor. Evidence: `plugin/skills/cerebro/SKILL.md` Claim: `clm_0001` supported 0.86
- **Multi-Host Install and Distribution** (Verify after install): The project contains plugin or marketplace configuration, indicating it targets install and distribution across one or more AI hosts. Evidence: `.claude-plugin/marketplace.json`, `plugin/.claude-plugin/plugin.json` Claim: `clm_0002` supported 0.86
- **Command-Line Startup or Install Flow** (Verify after install): The project documentation contains runnable commands; real use requires running them in a local or host environment. Evidence: `README.md` Claim: `clm_0003` supported 0.86

## How to Start

- `claude mcp add cerebro -- uvx cerebro-code-memory` Evidence: `README.md` Claim: `clm_0006` supported 0.86
- `/plugin marketplace add marcodavidd020/cerebro-code-memory` Evidence: `README.md` Claim: `clm_0007` supported 0.86
- `/plugin install cerebro@cerebro` Evidence: `README.md` Claim: `clm_0008` supported 0.86
- `uv tool install --from . cerebro          # installs the` Evidence: `README.md` Claim: `clm_0009` supported 0.86
- `claude mcp add cerebro -- uv --directory /path/to/cerebro run cerebro` Evidence: `README.md` Claim: `clm_0010` supported 0.86

## Continue-or-Stop Decision Card

- **Current recommendation**: Sandbox trial only
- **Why**: The project has signals of install commands, host configuration, or local writes; do not go straight into your primary environment—trial it in isolation first.

### 30-Second Read

- **What to do now**: Sandbox trial only
- **Minimum safe next step**: Run Prompt Preview first; if you still want to install, trial only in an isolated environment
- **Do not trust yet**: Real output quality cannot be trusted before install.
- **Continuing will touch**: Command execution, Host AI configuration, Local environment or project files

### What You Can Trust Now

- **Target-audience signal: Developers already using host AIs such as Claude/Codex/Cursor/Gemini** (supported): Backed by a supported claim or project evidence, but that still is not the same as real install results. Evidence: `README.md` Claim: `clm_0004` supported 0.86
- **Target-audience signal: Users who want to bring professional workflows into a host AI** (supported): Backed by a supported claim or project evidence, but that still is not the same as real install results. Evidence: `plugin/skills/cerebro/SKILL.md` Claim: `clm_0005` supported 0.86
- **Capability exists: AI Skill / Agent Instruction Asset Library** (supported): You can trust that the project contains signals of this capability; whether it fits your specific task still needs trial or after-install verification. Evidence: `plugin/skills/cerebro/SKILL.md` Claim: `clm_0001` supported 0.86
- **Capability exists: Multi-Host Install and Distribution** (supported): You can trust that the project contains signals of this capability; whether it fits your specific task still needs trial or after-install verification. Evidence: `.claude-plugin/marketplace.json`, `plugin/.claude-plugin/plugin.json` Claim: `clm_0002` supported 0.86
- **Capability exists: Command-Line Startup or Install Flow** (supported): You can trust that the project contains signals of this capability; whether it fits your specific task still needs trial or after-install verification. Evidence: `README.md` Claim: `clm_0003` supported 0.86
- **There are Quick Start / install-command signals** (supported): You can trust that the docs mention a startup or install entrypoint; do not run it directly in your primary environment because of that. Evidence: `README.md` Claim: `clm_0006` supported 0.86

### What You Cannot Trust Yet

- **Real output quality cannot be trusted before install.** (unverified): Prompt Preview can only show how it guides you; it cannot prove result quality in the real project.
- **Host AI version compatibility cannot be trusted before install.** (unverified): Host loading rules and version differences across Claude, Cursor, Codex, Gemini, and others must be verified in a real environment.
- **That it will not pollute your existing host AI's behavior cannot be trusted directly.** (inferred): Skill, plugin, and AGENTS/CLAUDE/GEMINI instructions may change the host AI's default behavior. Evidence: `.claude-plugin/marketplace.json`, `CLAUDE.md`, `plugin/.claude-plugin/plugin.json`, `plugin/skills/cerebro/SKILL.md`
- **Safe rollback cannot be assumed by default.** (unverified): Unless the project clearly provides uninstall and recovery instructions, verify in an isolated environment first.
- **After a real install, is it compatible with the user's current host AI version?** (unverified): Compatibility can only be verified in the actual host environment. Evidence: `.claude-plugin/marketplace.json`, `plugin/.claude-plugin/plugin.json`
- **Does the project's output quality meet the user's specific task?** (unverified): The pre-install preview can only show flow and boundaries; it cannot replace real evaluation.
- **Do the install commands require network access, permissions, or global writes?** (unverified): This affects install risk in both enterprise and personal environments. Evidence: `README.md`

### What Continuing Will Touch

- **Command execution**: Package managers, network downloads, the local plugin directory, project config, or the user's home directory. Why: Running the very first command can already change your environment; decide whether it is worth running first. Evidence: `README.md`
- **Host AI configuration**: The plugin, Skill, or rule-loading config of hosts like Claude/Codex/Cursor/Gemini/OpenCode. Why: Host configuration changes how the AI works afterward and may conflict with the user's existing rules. Evidence: `.claude-plugin/marketplace.json`, `CLAUDE.md`, `plugin/.claude-plugin/plugin.json`, `plugin/skills/cerebro/SKILL.md`
- **Local environment or project files**: Install results, plugin caches, project config, or local dependency directories. Why: The write scope and rollback path cannot be proven before install and need isolated verification. Evidence: `.claude-plugin/marketplace.json`, `README.md`, `plugin/.claude-plugin/plugin.json`
- **Host AI context**: The AI Context Pack, Prompt Preview, Skill routing, risk rules, and project facts. Why: Importing context affects the host AI's later judgment, so avoid packaging unverified items as facts.

### Minimum Safe Next Steps

- **Run Prompt Preview first**: Use a pre-install interactive trial to judge whether the way of working fits; it needs no authorization or environment change. (applies when: Applies to any project, especially when output quality is unknown.)
- **Trial-install only in an isolated directory or a test account**: Avoid letting install commands pollute your primary host AI, real projects, or home directory. (applies when: When there are signals of command execution, plugin config, or local writes.)
- **Back up your host AI configuration first**: Skill, plugin, and rule files may change the default behavior of Claude/Cursor/Codex. (applies when: When there is a plugin manifest, a Skill, or a host rule entrypoint.)
- **After install, verify just one minimal task**: Verify loading, compatibility, output quality, and rollback first, then decide whether to use it deeply. (applies when: When moving from a trial into a real workflow.)

### Exit Plan

- **Preserve the pre-install state**: Record the original host config and project state so you can later judge whether it is recoverable.
- **Be ready to remove the host plugin / Skill / rule entrypoint**: If behavior is off after the trial install, you can restore the host AI to its pre-trial state.
- **Record the install commands and written paths**: Without clear uninstall instructions, you at least need to know which directories or configs to clean up manually.
- **If there is no rollback path, do not enter your primary environment**: No rollback is a blocker before continuing; do not proceed on trust or luck.

## What Can Only Be Previewed

- Explain who the project fits and what it can do
- Demonstrate a typical conversation flow based on project docs
- Help the user decide whether it is worth installing or researching further

## What Must Be Verified After Install

- Actually installing the Skill, plugin, or CLI
- Running scripts, modifying local files, or accessing external services
- Verifying real output quality, performance, and compatibility

## Boundary & Risk Decision Card

- **Mistaking the pre-install preview for a real run**: The user may overestimate how much configuration, permission, and compatibility verification the project has already done. Mitigation: Clearly separate prompt_preview_can_do from runtime_required. Claim: `clm_0011` inferred 0.45
- **Host AI plugin or Skill rule conflicts**: New rules may change how the user's existing host AI behaves. Mitigation: Inspect the plugin manifest and Skill files before installing, and test in isolation if needed. Evidence: `.claude-plugin/marketplace.json`, `plugin/.claude-plugin/plugin.json` Claim: `clm_0012` supported 0.86
- **Command execution will modify the local environment**: Install commands may write to the user's home directory, the host plugin directory, or project configuration. Mitigation: Run in an isolated environment or a test account first. Evidence: `README.md` Claim: `clm_0013` supported 0.86
- **To confirm**: After a real install, is it compatible with the user's current host AI version?. Why: Compatibility can only be verified in the actual host environment.
- **To confirm**: Does the project's output quality meet the user's specific task?. Why: The pre-install preview can only show flow and boundaries; it cannot replace real evaluation.
- **To confirm**: Do the install commands require network access, permissions, or global writes?. Why: This affects install risk in both enterprise and personal environments.

## Pre-Work Working Context

### Loading Order

- First read how_to_use.host_ai_instruction to establish the boundaries of this pre-install judgment asset.
- Read claim_graph_summary to confirm facts come from the Claim/Evidence Graph, not the Human Wiki narrative.
- Then read intended_users, capabilities, and quick_start_candidates to judge whether the user is a match.
- When you need to carry out a concrete task, check role_skill_index first, then evidence_index.
- For real install, file modification, network access, performance, or compatibility questions, turn to risk_card and boundaries.runtime_required.

### Task Routes

- **AI Skill / Agent Instruction Asset Library**: Use role_skill_index / evidence_index to help the user pick a usable role, Skill, or workflow first. Boundary: Can be experienced via a pre-install Prompt. Evidence: `plugin/skills/cerebro/SKILL.md` Claim: `clm_0001` supported 0.86
- **Multi-Host Install and Distribution**: State that this is an after-install capability first, then give a pre-install checklist. Boundary: Must be verified after a real install or run. Evidence: `.claude-plugin/marketplace.json`, `plugin/.claude-plugin/plugin.json` Claim: `clm_0002` supported 0.86
- **Command-Line Startup or Install Flow**: State that this is an after-install capability first, then give a pre-install checklist. Boundary: Must be verified after a real install or run. Evidence: `README.md` Claim: `clm_0003` supported 0.86

### Context Scale

- Total files: 41
- Important-file coverage: 34/41
- Evidence index entries: 34
- Role / Skill entries: 1

### Handling Insufficient Evidence

- **missing_evidence**: State that evidence is insufficient and ask the user for the target file, a README section, or after-install verification records; do not fill in facts.
- **out_of_scope_request**: State that the task is beyond the current AI Context Pack's evidence scope and suggest the user check the Human Manual or verify after a real install.
- **runtime_request**: Provide a pre-install checklist and command sources, but do not run commands for the user or claim they have been run.
- **source_conflict**: Show the conflicting sources side by side, mark them as unverified, and do not force a single version.

## Prompt Recipes

### Fit assessment

- Goal: Judge whether this project fits the user's current task.
- Expected output: A fit conclusion, key reasons, evidence citations, what can be previewed before install, what must be verified after install, and a next-step recommendation.

```text
Based on the AI Context Pack for cerebro-code-memory, ask me 3 necessary questions first, then judge whether it fits my task. The answer must cover: who it fits, what it can do, what it cannot do, whether it is worth installing, and where the evidence comes from. Every project fact must cite evidence_refs, source_paths, or a claim_id.
```

### Pre-install experience

- Goal: Let the user feel the core workflow before installing, while avoiding packaging the preview as real capability or a marketing promise.
- Expected output: An experience script with boundary labels, an after-install verification checklist, and a cautious recommendation; with no real-run promises or strong marketing language.

```text
Treat cerebro-code-memory as a pre-install experience asset, not an already-installed tool or a real runtime environment.

Output exactly four parts:
1. Ask me 3 necessary questions first.
2. Give an "experience script": use the three labels [Previewable before install], [Must verify after install], and [Insufficient evidence] to show how it might guide the workflow.
3. Give an after-install verification checklist: list which capabilities can only be confirmed after a real install, real host loading, and a real project run.
4. Give a cautious recommendation: only "worth researching/trialing further", "add information before deciding", or "not recommended to continue"; do not endorse the project.

Hard boundaries:
- Do not claim you have installed, run, executed tests, modified files, or produced real results.
- Do not write promise-like phrasing such as "auto-adapts", "guarantees passing", "perfect fit", or "strongly recommend installing".
- If you describe how it works after install, you must use a conditional such as "if installed successfully and the host loads the Skill correctly, it might...".
- The experience script may only be written as "example lines / hypothetical flow": use "might ask / might suggest / might show", not "has written, has generated, has passed, is running, is generating".
- Prompt Preview does not hand out install commands; if the user is ready to trial, only prompt them to read Quick Start and the Risk Card first and to verify in an isolated environment.
- Every project fact must come from a supported claim, evidence_refs, or source_paths; inferred/unverified items can only be risks or open questions.

```

### Role / Skill selection

- Goal: Pick the best-matching asset from the project's roles or Skills.
- Expected output: A list of candidate roles or Skills, each with an applicable scenario, evidence paths, risk boundary, and whether after-install verification is needed.

```text
Read role_skill_index and recommend 3-5 of the most relevant roles or Skills for my target task. For each recommendation, state the applicable scenario, likely output, risk boundary, and evidence_refs.
```

### Risk pre-check

- Goal: Identify environment, permission, rule-conflict, and quality risks before installing or adopting.
- Expected output: A checklist of environment, permission, dependency, license, host-conflict, quality risk, and unknown items.

```text
Based on risk_card, boundaries, and quick_start_candidates, give me a pre-install risk pre-check list. Do not run commands for me; only explain what I should check, why, and what impact a failure would have.
```

### Host AI kickoff instruction

- Goal: Turn the project context into a host AI instruction for the start of a conversation.
- Expected output: A pre-work instruction with clear boundaries and clear evidence citations, suitable to copy to a host AI.

```text
Based on the AI Context Pack for cerebro-code-memory, generate a pre-work instruction I can paste to my host AI. This instruction must obey not_runtime=true and must not claim the project has been installed, run, or produced real results.
```

## Role / Skill Index

- Indexed 1 role / Skill / project-doc entries.

- **cerebro** (skill): Use the Cerebro brain to understand a codebase cheaply instead of re-reading folders. Invoke when starting work on a project, when you need to understand what a file does or where something lives, or before exploring directories. Query cerebro map / cerebro get / cerebro search first; record what you learn with cerebro record so future sessions reuse it. Activation hint: When the user's task is highly relevant to the workflow described by “cerebro”, use it for a pre-install experience first, then decide whether to install. Evidence: `plugin/skills/cerebro/SKILL.md`

## Evidence Index

- Indexed 34 evidence entries.

- **Cerebro 🧠** (documentation): Persistent code-knowledge memory across AI chat sessions. Evidence: `README.md`
- **Plugin** (structured_config): { "name": "cerebro", "version": "0.2.1", "description": "Persistent code-knowledge memory: an MCP brain that caches a codebase's structure and summaries so AI sessions query it instead of re-reading files. Bundles the MCP server, cerebro-first subagents, and session hooks.", "author": { "name": "Marco Toledo", "url": "https://github.com/marcodavidd020/cerebro-code-memory" }, "homepage": "https://github.com/marcodavidd020/cerebro-code-memory", "license": "MIT", "mcpServers": "./.mcp.json", "hooks": "./hooks/hooks.json" } Evidence: `plugin/.claude-plugin/plugin.json`
- **CLAUDE.md — Cerebro** (documentation): Estándares reales de este proyecto. Cárgalos antes de proponer o escribir código. Si algo aquí contradice al código actual, gana el código : verifícalo y actualiza este archivo. Evidence: `CLAUDE.md`
- **Cerebro — reuse cached code understanding** (skill_instruction): Cerebro — reuse cached code understanding Evidence: `plugin/skills/cerebro/SKILL.md`
- **Marketplace** (structured_config): { "name": "cerebro", "owner": { "name": "Marco Toledo", "url": "https://github.com/marcodavidd020" }, "plugins": { "name": "cerebro", "source": "./plugin", "description": "MCP brain for codebases: caches structure + summaries so AI sessions query it instead of re-reading files. Bundles the MCP server, cerebro-first subagents, and session hooks.", "version": "0.2.2" } } Evidence: `.claude-plugin/marketplace.json`
- **License** (source_file): Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files the "Software" , to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Evidence: `LICENSE`
- **.Mcp** (structured_config): { "mcpServers": { "cerebro": { "command": "uvx", "args": "cerebro-code-memory" } } } Evidence: `plugin/.mcp.json`
- **Hooks** (structured_config): { "hooks": { "SessionStart": { "hooks": { "type": "command", "command": "${CLAUDE PLUGIN ROOT}/hooks/session start.py" } } , "SessionEnd": { "hooks": { "type": "command", "command": "${CLAUDE PLUGIN ROOT}/hooks/cerebro-session-end.py" } } , "PreToolUse": { "matcher": "Bash Grep Glob", "hooks": { "type": "command", "command": "${CLAUDE PLUGIN ROOT}/hooks/cerebro-first.py" } } , "PostToolUse": { "matcher": "Edit Write MultiEdit", "hooks": { "type": "command", "command": "${CLAUDE PLUGIN ROOT}/hooks/post edit.py" }, { "type": "command", "command": "${CLAUDE PLUGIN ROOT}/hooks/verify-edit.py" } }, { "matcher": "mcp cerebro . ", "hooks": { "type": "command", "command": "${CLAUDE PLUGIN ROOT}/hoo… Evidence: `plugin/hooks/hooks.json`
- **Pyproject** (source_file): project name = "cerebro-code-memory" version = "0.2.2" description = "Persistent code-knowledge memory across AI chat sessions MCP server " readme = "README.md" requires-python = " =3.10" license = { text = "MIT" } authors = { name = "Marco Toledo", email = "huancacori@gmail.com" } keywords = "mcp", "claude", "code-intelligence", "tree-sitter", "semantic-search", "sqlite" dependencies = "mcp =1.2.0", "tree-sitter =0.23", "tree-sitter-language-pack =0.7", "networkx =3.2", "pathspec =0.12", Evidence: `pyproject.toml`
- **Cerebro First** (source_file): STATE DIR = Path tempfile.gettempdir / "cerebro-hook-state" ⋮---- EXPLORE = re.compile r"\b grep rg find ack ag \b" ⋮---- def find brain start: str ⋮---- p = Path start .resolve ⋮---- p = p if p.is dir else p.parent ⋮---- def main - None ⋮---- data = json.load sys.stdin ⋮---- tool = data.get "tool name", "" ti = data.get "tool input", {} or {} sid = data.get "session id" or "nosession" cwd = data.get "cwd" or os.getcwd ⋮---- exploratory = True ⋮---- exploratory = bool EXPLORE.search ti.get "command", "" or "" ⋮---- exploratory = False ⋮---- used = STATE DIR / f"{sid}.cerebro-used" nudged = STATE DIR / f"{sid}.nudged" Evidence: `plugin/hooks/cerebro-first.py`
- **Cerebro Mark Used** (source_file): STATE DIR = Path tempfile.gettempdir / "cerebro-hook-state" ⋮---- data = json.load sys.stdin sid = data.get "session id" or "nosession" Evidence: `plugin/hooks/cerebro-mark-used.py`
- **Cerebro Session End** (source_file): def find brain root start: str ⋮---- p = Path start .resolve p = p if p.is dir else p.parent ⋮---- def edited files transcript path: str - list str ⋮---- out: list str = ⋮---- obj = json.loads line ⋮---- content = obj.get "message" or {} .get "content" ⋮---- fp = item.get "input" or {} .get "file path" ⋮---- def touched roots cwd: str, transcript path: str None - list Path ⋮---- roots: dict str, Path = {} cwd root = find brain root cwd ⋮---- r = find brain root fp ⋮---- def main - None ⋮---- n = os.environ.get "CEREBRO AUTORECORD", "" .strip ⋮---- return opt-in: set CEREBRO AUTORECORD=N to enable ⋮---- data = json.load sys.stdin ⋮---- data = {} cwd = data.get "cwd" or os.getcwd roots = touc… Evidence: `plugin/hooks/cerebro-session-end.py`
- **Init** (source_file): version = "0.2.2" Evidence: `src/cerebro/__init__.py`
- **A method declaration line: optional modifiers then name . Used to attach a** (source_file): CONTROLLER = re.compile r"@Controller\ \s '\" ^'\" '\" " CONTROLLER BARE = re.compile r"@Controller\ \s \ " METHOD = re.compile r"@ Get Post Put Patch Delete All \ \s ?: '\" ^'\" '\" ?" A method declaration line: optional modifiers then name . Used to attach a handler name to the decorator above it. HANDLER = re.compile r"^\s ?:public\s+ private\s+ protected\s+ async\s+ static\s+ " ⋮---- HTTP = "GET", "POST", "PUT", "PATCH", "DELETE", "ALL" ⋮---- def join base: str None, path: str None - str ⋮---- parts = p.strip "/" for p in base or "", path or "" if p and p.strip "/" ⋮---- def extract file rel: str, text: str - list dict ⋮---- """Endpoints declared in one controller source. Each: method,… Evidence: `src/cerebro/apiroutes.py`
- **Callgraph** (source_file): def callers conn, name: str, limit: int = 300 - dict ⋮---- defined = sorted rows = conn.execute sites = r "src path" , r "src symbol" , r "line" for r in rows ⋮---- def calls from conn, path: str, limit: int = 300 - dict ⋮---- defined = {r "name" for r in conn.execute "SELECT DISTINCT name FROM symbols" } ⋮---- internal = Evidence: `src/cerebro/callgraph.py`
- **Cli** (source_file): def ctx ⋮---- config = cfg.Config.load conn = db.connect config.db path ⋮---- def bind server config, conn ⋮---- def project root - Path ⋮---- def cmd serve args ⋮---- def cmd index args ⋮---- rels = r for r in indexer. to rel config, a for a in args.paths if r res = indexer.reindex paths config, conn, rels ⋮---- res = indexer.reindex config, conn, force=args.force ⋮---- def cmd search args ⋮---- def cmd map args ⋮---- def cmd impact args ⋮---- def cmd cycles args ⋮---- def cmd orphans args ⋮---- def cmd orphans symbols args ⋮---- def cmd callers args ⋮---- def cmd calls args ⋮---- def cmd endpoints args ⋮---- def cmd recall args ⋮---- def cmd graph args ⋮---- out = Path args.out if args.ou… Evidence: `src/cerebro/cli.py`
- **Config** (source_file): DEFAULT IGNORES = ⋮---- LANG BY EXT = { ⋮---- def find root start: str None = None - Path ⋮---- env = os.environ.get "CEREBRO ROOT" ⋮---- start path = Path start or os.getcwd .resolve ⋮---- probe = start path if start path.is dir else start path.parent ⋮---- out = subprocess.run ⋮---- @dataclass class Config ⋮---- root: Path db path: Path spec: pathspec.PathSpec ⋮---- @classmethod def load cls, start: str None = None - "Config" ⋮---- root = find root start db path = root / ".cerebro" / "brain.db" patterns = list DEFAULT IGNORES ⋮---- f = root / fname ⋮---- spec = pathspec.PathSpec.from lines "gitignore", patterns ⋮---- def is ignored self, path: Path - bool ⋮---- rel = path.relative to self… Evidence: `src/cerebro/config.py`
- **--- structural index writes -------------------------------------------------** (source_file): SCHEMA = """ ⋮---- def connect db path: Path - sqlite3.Connection ⋮---- conn = sqlite3.connect str db path ⋮---- def ensure columns conn - None ⋮---- cols = {r "name" for r in conn.execute f"PRAGMA table info {table} " } ⋮---- --- structural index writes ------------------------------------------------- ⋮---- def upsert file conn, path, lang, file hash, mtime, size, indexed at, struct hash=None ⋮---- def replace symbols conn, path, symbols ⋮---- """symbols: iterable of kind, name, line, signature .""" ⋮---- names = " ".join sorted {n for , n, , in symbols} ⋮---- def replace edges conn, src path, edges ⋮---- """edges: an iterable of dst paths all recorded as kind 'import' , or a mapping {dst… Evidence: `src/cerebro/db.py`
- **Embeddings** (source_file): np = None ⋮---- MODEL = None MODEL NAME = "minishlab/potion-base-8M" ⋮---- def model available - bool ⋮---- def model ⋮---- MODEL = StaticModel.from pretrained MODEL NAME ⋮---- def docs for conn, path: str ⋮---- row = conn.execute summary = row "summary en" if row else "" syms = db.symbols for conn, path ⋮---- def has index conn - bool ⋮---- def build config, conn, only missing: bool = True - dict ⋮---- model = model files = have: dict str, str = {} ⋮---- file docs = docs for conn, p fhash = hashlib.sha1 ⋮---- vecs = np.asarray model.encode docs , dtype="float32" dim = int vecs.shape 1 now = summaries.now iso ⋮---- def search config, conn, query: str, limit: int = 10 ⋮---- rows = conn.execu… Evidence: `src/cerebro/embeddings.py`
- **Gitsync** (source_file): def git repo abs: Path, args: str, timeout: int = 15 - str None ⋮---- out = subprocess.run ⋮---- def find git repos config, max depth: int = 3 - list str ⋮---- root = config.root ⋮---- repos: list str = ⋮---- d = Path dirpath depth = len d.relative to root .parts ⋮---- def porcelain paths status: str - set str ⋮---- paths = set ⋮---- path = line 3: ⋮---- path = path.split " - ", 1 1 path = path.strip .strip '"' ⋮---- def sync config, conn - dict ⋮---- repos = find git repos config ⋮---- changed root rel: set str = set new heads: dict str, str = {} ⋮---- repo abs = config.root / repo rel if repo rel else config.root head = git repo abs, "rev-parse", "HEAD" ⋮---- key = f"git head:{repo rel}"… Evidence: `src/cerebro/gitsync.py`
- **Graph** (source_file): def build graph conn, exclude kinds: tuple str, ... = - nx.DiGraph ⋮---- g = nx.DiGraph ⋮---- ph = ",".join "?" len exclude kinds rows = conn.execute ⋮---- rows = conn.execute "SELECT src path, dst path FROM edges" ⋮---- def pagerank g, damping: float = 0.85, iters: int = 50, tol: float = 1e-6 ⋮---- nodes = list g.nodes n = len nodes ⋮---- out deg = {v: g.out degree v for v in nodes} rank = {v: 1.0 / n for v in nodes} ⋮---- dangling = sum rank v for v in nodes if out deg v == 0 nxt = {} ⋮---- inflow = sum rank u / out deg u for u in g.predecessors v if out deg u ⋮---- delta = sum abs nxt v - rank v for v in nodes rank = nxt ⋮---- def rank conn, top: int None = None ⋮---- g = build graph con… Evidence: `src/cerebro/graph.py`
- **--- disk diff ---------------------------------------------------------------** (source_file): get parser = None ⋮---- PARSER TLS = threading.local ⋮---- def parser lang: str ⋮---- cache = getattr PARSER TLS, "parsers", None ⋮---- cache = {} ⋮---- def now iso - str ⋮---- def file hash path: Path - str ⋮---- h = hashlib.sha1 ⋮---- def structure hash symbols, imports - str ⋮---- """Fingerprint of a file's shape , for summary-staleness. Hashes the symbol signatures kind+name+signature and the raw import specifiers, each sorted so reordering is a no-op. Deliberately ignores comments, whitespace and function bodies a 1-3 sentence role summary rarely changes with those — that's the token saving. It's a pure function of the file's own source raw imports, not resolved edges , so it never shi… Evidence: `src/cerebro/indexer.py`
- **Insights** (source_file): ENTRY SUFFIXES = ENTRY BASENAMES = { ENTRY SEGMENTS = ⋮---- def looks entrypoint path: str - bool ⋮---- base = path.rsplit "/", 1 -1 ⋮---- def impact conn, path: str, limit: int = 300 - dict None ⋮---- g = graphmod.build graph conn ⋮---- rev = g.reverse copy=False dist = {} dq = deque path seen = {path} ⋮---- n = dq.popleft ⋮---- by dist: dict int, int = {} ⋮---- items = sorted dist.items , key=lambda kv: kv 1 , kv 0 direct = sorted m for m, d in dist.items if d == 1 ⋮---- def is barrel path: str - bool ⋮---- def cycles conn, ignore barrels: bool = True, max report: int = 50 - dict ⋮---- g = graphmod.build graph conn, exclude kinds= "type", barrels = 0 ⋮---- drop = n for n in g.nodes if is… Evidence: `src/cerebro/insights.py`
- **Server** (source_file): mcp = FastMCP "cerebro" ⋮---- CONFIG: cfg.Config None = None CONN = None ⋮---- def ctx ⋮---- CONFIG = cfg.Config.load ⋮---- CONN = db.connect CONFIG.db path ⋮---- DEP CAP = 15 SYM CAP = 40 ⋮---- def join capped items, n: int = DEP CAP - str ⋮---- items = list items ⋮---- def empty index hint conn - str None ⋮---- n = conn.execute "SELECT COUNT AS n FROM files" .fetchone "n" ⋮---- def resolve path config, conn, path: str - str ⋮---- p = Path path ⋮---- norm = p.resolve .relative to config.root.resolve .as posix ⋮---- norm = path ⋮---- norm = posixpath.normpath path.lstrip "/" ⋮---- rows = conn.execute ⋮---- @mcp.tool def cerebro map top: int = 30 - str ⋮---- @mcp.tool def cerebro get path: s… Evidence: `src/cerebro/server.py`
- **Summaries** (source_file): def now iso - str ⋮---- def record conn, path: str, summary: str, model: str None = None - dict ⋮---- row = conn.execute source hash = row "hash" if row else None struct hash = row "struct hash" if row else None ⋮---- row = conn.execute "SELECT FROM summaries WHERE path=?", path, .fetchone ⋮---- file row = conn.execute ⋮---- current hash = file row "hash" if file row else None ⋮---- current struct = file row "struct hash" if file row else None ⋮---- stale = row "struct hash" != current struct ⋮---- stale = bool ⋮---- def stale summaries conn - list str ⋮---- rows = conn.execute Evidence: `src/cerebro/summaries.py`
- **Summarizer** (source_file): INSTRUCTION = MAX CHARS = 16000 DEFAULT MODEL = "claude-haiku-4-5" ⋮---- def claude bin - str ⋮---- HOOK NOISE = ⋮---- def is valid summary text: str - bool ⋮---- low = text.lower ⋮---- def summarize one config, rel: str, model: str - str None ⋮---- abs path = config.root / rel ⋮---- content = abs path.read text encoding="utf-8", errors="ignore" :MAX CHARS ⋮---- prompt = f"{INSTRUCTION}\n\nFile path: {rel}\n\n \n" ⋮---- out = subprocess.run ⋮---- summary = out.stdout.strip ⋮---- def select central missing conn, limit: int, prefix: str None = None - list str ⋮---- """Top files by dependency centrality that have no summary yet.""" have = {r "path" for r in conn.execute "SELECT path FROM summa… Evidence: `src/cerebro/summarizer.py`
- **Tsconfig** (source_file): @dataclass class AliasConfig ⋮---- dir: str base url: str patterns: dict str, list str ⋮---- def strip comments text: str - str ⋮---- out = ⋮---- in str = False ⋮---- ch = text i ⋮---- in str = True ⋮---- def loads jsonc text: str ⋮---- text = strip comments text text = re.sub r", \s }\ ", r"\1", text ⋮---- def resolve extends base dir: Path, ext: str - Path None ⋮---- cand = base dir / ext ⋮---- cand = base dir / ext + ".json" ⋮---- def read with extends abs path: Path, seen: set - dict ⋮---- rp = abs path.resolve ⋮---- data = loads jsonc abs path.read text encoding="utf-8", errors="ignore" ⋮---- co = data.get "compilerOptions" or {} result = {"baseUrl": co.get "baseUrl" , "paths": co.get… Evidence: `src/cerebro/tsconfig.py`
- **Cerebro — daily driver** (documentation): How to actually use it day to day. Set up once, then it mostly runs itself. Evidence: `USAGE.md`
- **Regla anti-alucinación la más importante** (documentation): Eres el Arquitecto Cerebro : el portón de diseño que evita que se programe sobre alucinaciones. Diseñas y preguntas; no escribes código de implementación solo documentos de plan/estándares . No entregas nada para implementar hasta que el usuario apruebe. Evidence: `plugin/agents/cerebro-architect.md`
- **Orden de operaciones barato → caro** (documentation): Eres el Explorador Cerebro : encuentras y explicas código gastando el mínimo de tokens. Regla de oro: nunca leas un archivo que Cerebro ya puede describirte. Evidence: `plugin/agents/cerebro-explorer.md`
- **Qué corres según la pregunta** (documentation): Eres el Analista de Impacto Cerebro : das un veredicto de riesgo ANTES de tocar código, apoyándote en el grafo de dependencias. Eres read-only . Evidence: `plugin/agents/cerebro-impact-analyst.md`
- **Flujo** (documentation): Eres el Implementador Cerebro : haces cambios de código quirúrgicos y dejas el brain más inteligente de como lo encontraste. Evidence: `plugin/agents/cerebro-implementer.md`
- **Rutina** (documentation): Eres el Guardián de Memoria Cerebro : mantienes el brain fresco y bien documentado para que las próximas sesiones gasten pocos tokens. Evidence: `plugin/agents/cerebro-memory-keeper.md`
- **Cerebro brain generated, per-repo** (source_file): Cerebro brain generated, per-repo .cerebro/ Evidence: `.gitignore`

## Rules the Host AI Must Follow

- **Treat this asset as pre-work context, not a runtime environment.**: The AI Context Pack contains only an evidence-backed understanding of the project, not the project's executable state. Evidence: `README.md`, `plugin/.claude-plugin/plugin.json`, `CLAUDE.md`
- **When answering the user, distinguish what can be previewed from what can only be verified after install.**: The consumer value of the pre-install experience comes from reducing bad installs and misjudgments, not from pretending to be a real run. Evidence: `README.md`, `plugin/.claude-plugin/plugin.json`, `CLAUDE.md`

## Questions the User Should Answer First

- Which host AI or local environment do you plan to use it in?
- Do you just want to experience the workflow first, or are you ready to actually install?
- What matters most to you: install cost, output quality, or conflicts with your existing rules?

## Acceptance Checks

- Every capability claim can be traced back to a file path in evidence_refs.
- AI_CONTEXT_PACK.md does not package previews as a real run.
- The user can understand who it fits, what it can do, how to start, and the risk boundaries within 3 minutes.

---

## Doramagic Context Augmentation

The following sections strengthen the repository context for a host AI. Human Manual data is a reading route, and pitfall notes become operating constraints.

## Human Manual Outline

Usage rule: this is only a reading route and salience signal, not factual authority. Concrete claims must still return to repo evidence or Claim Graph.

Host AI hard rules:
- Do not treat page titles, section order, summaries, or importance values as factual project evidence.
- When explaining the Human Manual outline, state that it is only a reading route or salience signal.
- Capability, installation, compatibility, runtime state, and risk claims must cite repo evidence, source paths, or Claim Graph.

- **Introduction & Installation**: importance `high`
  - source_paths: README.md, pyproject.toml, src/cerebro/cli.py, src/cerebro/config.py
- **System Architecture & Data Flow**: importance `high`
  - source_paths: src/cerebro/db.py, src/cerebro/indexer.py, src/cerebro/graph.py, src/cerebro/callgraph.py, src/cerebro/tsconfig.py
- **Core Features & MCP Tools**: importance `high`
  - source_paths: src/cerebro/server.py, src/cerebro/apiroutes.py, src/cerebro/summarizer.py, src/cerebro/summaries.py, src/cerebro/embeddings.py
- **Claude Code Plugin, Agents & Common Failure Modes**: importance `high`
  - source_paths: plugin/.claude-plugin/plugin.json, plugin/.mcp.json, plugin/hooks/hooks.json, plugin/hooks/cerebro-first.py, plugin/hooks/cerebro-session-end.py

## Repo Inspection Evidence

- repo_clone_verified: true
- repo_inspection_verified: true
- repo_commit: `7452742631ada7cedd1158d814668fb009fadf44`
- inspected_files: `README.md`, `pyproject.toml`, `src/cerebro/__init__.py`, `src/cerebro/apiroutes.py`, `src/cerebro/callgraph.py`, `src/cerebro/cli.py`, `src/cerebro/config.py`, `src/cerebro/db.py`, `src/cerebro/docaudit.py`, `src/cerebro/embeddings.py`, `src/cerebro/gitsync.py`, `src/cerebro/graph.py`, `src/cerebro/indexer.py`, `src/cerebro/insights.py`, `src/cerebro/notes.py`, `src/cerebro/server.py`, `src/cerebro/summaries.py`, `src/cerebro/summarizer.py`, `src/cerebro/tsconfig.py`, `src/cerebro/views.py`

Host AI hard rules:
- Without repo_clone_verified=true, do not claim that the source code has been read.
- Without repo_inspection_verified=true, do not write README, docs, or package-file conclusions as facts.
- Without quick_start_verified=true, do not claim that the Quick Start path has run successfully.

## Doramagic Pitfall Constraints

These rules come from Doramagic discovery, validation, or compilation findings. The host AI must treat them as operating constraints, not background notes.

### Constraint 1: Installation risk requires verification

- Trigger: Developers should check this installation risk before relying on the project: Cerebro 0.1.0
- Host AI rule: Before packaging this project, run the relevant install/config/quickstart check for: Cerebro 0.1.0. Context: Observed when using python
- Why it matters: Upgrade or migration may change expected behavior: Cerebro 0.1.0
- Evidence: failure_mode_cluster:github_release | https://github.com/marcodavidd020/cerebro-code-memory/releases/tag/v0.1.0
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 2: Installation risk requires verification

- Trigger: Developers should check this installation risk before relying on the project: Cerebro 0.2.0
- Host AI rule: Before packaging this project, run the relevant install/config/quickstart check for: Cerebro 0.2.0. Context: Observed when using python
- Why it matters: Upgrade or migration may change expected behavior: Cerebro 0.2.0
- Evidence: failure_mode_cluster:github_release | https://github.com/marcodavidd020/cerebro-code-memory/releases/tag/v0.2.0
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 3: Capability evidence risk requires verification

- Trigger: README/documentation is current enough for a first validation pass.
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: capability.assumptions | https://github.com/marcodavidd020/cerebro-code-memory
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 4: Runtime risk requires verification

- Trigger: Developers should check this runtime risk before relying on the project: Cerebro 0.2.1
- Host AI rule: Before packaging this project, run the relevant install/config/quickstart check for: Cerebro 0.2.1. Context: Observed when using python
- Why it matters: Upgrade or migration may change expected behavior: Cerebro 0.2.1
- Evidence: failure_mode_cluster:github_release | https://github.com/marcodavidd020/cerebro-code-memory/releases/tag/v0.2.1
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 5: Security or permission risk requires verification

- Trigger: no_demo
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: downstream_validation.risk_items | https://github.com/marcodavidd020/cerebro-code-memory
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 6: Security or permission risk requires verification

- Trigger: no_demo
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: risks.scoring_risks | https://github.com/marcodavidd020/cerebro-code-memory
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 7: Maintenance risk requires verification

- Trigger: issue_or_pr_quality=unknown。
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: evidence.maintainer_signals | https://github.com/marcodavidd020/cerebro-code-memory
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 8: Maintenance risk requires verification

- Trigger: release_recency=unknown。
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: evidence.maintainer_signals | https://github.com/marcodavidd020/cerebro-code-memory
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.
