Code Search
The code search tool provides semantic search over indexed code repositories. Agents can query a codebase in natural language and receive file names, line numbers, and relevant code snippets.
Tool: search_codebase
Searches indexed repositories using vector embeddings and returns the most relevant code snippets.
Arguments
| Argument | Type | Description |
|---|---|---|
query | string | Natural language description of what to find |
repo_id | string | Optional — limit search to a specific repo |
top_k | int | Number of results to return (default 5) |
Setting up code search
1. Enable code embedding
In Settings, toggle Code Repository Indexing on. This requires PostgreSQL with the pgvector extension — see PostgreSQL + pgvector setup below.
2. Add a repository
Go to Settings → Code Repos and add a repository:
| Field | Description |
|---|---|
| Name | Display name |
| Path | Absolute path to the repo on the host |
| Description | What this codebase does |
| Included patterns | File types to index (default: .py, .ts, .tsx, .js, .jsx, .rs, .go, .java, .md, .html, .vue, .css, .scss, .cpp, .c) |
| Excluded patterns | Files/dirs to skip (default: node_modules, __pycache__, venv, .git, *.pyc, dotfiles) |
| Embedding model provider | Provider for generating embeddings (gemini by default) |
3. Index the repository
Click Index in the repository settings. Synapse walks the directory tree, generates vector embeddings for each file (chunked by function/class/section), and stores them in PostgreSQL with pgvector.
Indexing progress is shown as a status indicator: pending → indexing → indexed.
4. Assign repos to agents
In the agent editor, set repos to the list of repo IDs the agent should search:
"repos": ["repo-abc123", "repo-def456"]
Example queries
Find the function that handles MCP server registration
Where is the vault_write tool implemented?
Show me all places where the anthropic client is initialised
Find tests for the orchestration engine
Re-indexing
After making significant code changes, re-index to keep the embeddings up to date. Click Re-index in the repository settings or wait for the automatic re-index (if configured).
PostgreSQL + pgvector setup
Toggle Code Repository Indexing in Settings. Synapse checks your PostgreSQL setup and guides you through any missing pieces:
| State | What Synapse shows |
|---|---|
| PostgreSQL not installed | Install instructions for Ubuntu/Debian, macOS, and Windows |
| No database configured | A form to enter host, port, username, password, and database name — click Create Database and Synapse creates the database and enables pgvector |
| Existing connection broken | The same credentials form pre-filled, with the failing URL shown — click Save & Connect to reconfigure |
| pgvector extension missing | Instructions to run CREATE EXTENSION vector; (and OS package install commands if needed) |
Or set it up manually:
CREATE DATABASE synapse;
\c synapse
CREATE EXTENSION vector;