---
title: "How do I give Claude Code, Cursor or Codex the whole repo as context?"
description: "Index the repository and give Claude Code, Cursor or Codex a search tool over it. The agent then pulls the relevant code from any file when it needs it."
last_updated: 2026-11-05
doc_version: "2026-11-05"
canonical: https://cocoindex.io/answers/whole-repo-context/
---

# How do I give Claude Code, Cursor or Codex the whole repo as context?

Give the agent a search tool over the whole repo instead of loading the repo into the prompt. A large repository can exceed the context window, and code the agent does not use still costs tokens on every turn. With `cocoindex-code`, run `ccc index` once, then connect Claude Code, Codex or Cursor through MCP.

Checked: 2026-11-05 · Canonical: https://cocoindex.io/answers/whole-repo-context/

## Why loading the whole repo does not scale

A model accepts a limited amount of text per request, its context window. A client sends the conversation again on each turn, so a file in the context is paid for again on each turn, until the client compacts the conversation. A small project can fit in the window. A large repository can exceed it, and files unrelated to the current task still cost tokens.

With a search tool, the repository stays on disk and the index covers the files that the project settings select. The agent requests the chunks that match the current task.

## What the index covers

[`cocoindex-code`](https://github.com/cocoindex-io/cocoindex-code) is an open-source (Apache 2.0) CLI and MCP server. `ccc index` walks the project and indexes the files that match its include patterns, minus the excluded ones listed below. The README lists 33 languages, among them Python, TypeScript, JavaScript, Rust, Go, Java, C, C++, C#, SQL and Markdown.

The project settings file, `.cocoindex_code/settings.yml`, controls the scope:

- `include_patterns` and `exclude_patterns` select files. The defaults exclude hidden directories, `node_modules`, `dist`, `target`, `__pycache__` and vendor directories.
- Files that `.gitignore` excludes stay out of the index, and so do empty files and files that are not UTF-8 text.
- `max_file_size` skips bundled or generated files above a size, for example `500KB`.

For the languages it supports, Tree-sitter parses the file, and the tool tries to split it at function, class and method boundaries. Each chunk is embedded. The agent's query returns the closest chunks with file path and line numbers, from any indexed file.

## Install and connect each client

Install the CLI and index the repository:

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

cd your-repo
ccc index
```

**Claude Code.** The README recommends the skill. The skill teaches the agent to initialize, index and search, and you can invoke it with `/ccc`:

```bash
npx skills add cocoindex-io/cocoindex-code
```

Or add the MCP server:

```bash
claude mcp add cocoindex-code -- ccc mcp
```

**OpenAI Codex CLI.**

```bash
codex mcp add cocoindex-code -- ccc mcp
```

**Cursor and other MCP clients.** A client that launches a stdio server takes this entry in its MCP configuration. The client must start `ccc mcp` with the project as its working directory:

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

The [README](https://github.com/cocoindex-io/cocoindex-code#coding-agent-integration) also documents OpenCode, Kilo Code, Grok and Oh My Pi, and a Docker setup for teams that want no Python on the host.

The MCP server exposes one tool:

```
search(
    query: str,                          # Natural language query or code snippet
    limit: int = 5,                      # Maximum results (1-100)
    offset: int = 0,                     # Pagination offset
    refresh_index: bool = True,          # Refresh index before querying
    languages: list[str] | None = None,  # Filter by language (e.g. ["python", "typescript"])
    paths: list[str] | None = None,      # Filter by path glob (e.g. ["src/utils/*"])
)
```

## Limits, and when another tool fits better

- **Chunks.** Search returns chunks, so the agent still opens the file to edit a function. Each result gives the file and the lines.
- **Built-in search.** Claude Code searches with file patterns and regular expressions ([docs](https://code.claude.com/docs/en/how-claude-code-works)), and Cursor documents its own [codebase search](https://cursor.com/docs/context/codebase-indexing). The MCP server adds search by meaning next to them. In a small repository the built-in tools can be enough.
- **Scope.** The index covers one project on one machine. For the repositories of a whole organization behind one API, see [CocoIndex Code Plus](https://cocoindex.io/cocoindex-code/) (`ccx`). It is a separate self-hosted product, with search across repositories, symbol definitions and references, and cited answers.
- **Summaries.** Search does not summarize. For an overview of how a codebase is organized, a generated wiki fits better. [Build a self-updating wiki for your codebases](https://cocoindex.io/blogs/multi-codebase-summarization/) shows one built with CocoIndex.

## Sources and further reading

- [cocoindex-code README](https://github.com/cocoindex-io/cocoindex-code): client setup, MCP tool reference, project settings, supported languages.
- [Index your codebase for AI agents with CocoIndex V1](https://cocoindex.io/blogs/index-codebase-v1/): build your own code index with the CocoIndex framework.
- [llms.txt](https://cocoindex.io/llms.txt): the install recipes in plain text for agents.

## Related questions

- [How do I add semantic search over my source code for my AI assistant?](https://cocoindex.io/answers/semantic-search-source-code.md)
- [How do I cut the tokens my coding agent burns per turn?](https://cocoindex.io/answers/cut-coding-agent-tokens.md)
- [Why is my coding agent slow on a large codebase or monorepo?](https://cocoindex.io/answers/coding-agent-slow-large-codebase.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)
