<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Cross-Repo Context on RockB</title><link>https://baeseokjae.github.io/tags/cross-repo-context/</link><description>Recent content in Cross-Repo Context on RockB</description><image><title>RockB</title><url>https://baeseokjae.github.io/images/og-default.png</url><link>https://baeseokjae.github.io/images/og-default.png</link></image><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sun, 30 Aug 2026 19:02:48 +0000</lastBuildDate><atom:link href="https://baeseokjae.github.io/tags/cross-repo-context/index.xml" rel="self" type="application/rss+xml"/><item><title>Cross Repository Context for Coding Agents: WCTX via Local MCP</title><link>https://baeseokjae.github.io/posts/wctx-cross-repo-context-mcp/</link><pubDate>Sun, 30 Aug 2026 19:02:48 +0000</pubDate><guid>https://baeseokjae.github.io/posts/wctx-cross-repo-context-mcp/</guid><description>WCTX is a local-first MCP server that gives coding agents cross-repository context by importing finished sessions into SQLite + FTS5, with git-based freshness.</description><content:encoded><![CDATA[<p>Coding agents lose context across repositories because a session is scoped to one repo while the system under investigation spans many. WCTX is a local-first MCP server that solves this by importing finished coding-agent sessions into a SQLite + FTS5 store, linking repositories with typed relations, and exposing seven tools that let a fresh session search prior evidence with git-based freshness verdicts. No cloud account, no embeddings, no transcript upload.</p>
<h2 id="why-coding-agents-lose-context-across-repositories">Why coding agents lose context across repositories</h2>
<p>The core problem is a mismatch between the scope of a session and the scope of the system. When you run a coding agent inside repository A, its entire working memory — the files it read, the bugs it found, the decisions it made — lives in that session&rsquo;s context window. But the system you are actually building or debugging rarely lives in a single repository. A monorepo, a set of microservices, a frontend plus a backend, a library plus the applications that consume it: all of these are multi-repository systems.</p>
<p>Consider a concrete scenario. A session in repo A discovers that a bug in repo B is caused by a specific function in repo C. That is a valuable, hard-won finding. A week later, a fresh session starts in repo B to fix the bug. That session has no memory of the earlier investigation. It re-reads the same files, re-traces the same call path, and re-discovers what the first session already knew. The knowledge was never lost from the system — it was lost from the agent&rsquo;s context.</p>
<p>This is not a niche annoyance. As agentic coding becomes a daily workflow, the cost of re-deriving context grows linearly with the number of repositories and the number of sessions. The research brief for WCTX frames it precisely: &ldquo;coding-agent sessions are scoped to a repository, but the system under investigation is not.&rdquo; The fix is not to make agents remember more inside a session; it is to persist what a session learned so that future sessions in related repositories can retrieve it.</p>
<h2 id="what-is-wctx-and-how-it-works">What is WCTX and how it works</h2>
<p>WCTX is a local-first MCP server that turns completed coding-agent sessions into structured, evidence-backed engineering context. It is written in TypeScript, requires Node 22+ and git, and is MIT licensed. Its design centers on six core concepts:</p>
<ul>
<li><strong>Workspace</strong> — a logical product that sits above individual repositories. A workspace groups the repositories that together form one system.</li>
<li><strong>Repository</strong> — a git repository that belongs to a workspace.</li>
<li><strong>Relation</strong> — a directional, typed edge between repositories, such as <code>uses</code>, <code>depends_on</code>, <code>calls</code>, or <code>imports</code>. Relations are declared, not inferred, which keeps ranking explainable.</li>
<li><strong>Session</strong> — a completed coding-agent session, imported from a transcript.</li>
<li><strong>Evidence</strong> — a discrete, attributable finding extracted from a session, carrying its session id, repository, and commit.</li>
<li><strong>Freshness</strong> — a git-based staleness verdict that tells an agent whether evidence is still trustworthy.</li>
</ul>
<p>The storage layer is deliberately simple: SQLite for structured data, FTS5 for full-text search, and git for freshness checks. There are no embeddings, no vector database, and no cloud dependency. The whole thing runs on your machine.</p>
<p>WCTX exposes seven MCP tools, ordered for progressive disclosure so the surface stays affordable inside a context window:</p>
<ol>
<li><code>workspace_overview</code> — a cheap, high-level map of the workspace.</li>
<li><code>search_session_evidence</code> — the primary retrieval tool.</li>
<li><code>get_evidence</code> — fetch a specific piece of evidence.</li>
<li><code>get_session_evidence</code> — all evidence from one session.</li>
<li><code>get_related_repositories</code> — repositories connected to the current one.</li>
<li><code>verify_finding_freshness</code> — check whether evidence is stale.</li>
<li><code>finalize_session</code> — mark a session complete and index its evidence.</li>
</ol>
<p>The contrast with tools that expose dozens of MCP functions is intentional. The brief notes that agentmemory ships 54 MCP tools; WCTX ships 7. Fewer tools means a smaller context footprint and a lower chance the agent wastes tokens enumerating capabilities.</p>
<h2 id="installing-and-setting-up-wctx">Installing and setting up WCTX</h2>
<p>WCTX requires Node 22+ and git. Installation is a standard Node project:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>git clone https://github.com/Haroon-jay/wctx.git
</span></span><span style="display:flex;"><span>cd wctx
</span></span><span style="display:flex;"><span>pnpm install
</span></span><span style="display:flex;"><span>pnpm build
</span></span></code></pre></div><p>After building, initialize the workspace and run a health check:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>wctx init
</span></span><span style="display:flex;"><span>wctx doctor
</span></span></code></pre></div><p><code>wctx init</code> creates the local data directory and the SQLite store. <code>wctx doctor</code> verifies that Node, git, and the store are all in a working state before you connect an agent. If you are importing transcripts from Claude Code, note that WCTX copies the raw transcript into its own data directory at import time — this matters because Claude Code&rsquo;s <code>cleanupPeriodDays</code> (default 30) deletes JSONL transcripts, so an import-only capture strategy silently loses old history. WCTX avoids that trap by owning a copy of the transcript.</p>
<h2 id="connecting-wctx-to-your-agent-over-mcp">Connecting WCTX to your agent over MCP</h2>
<p>Once the server is built and initialized, you register it with your agent over the Model Context Protocol. For Claude Code, the command is:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>claude mcp add wctx -- wctx mcp
</span></span></code></pre></div><p>This registers the WCTX MCP server under the name <code>wctx</code>. The agent can then call the seven tools during a session. Because WCTX is a standard MCP server, the same registration pattern works with other MCP-capable agents, and you can point them at the server via a JSON MCP configuration file if your agent uses that style of config.</p>
<p>The key point is that WCTX is a local server on your machine. There is no remote endpoint, no API key to provision, and no transcript leaving your disk. The agent talks to it over the local MCP transport, and all retrieval happens against the local SQLite store.</p>
<h2 id="recording-what-a-session-learned">Recording what a session learned</h2>
<p>The capture model is the heart of WCTX&rsquo;s philosophy: post-session processing beats in-session discipline. Agents under load skip <code>save_memory</code> calls — asking an agent to remember mid-task is unreliable. Instead, WCTX imports and audits the transcript after the session ends.</p>
<p>The command-line interface provides:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>wctx capture --summary
</span></span><span style="display:flex;"><span>wctx search
</span></span></code></pre></div><p><code>wctx capture</code> ingests a finished session transcript and extracts evidence. It supports session adapters for Xirp, Claude Code, Codex, and generic JSONL, so it is not tied to a single agent vendor. The <code>--summary</code> flag produces a structured summary of what the session learned.</p>
<p>Within an MCP session, the <code>finalize_session</code> tool marks a session complete and indexes its evidence, making it available to future searches. The result is that a session&rsquo;s findings — root causes, decisions, and unresolved questions — become durable, searchable context rather than ephemeral context-window content.</p>
<h2 id="searching-prior-sessions-across-related-repositories">Searching prior sessions across related repositories</h2>
<p>Retrieval is where the cross-repository design pays off. The <code>search_session_evidence</code> tool takes a query and returns evidence ranked by relevance, with each result carrying its session id, repository, and commit. The <code>get_related_repositories</code> tool tells the agent which repositories are connected to the current one, so a search can be scoped or expanded across the workspace topology.</p>
<p>The evaluation data shows why workspace topology matters. On a synthetic 15-query, 28-evidence-item corpus, the relevant prior session appeared in the top five for 15 of 15 queries and ranked first for 11 of 15. Adding workspace topology to plain FTS5 improved mean reciprocal rank (MRR) from 0.839 to 0.867, made repository attribution exact (0.93 to 1.00), and eliminated results from unrelated repositories (0.20 to 0.00 per query). In other words, the declared relations between repositories are not decoration — they measurably improve both ranking quality and precision.</p>
<h2 id="verifying-evidence-freshness">Verifying evidence freshness</h2>
<p>Freshness is a first-class concept in WCTX, and it is what separates it from a naive transcript dump. Evidence is labelled with a git-based staleness verdict drawn from one of four states:</p>
<ul>
<li><strong>current</strong> — the evidence still matches the repository state.</li>
<li><strong>possibly_stale</strong> — something changed that may affect the finding.</li>
<li><strong>stale</strong> — the finding no longer reflects the repository.</li>
<li><strong>unknown</strong> — freshness could not be determined.</li>
</ul>
<p>The <code>verify_finding_freshness</code> tool returns this verdict, so an agent can decide whether to trust a piece of evidence or re-verify it. This matters because the whole point of cross-repository context is that a finding from a week ago may no longer be true after a refactor. A freshness verdict lets the agent treat old evidence as a lead to check rather than as ground truth.</p>
<h2 id="making-it-proactive-with-claudemd--agentsmd-guidance">Making it proactive with CLAUDE.md / AGENTS.md guidance</h2>
<p>WCTX can be made proactive by installing guidance into your agent&rsquo;s instruction files. The command:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>wctx instructions --write
</span></span></code></pre></div><p>writes guidance into <code>CLAUDE.md</code> or <code>AGENTS.md</code> so that every future session in that repository knows to search before investigating and to record root causes, decisions, and unresolved questions. This turns a passive retrieval tool into an active workflow: the agent checks prior evidence before re-deriving it, and it leaves behind evidence for the next session. The brief calls this the difference between a memory that waits to be asked and a memory that shapes how the agent works.</p>
<h2 id="wctx-vs-alternatives">WCTX vs. alternatives</h2>
<p>WCTX is not the only tool in this space, and the competitive landscape is worth understanding. The research brief compares it against five alternatives.</p>
<table>
  <thead>
      <tr>
          <th>Tool</th>
          <th>Approach</th>
          <th>Multi-repo topology</th>
          <th>Local-first</th>
          <th>Notes</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>WCTX</strong></td>
          <td>Import finished sessions into SQLite + FTS5; declared typed relations</td>
          <td>Yes, first-class</td>
          <td>Yes</td>
          <td>7 MCP tools; git-based freshness</td>
      </tr>
      <tr>
          <td><strong>engram</strong></td>
          <td>Persistent agent memory; single Go binary, SQLite + FTS5</td>
          <td>Weak; single-project focus</td>
          <td>Yes</td>
          <td>~5,991 stars; works with many agents</td>
      </tr>
      <tr>
          <td><strong>agentmemory</strong></td>
          <td>Broad automatic capture; 12 hooks, 54 MCP tools, embeddings</td>
          <td>Global server</td>
          <td>Localhost</td>
          <td>~26,961 stars; documents the cleanupPeriodDays trap</td>
      </tr>
      <tr>
          <td><strong>context-router</strong></td>
          <td>Multi-repo workspaces; observations + ADRs; auto-capture hooks</td>
          <td>Yes</td>
          <td>Yes</td>
          <td>Edges inferred from code/contracts, not declared</td>
      </tr>
      <tr>
          <td><strong>anchor</strong></td>
          <td>Repo/org memory from GitHub PR history</td>
          <td>Cross-repo impact</td>
          <td>Needs GitHub auth</td>
          <td>Records merged PRs, not the investigation</td>
      </tr>
      <tr>
          <td><strong>Rewind</strong></td>
          <td>Nightly &ldquo;dreaming&rdquo; daemon consolidates transcripts</td>
          <td>Single-agent/store</td>
          <td>Yes</td>
          <td>Review-gated updates; closest in philosophy</td>
      </tr>
  </tbody>
