TeamBrain

TeamBrain — project instructions

TeamBrain is a git-native, cross-vendor shared memory for AI coding agents: a brain repo of markdown memories + a local daemon (MCP server + index) + capture hooks + a CI distiller that proposes new memories as pull requests.

Read first

Non-negotiable principles (tie-breakers for every decision)

  1. Git is the source of truth. SQLite index is a rebuildable cache — index corruption must never lose data. Anything durable is a file in the repo.
  2. Graceful degradation. Hooks fire-and-forget; if the daemon is down, events drop silently and the agent session is unaffected. No hook path may block, throw to the caller, or exceed 20ms p95.
  3. Privacy by construction. Default capture level is metadata: never record raw prompts, file contents, or diff bodies. Redaction runs before anything touches the spool. Never log memory bodies or event payloads at info level.
  4. Human-approved writes only. No code path writes to memories/ on main; automation writes to branches and opens PRs.
  5. Vendor-neutral. All agent-facing behavior goes through MCP + thin per-tool hooks. No richer code path for one vendor.
  6. Boring dependencies. Adding a dependency requires a one-line justification in the commit body. Prefer: node stdlib > small vetted lib > large framework. Banned without discussion: ORMs, DI frameworks, langchain-style wrappers.

Stack (fixed)

TypeScript strict, Node >= 20, pnpm workspaces monorepo. ESM only. better-sqlite3 + FTS5 + sqlite-vec; fastembed (bge-small, local ONNX); official @modelcontextprotocol/sdk; commander for CLI; vitest for tests; zod for all runtime validation at boundaries. No default exports.

Commands

pnpm install · pnpm build · pnpm test · pnpm lint · pnpm bench pnpm test:integration (spins fixture repos under /tmp)

Testing rules

Definition of done (per task)

Code + tests + acceptance commands from docs/internal/BUILD_PLAN.md pass + short entry in docs/internal/DEVLOG.md (what/why/tradeoffs, 5 lines max). If an acceptance criterion cannot be met, do not redefine it — report the blocker.

Forbidden