Why is my coding agent slow on a large codebase or monorepo?

A coding agent finds code by running text searches and reading files. In a large codebase or monorepo, each question takes more searches and more file reads before the agent can edit anything. A code index shortens that step: the agent sends one query by meaning and gets the matching code chunks with file paths and line numbers.

Checked Markdown version

Where the time goes

Claude Code’s documentation describes the loop: the agent searches for the relevant source files, reads them, then acts (How Claude Code works). Its search tools match file name patterns and regular expressions.

A text search needs the right word. When the agent looks for “retry logic” and the code names it backoff, the first search misses. The agent then tries another word, or opens files to find one. A larger repository has more files that match a common word and more directories to check, so the agent spends more tool calls and reads more text before its first edit.

Text that the agent reads stays in its context for the following turns, so a long search also raises the token count of the rest of the session. How do I cut the tokens my coding agent burns per turn? covers that part.

An index answers by meaning in one call

cocoindex-code is an open-source (Apache 2.0) code search tool with a ccc CLI and an MCP server. It builds a local index of the repository:

  • Chunking. For the languages it supports, Tree-sitter parses the file, and the tool tries to split it at function, class and method boundaries. Chunks target about 1,000 characters (about 300 tokens).
  • Embedding. Each chunk gets an embedding vector. With the [full] install the model runs on your machine and needs no API key.
  • Search. The agent sends a natural-language query to the search tool. The tool returns the closest chunks, each with file path, language, code, line numbers and a similarity score. By default the MCP tool returns up to 5 results, and the ccc search CLI up to 10.

In a monorepo, scope the query to one package. The search tool takes paths (a list of path globs such as ["services/billing/*"]) and languages. The ccc search CLI scopes results to the current working directory by default.

Install and connect

Install the CLI once:

bash
pipx install 'cocoindex-code[full]'
# or with uv:
uv tool install --upgrade 'cocoindex-code[full]'

Build the index:

bash
cd your-repo
ccc index

Connect the agent. The README recommends the skill for Claude Code and other skill-compatible agents:

bash
npx skills add cocoindex-io/cocoindex-code

Or register the MCP server:

bash
# Claude Code
claude mcp add cocoindex-code -- ccc mcp

# OpenAI Codex CLI
codex mcp add cocoindex-code -- ccc mcp

Cursor and other MCP clients that launch a stdio server take the generic entry. The client must start ccc mcp with the project as its working directory:

json
{
  "mcpServers": {
    "cocoindex-code": {
      "command": "ccc",
      "args": ["mcp"]
    }
  }
}

Limits, and when another tool fits better

  • First index. The first run takes the longest: it embeds every chunk in the repository. Later runs re-index only the changed files. For the first index of a very large repository, the embedding guide suggests a cloud embedding provider.
  • Index size. The index is stored in LMDB with a default limit of 4 GiB. The README says codebases with tens of thousands of files can exhaust it. Raise it with the COCOINDEX_LMDB_MAP_SIZE environment variable (a value in bytes), then run ccc daemon restart.
  • Exact references. Semantic search returns similar code. To list every caller of a function, use a symbol tool. Serena does this through language servers. CocoIndex Code Plus (ccx) resolves definitions and references across repositories.
  • Known names. When the agent has the exact identifier, a regular-expression search is exact and quick. Keep both tools available.
  • Shared index. The index is per machine: each developer builds a local copy. For one shared index of many repositories, see CocoIndex Code Plus, a separate self-hosted product.

The speed gain depends on the repository and the task, so time the same task with and without the search tool.

Sources and further reading