</table>
<p>The main differentiators for WCTX are the declared, typed relations (which drive explainable ranking and human-readable reasons) and the explicit multi-repository topology. engram is strong but single-project focused; agentmemory is broad but ships a much larger MCP surface; context-router infers edges from code rather than declaring them; anchor indexes merged PRs but not the investigation that led to them; Rewind shares WCTX&rsquo;s post-session philosophy but is single-agent in scope.</p>
<h2 id="evaluation-results-and-honest-limitations">Evaluation results and honest limitations</h2>
<p>The evaluation numbers are encouraging but should be read with appropriate skepticism. The corpus is synthetic — 15 queries and 28 evidence items — so it is a controlled test of the retrieval mechanism, not a measure of real-world value across a production codebase. The headline results:</p>
<ul>
<li>Relevant prior session in the top five for 15 of 15 queries; ranked first for 11 of 15.</li>
<li>Workspace topology improved MRR from 0.839 to 0.867 and made repository attribution exact (0.93 to 1.00).</li>
<li>Median local retrieval latency is 1.57 ms with a median response payload of ~5.0 KB (~1,250 tokens for five results).</li>
<li>Source attribution was complete for 100% of returned results under all three configurations.</li>
</ul>
<p>The latency and payload figures are the most practically relevant: sub-2 ms retrieval and a ~1,250-token response for five results mean the tool is cheap enough to call without worrying about context-window bloat. The honest limitation is that the evaluation is synthetic and small; real-world value depends on how well the declared relations match your actual repository topology and how consistently your agents record evidence.</p>
<h2 id="security-and-privacy-considerations">Security and privacy considerations</h2>
<p>Because WCTX is local-first, the privacy story is strong: no cloud account, no embeddings, no transcript upload. Your transcripts and evidence never leave your machine. The design also takes security seriously in several specific ways:</p>
<ul>
<li><strong>Redaction of secrets</strong> — evidence is scrubbed of secrets before storage.</li>
<li><strong>Historical untrusted data</strong> — evidence is labelled as historical, untrusted data, so the agent treats it as a lead rather than as authoritative instructions.</li>
<li><strong>Argument-array git calls</strong> — git is invoked with argument arrays rather than shell interpolation, avoiding injection through repository names or paths.</li>
<li><strong>Constructed FTS5 queries</strong> — full-text queries are built safely to prevent query injection.</li>
</ul>
<p>These are the details that matter when you are feeding agent-derived content back into an agent&rsquo;s context. The threat model is not a malicious remote attacker; it is the risk that stale or untrusted evidence gets treated as ground truth, or that a crafted repository name breaks a shell command.</p>
<h2 id="when-to-use-wctx-and-when-not-to">When to use WCTX and when not to</h2>
<p>WCTX is a good fit when you work across multiple repositories that form one logical system, when you want local-first privacy, and when you want explainable, freshness-checked evidence rather than a black-box vector store. It is especially valuable in the post-session model: you do not need to trust agents to remember mid-task, because you import and audit the transcript afterward.</p>
<p>It is probably overkill if you work in a single repository with a short-lived set of sessions, or if you need a global memory server shared across many agents and are willing to accept a larger MCP surface. If your primary need is broad automatic capture with embeddings and session replay, agentmemory may fit better. If you want a minimal single-binary memory with no multi-repo emphasis, engram is worth a look.</p>
<p>The deciding question is whether your system spans repositories. If it does, and if you are tired of fresh sessions re-discovering what old sessions already knew, WCTX is a focused, local-first answer.</p>
<h2 id="faq">FAQ</h2>
<p><strong>What is cross repository context for coding agents?</strong>
Cross repository context means giving a coding agent access to knowledge that was discovered in sessions run against other repositories in the same system. WCTX stores that knowledge locally and retrieves it over MCP, so a fresh session in one repo can use findings from sessions in related repos.</p>
<p><strong>Does WCTX require a cloud account or embeddings?</strong>
No. WCTX is local-first: it uses SQLite + FTS5 for storage and search, and git for freshness checks. There is no cloud account, no embeddings, and no transcript upload.</p>
<p><strong>Which coding agents does WCTX work with?</strong>
WCTX imports session transcripts from Xirp, Claude Code, Codex, and generic JSONL, and exposes a standard MCP server that any MCP-capable agent can connect to. For Claude Code, you register it with <code>claude mcp add wctx -- wctx mcp</code>.</p>
<p><strong>How does WCTX know when evidence is stale?</strong>
WCTX labels every piece of evidence with a git-based freshness verdict: current, possibly_stale, stale, or unknown. The <code>verify_finding_freshness</code> tool returns this verdict so an agent can decide whether to trust a finding or re-verify it.</p>
<p><strong>Is WCTX better than agentmemory or engram?</strong>
It depends on your needs. WCTX emphasizes declared multi-repository topology, explainable ranking, and a small 7-tool MCP surface. agentmemory offers broader automatic capture with 54 tools and embeddings, while engram is a minimal single-project memory. Choose based on whether your system spans repositories and how much MCP surface you can afford.</p>
]]></content:encoded></item></channel></rss>