← Back to Docs

Project Memory

RAG isn't just agent memory — it's a shared, persistent memory for your entire project.

Index your codebase once, and every agent, every session, and every team member benefits from a single source of truth about how your project works.

What is RAG?

Retrieval-Augmented Generation (RAG) is the technique of giving an AI model access to external knowledge at query time. Instead of relying solely on what the model learned during training, RAG retrieves relevant information from a knowledge base and injects it into the model's context window.

Think of it as giving your project a shared brain. When anyone — human or agent — needs to understand how something works, the knowledge base serves as a single source of truth. It's not just about answering questions; it's about preserving and sharing the collective understanding of your codebase.

RAG transforms an AI agent from someone working from vague recollection into someone with a photographic memory of your entire project.

Why agents need memory

Without RAG, every coding session starts from zero. The agent has no concept of your project structure, your coding conventions, or decisions made in previous sessions. RAG changes this by giving the agent persistent, searchable memory.

  • No context amnesiaEvery session starts with full knowledge of your codebase. The agent already knows your folder structure, key modules, and how everything connects.
  • Convention awarenessYour coding patterns, naming conventions, and architectural decisions are indexed once and recalled forever. The agent adapts to your style, not the other way around.
  • Session continuityDecisions made in past sessions are remembered. The agent picks up where it left off, understanding what was built, why it was built that way, and what comes next.
  • Faster onboardingNew team members get an agent that already knows the codebase. No need to manually explain architecture — the agent reads it from the knowledge base and can explain it to them.

Beyond agents: Project Memory

Most people think of RAG as a tool that helps a single agent answer better questions. In mBm, we treat it as Project Memory — a persistent, shared knowledge base that serves the entire project lifecycle, not just individual conversations.

Project Memory means the knowledge base becomes the project's long-term memory. It outlives individual sessions, survives team changes, and accumulates wisdom over time. Every decision, every pattern, every architectural insight gets indexed and preserved.

Project Memory is the difference between an agent that helps you today and a knowledge base that helps your entire team for the life of the project.

>

Single source of truth

No more tribal knowledge lost when people leave. The codebase documents itself — every module, convention, and decision is searchable by anyone on the team.

>

Cross-session continuity

Work you did three months ago isn't forgotten. The agent remembers why you chose that architecture, why that pattern exists, and what depends on it.

>

Team-wide context

Multiple developers and multiple agents all pull from the same knowledge base. Everyone operates with the same understanding of the codebase.

>

Accumulated wisdom

As the project grows, so does its memory. Session summaries, architectural decisions, and refactoring rationale all compound into a rich knowledge resource.

How RAG memory works

1

Index

mBm scans your source files, documentation, configs, and session history. Each file is split into semantic chunks and converted into vector embeddings — mathematical representations of meaning.

2

Store

The embeddings are stored in a vector database alongside the original text. The database is optimized for fast similarity search — finding related content in milliseconds.

3

Retrieve

When you ask the agent something, your query is also converted to an embedding. The database finds the most semantically similar chunks — not just keyword matches, but content that's genuinely related.

4

Augment

The retrieved chunks are inserted into the model's context window alongside your question. The model now has both your query and the relevant background knowledge, enabling accurate, informed responses.

RAG in mBm

mBm ships with a built-in RAG engine that indexes your project automatically. Here's how to use it:

# Index your project into the knowledge base
mbm rag index ./src

# The agent now remembers your code structure, conventions,
# and patterns across all sessions

# Search the knowledge base
mbm rag search "how does auth work"

# Check memory health
mbm rag status

# Reindex changed files
mbm rag reindex

The knowledge base persists across sessions and is shared with all agents working on the same project. Changes to your codebase are detected automatically — reindex only changed files to keep the memory fresh without full rebuilds.

  • Persistent storageYour knowledge base lives on your machine or server. It survives restarts, updates, and works across all sessions within a project.
  • Smart reindexingmBm tracks file changes and only reindexes what changed. No wasteful full rebuilds — just incremental updates that keep memory current.
  • Multi-agent shared memoryRun multiple agents in parallel on the same project. They all share the same knowledge base, building on each other's context.

Best practices for RAG memory

Index everything meaningful

Include source code, README files, architecture docs, API specs, and even past session summaries. The richer your knowledge base, the smarter your agent becomes. Don't index build artifacts, node_modules, or generated files — they add noise without value.

Reindex after significant changes

After refactoring, adding major features, or changing architecture, run a reindex. This keeps the agent's understanding aligned with reality. Daily reindexing is a good habit for active projects.

Use descriptive file and function names

RAG works on semantic similarity. Clear, descriptive names for files, functions, and variables produce better embeddings and more accurate retrieval. The agent finds what it needs faster.

Check memory health regularly

Run `mbm rag status` periodically to check your knowledge base health. Watch for stale entries, orphaned chunks, and indexing gaps. A healthy memory means reliable agent performance.