# CocoIndex Code

> AST-based semantic code search your coding agent can call

- Category: Retrieval & Knowledge (RAG) / Code Indexing & Search
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/cocoindex-io/cocoindex-code
- Website: https://cocoindex.io/
- Canonical page: https://ai-tldr.dev/tools/cocoindex-code/

## In short

CocoIndex Code is a command-line semantic code search tool for a single repository. It sits in the Code Indexing & Search category of the Retrieval & Knowledge (RAG) tools and is open-source, written in Python and licensed Apache-2.0. To get started: install the CLI.

## Overview

CocoIndex Code is a command-line semantic code search tool for a single repository. It chunks source files along their abstract syntax tree rather than on fixed line counts, embeds those chunks, and stores the index locally, so a query like "find how user sessions are managed" returns the functions that actually do that work instead of a list of files that happen to contain the words.

The project is built on CocoIndex, a Rust data transformation engine from the same authors, and ships as the `ccc` command. A background daemon starts on first use and keeps the index warm; the index itself lives in an LMDB database under `.cocoindex_code/` in the project, and the whole pipeline runs on the machine — the batteries-included install pulls in `sentence-transformers` so local embeddings work with no API key at all.

Its reason for existing is the coding agent rather than the human: the repository doubles as a plugin marketplace, so Claude Code, Grok and Oh My Pi can install a `ccc` skill that teaches the agent to index and search on its own, and `ccc mcp` exposes the same search as an MCP stdio server for any other client. The README's claim for the approach is a roughly 70% token saving on code exploration compared with reading files outright.

## What it does

- AST-aware chunking via CocoIndex's Rust engine, so retrieved chunks are whole functions and classes rather than arbitrary line windows
- Local embeddings out of the box with the `[full]` install — `Snowflake/snowflake-arctic-embed-xs` is the default, and no API key is required
- Three ways for an agent to reach it: an installable `ccc` skill, an MCP stdio server (`ccc mcp`), or the CLI directly
- Incremental indexing driven by editor hooks — `SessionStart` and `PostToolUse` re-index only what changed
- `ccc grep` does structural search-by-example with no index at all, for one-off queries
- `ccc doctor` diagnoses settings, daemon health, embedding model, file matching and index status in one command

## Getting started

Install the CLI, then either hand it to your coding agent as a skill or drive it yourself. The daemon starts automatically the first time you index.

1. Install the CLI

   The `[full]` extra bundles sentence-transformers so local embeddings work without a cloud provider. Use pipx or uv — the README documents both.

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

2. Give it to your coding agent as a skill

   This is the recommended path: the skill teaches the agent to initialize, index and search on its own, and keeps the index current as you work. No `ccc init` needed.

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

3. Or drive the CLI yourself

   Useful for manual control, re-indexing after a settings change, or searching outside an agent. You can skip `ccc init` and go straight to `ccc index`, which auto-initializes a new project.

```bash
ccc init                                # initialize project (creates settings)
ccc index                               # build the index
ccc search "authentication logic"       # search!
```

4. Or register it as an MCP server

   `ccc mcp` runs the same search over MCP stdio, for clients that prefer a tool call to a skill.

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

5. Check on it

   `ccc status` reports chunk count, file count and the language breakdown; `ccc doctor` runs the full diagnostic when something looks wrong.

```bash
ccc status
ccc doctor
```

## When to use it

- Stop a coding agent from burning its context window reading whole files just to locate one function
- Search an unfamiliar repository by intent — "where do we validate webhooks?" — instead of guessing at grep patterns
- Keep code search entirely on your own machine, with local embeddings and no API key or upload
- Give several agents (Claude Code, Codex, Cursor) one shared index of the same project through MCP
