---
title: "Why is my coding agent slow on a large codebase or monorepo?"
description: "A coding agent finds code with text searches and file reads, and a large codebase or monorepo needs more of both per question. A code index shortens that step."
last_updated: 2026-11-05
doc_version: "2026-11-05"
canonical: https://cocoindex.io/answers/coding-agent-slow-large-codebase/
---

# 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: 2026-11-05 · Canonical: https://cocoindex.io/answers/coding-agent-slow-large-codebase/

## 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](https://code.claude.com/docs/en/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?](https://cocoindex.io/answers/cut-coding-agent-tokens/) covers that part.

## An index answers by meaning in one call

[`cocoindex-code`](https://github.com/cocoindex-io/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](https://github.com/cocoindex-io/cocoindex-code/blob/main/EMBEDDINGS.md) 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](https://github.com/oraios/serena) does this through language servers. [CocoIndex Code Plus](https://cocoindex.io/cocoindex-code/) (`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](https://cocoindex.io/cocoindex-code/), 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

- [cocoindex-code README](https://github.com/cocoindex-io/cocoindex-code): install, MCP tool reference, configuration, troubleshooting.
- [Embedding options for cocoindex-code](https://github.com/cocoindex-io/cocoindex-code/blob/main/EMBEDDINGS.md): chunk sizes, local and cloud models.
- [Index your codebase for AI agents with CocoIndex V1](https://cocoindex.io/blogs/index-codebase-v1/): how Tree-sitter chunking and incremental embedding work in the engine under `cocoindex-code`.
- [Invisible daemon: architecture patterns for local dev tools](https://cocoindex.io/blogs/building-an-invisible-daemon/): the background daemon that keeps the embedding model loaded between `ccc` commands.

## Related questions

- [How do I cut the tokens my coding agent burns per turn?](https://cocoindex.io/answers/cut-coding-agent-tokens.md)
- [How do I give Claude Code, Cursor or Codex the whole repo as context?](https://cocoindex.io/answers/whole-repo-context.md)
- [How do I keep a code index fresh without re-embedding everything?](https://cocoindex.io/answers/keep-code-index-fresh.md)

## Sitemap

- [All answers](https://cocoindex.io/answers.md)
- [Site index (llms.txt)](https://cocoindex.io/llms.txt)
- [Markdown sitemap](https://cocoindex.io/sitemap.md)
- [XML sitemap](https://cocoindex.io/sitemap.xml)
