# How to Register Multiple Repositories for Cross-Repo Search in code-review-graph

> Easily register multiple repositories for cross-repo search in code-review-graph. Add repos to your workspace for unified indexing and seamless searching across your codebase.

- Repository: [Tirth Kanani/code-review-graph](https://github.com/tirth8205/code-review-graph)
- Tags: how-to-guide
- Published: 2026-08-18

---

**Register multiple repositories in the code-review-graph VS Code extension by adding each repo to your workspace, which automatically indexes them into a unified SQLite-backed knowledge graph for seamless cross-repository search.**

The **code-review-graph** extension transforms scattered codebases into a searchable knowledge graph. By registering multiple repositories, you enable **cross-repo search**—a single query that surfaces results across every indexed repository without switching contexts.

## What Cross-Repo Search Means in code-review-graph

Cross-repository search lets you find symbols, functions, or patterns that span project boundaries. Unlike VS Code's native workspace search, which operates on raw text files, code-review-graph builds a **semantic index** that understands relationships between entities.

When you register a repository, the extension's backend ([`backend/watcher.ts`](https://github.com/tirth8205/code-review-graph/blob/main/backend/watcher.ts)) monitors filesystem changes and populates a local SQLite database ([`backend/sqlite.ts`](https://github.com/tirth8205/code-review-graph/blob/main/backend/sqlite.ts)). Each file entry is tagged with a `repo_id`, creating a unified namespace across all registered repositories.

## Registering Repositories: Two Methods

### Method 1: Automatic Registration via Workspace Folders

The extension automatically registers any folder you open in VS Code:

1. Open a repository folder in VS Code
2. The extension triggers the onboarding flow in [`onboarding/installer.ts`](https://github.com/tirth8205/code-review-graph/blob/main/onboarding/installer.ts)
3. `registerRepo()` inserts the repository path into the `repos` table
4. `indexRepository()` performs the initial file scan

```typescript
// src/onboarding/installer.ts
export async function registerRepo(rootPath: string) {
  const db = await getDb();
  db.run('INSERT OR IGNORE INTO repos (path, name) VALUES (?, ?)', 
    [rootPath, path.basename(rootPath)]);
  // Kick off an initial indexing run
  await indexRepository(rootPath);
}

```

### Method 2: Manual Registration Through Command Palette

For repositories outside your current workspace:

1. Run **"Code Review Graph: Add Repository"** from the command palette
2. Select or type the absolute path to the repository root
3. The extension validates the path and queues it for indexing

## How the Search Engine Queries Across Repositories

Once multiple repositories are registered, the search functionality in [`features/search.ts`](https://github.com/tirth8205/code-review-graph/blob/main/features/search.ts) executes **cross-repo queries** by filtering against all `repo_id` values present in the `repos` table.

### Query Execution Flow

| Step | Component | Action |
|------|-----------|--------|
| 1 | [`features/search.ts`](https://github.com/tirth8205/code-review-graph/blob/main/features/search.ts) | Captures user query from UI |
| 2 | RPC layer | Transmits query to backend |
| 3 | [`backend/sqlite.ts`](https://github.com/tirth8205/code-review-graph/blob/main/backend/sqlite.ts) | Executes parameterized SQL |
| 4 | Result aggregator | Deduplicates and ranks matches |
| 5 | [`views/graphWebview.ts`](https://github.com/tirth8205/code-review-graph/blob/main/views/graphWebview.ts) | Renders cross-repo results |

### Backend Search Implementation

The core query spans all registered repositories automatically:

```typescript
// src/features/search.ts
export async function searchAcrossRepos(query: string): Promise<SearchResult[]> {
  const db = await getDb();
  const stmt = db.prepare(`
    SELECT file_path AS filePath, repo_name AS repoName
    FROM files
    WHERE repo_id IN (SELECT id FROM repos)   -- all registered repos
      AND content LIKE ?
    LIMIT 100
  `);
  return stmt.all(`%${query}%`);
}

```

The `repo_id IN (SELECT id FROM repos)` clause ensures every registered repository is included without explicit enumeration.

## Triggering Cross-Repo Search from the UI

Use the command palette to search across all registered repositories:

```typescript
// Command registration (typically in extension.ts)
vscode.commands.registerCommand('codeReviewGraph.search', async () => {
  const query = await vscode.window.showInputBox({ 
    prompt: 'Search all registered repos' 
  });
  if (!query) { return; }

  // Send query to backend with progress notification
  const results = await vscode.window.withProgress(
    { 
      location: vscode.ProgressLocation.Notification, 
      title: `Searching for "${query}"` 
    },
    () => rpc.invoke('searchAcrossRepos', query)
  );

  // Present results with repository provenance
  const item = await vscode.window.showQuickPick(
    results.map(r => ({ 
      label: r.filePath, 
      description: r.repoName 
    }))
  );
  
  if (item) { 
    vscode.workspace.openTextDocument(item.label)
      .then(doc => vscode.window.showTextDocument(doc)); 
  }
});

```

## Performance Optimizations for Multi-Repo Search

The extension implements several strategies to maintain speed across large repository sets:

- **Indexed lookups**: Composite index on (`repo_id`, `content`) accelerates cross-repo queries
- **Incremental updates**: [`backend/watcher.ts`](https://github.com/tirth8205/code-review-graph/blob/main/backend/watcher.ts) only re-indexes changed files
- **Result limiting**: `LIMIT 100` prevents UI bottleneck on broad queries
- **Lazy loading**: Repository metadata loads on demand; full content indexes in background

## Verifying Your Registration Status

Check which repositories are currently searchable:

1. Open the **Code Review Graph** side panel
2. View the repository tree—the count shows registered repos
3. Each node displays indexing status: `pending`, `indexing`, or `ready`

Repositories with `ready` status are fully included in cross-repo search operations.

## Summary

- **Automatic registration**: Opening folders in VS Code triggers `registerRepo()` in [`onboarding/installer.ts`](https://github.com/tirth8205/code-review-graph/blob/main/onboarding/installer.ts)
- **Unified index**: All repositories share a single SQLite database with `repo_id` tagging
- **Seamless queries**: `searchAcrossRepos()` in [`features/search.ts`](https://github.com/tirth8205/code-review-graph/blob/main/features/search.ts) queries all registered repos automatically
- **Scalable architecture**: Incremental watchers and indexed columns maintain performance across dozens of repositories

## Frequently Asked Questions

### How many repositories can I register simultaneously?

There is no hard limit enforced by the extension. SQLite handles hundreds of repositories comfortably on modern hardware. Performance depends on total indexed file count rather than repository count—expect sub-second queries for workspaces under 500,000 files.

### Do I need to re-register repositories after restarting VS Code?

No. Registered repositories persist in the SQLite database at `~/.code-review-graph/graph.db`. The extension restores the repository list on activation and resumes filesystem watching via [`backend/watcher.ts`](https://github.com/tirth8205/code-review-graph/blob/main/backend/watcher.ts).

### Can I exclude specific files or directories from cross-repo search?

Yes. The extension respects `.gitignore` patterns during indexing. Additionally, modify the `indexRepository()` function in [`backend/watcher.ts`](https://github.com/tirth8205/code-review-graph/blob/main/backend/watcher.ts) or add path exclusions to the workspace settings under `codeReviewGraph.excludePatterns`.

### How do I unregister a repository without deleting its files?

Run **"Code Review Graph: Remove Repository"** from the command palette. This executes `DELETE FROM repos WHERE path = ?` and purges associated file entries from the index, leaving the source files untouched.