May 5, 2026 · 8 min read

What is Code Context Engine?

A complete guide to understanding and using CCE. What it does, why you need it, how to set it up, and what happens under the hood.

The problem CCE solves

When you use an AI coding agent (Claude Code, Cursor, Copilot, Gemini), it needs to understand your codebase to answer questions and write code. The way it does this today is by reading entire files.

Ask "how does the payment flow work?" and the agent reads payments.py (800 lines), shipping.py (600 lines), and orders.py (400 lines). That's 45,000 tokens of input. You pay for every one of them.

The problem: most of those tokens are irrelevant. The answer was in 3 functions totaling 40 lines. The other 1,760 lines were wasted context.

Input tokens are 85-95% of your AI coding bill. Output tokens (the AI's responses) are cheap. The expensive part is feeding your code into the model.

What CCE does

Code Context Engine (CCE) is a local tool that indexes your codebase and lets AI agents search instead of read.

Instead of reading 3 entire files (45,000 tokens), the AI calls context_search("payment flow") and gets back the 3 relevant functions (800 tokens). Same answer. 94% fewer tokens.

Without CCEWith CCE
How the AI gets contextReads entire filesSearches the index
Tokens per query83,6814,927
What the AI seesEverything in the fileOnly the relevant code
Your cost (Sonnet)$0.14/session$0.04/session

How to set it up (60 seconds)

1

Install CCE

uv tool install code-context-engine

Or use pipx install code-context-engine if you don't have uv. Requires Python 3.11+.

2

Initialize your project

cd /path/to/your/project
cce init

This does everything automatically:

  • Indexes your codebase (parses code into semantic chunks)
  • Registers the MCP server with your editor
  • Installs git hooks so the index stays current
  • Creates a CLAUDE.md with instructions for the AI
3

Restart your editor

That's it. Your AI agent now searches the index instead of reading files. No configuration needed.

Which editors work with CCE?

cce init auto-detects your editor and writes the right config:

EditorHow it connects
Claude CodeMCP via .mcp.json
CursorMCP via .cursor/mcp.json
VS Code / CopilotMCP via .vscode/mcp.json
Gemini CLIMCP via .gemini/settings.json
Codex CLIMCP via ~/.codex/config.toml
OpenCodeMCP via opencode.json

Multiple editors in the same project? All get configured in one command.

What is MCP?

Model Context Protocol (MCP) is an open standard that lets AI agents use external tools. CCE is an MCP server. When Claude Code needs to understand your code, it calls CCE's tools through MCP instead of reading files directly.

You don't need to understand MCP to use CCE. cce init handles the wiring.

How it works under the hood

1. Indexing

CCE uses tree-sitter (the same parser used by GitHub, Neovim, and Zed) to parse your code into semantic chunks: functions, classes, modules. Each chunk gets a vector embedding stored locally in SQLite.

2. Searching

When the AI calls context_search("payment flow"), CCE runs a hybrid search: vector similarity (finds conceptually related code) combined with BM25 keyword matching (finds exact terms). Results are ranked by a confidence scorer that blends similarity, keyword match, and recency.

3. Graph expansion

If payments.py is a hit, CCE checks the code graph and automatically pulls in files it imports or calls. You get the dependency chain without asking for it.

4. Compression

Retrieved chunks are compressed to signatures and docstrings. A 200-line function becomes its signature + first docstring paragraph. The AI gets the shape of the code without every implementation detail.

5. Memory

CCE remembers decisions across sessions. Call record_decision("use JWT for auth") and next session, session_recall("auth") brings it back. No re-explaining your architecture.

What tools does CCE give the AI?

ToolWhat it does
context_searchSearch for relevant code by description
expand_chunkGet the full source of a compressed result
related_contextFind code connected via imports/calls
session_recallRecall decisions from past sessions
record_decisionSave a decision for future sessions
record_code_areaNote which files were worked on
reindexRe-index a file or the full project
index_statusCheck index health
set_output_compressionAdjust how verbose Claude's replies are

The AI uses these tools automatically. You don't need to call them yourself.

Does the index stay current?

Yes. Git hooks reindex on every commit, checkout, and merge. CCE uses content hashing (SHA-256 per file), so only changed files get re-processed. Typical reindex after editing a few files: under 1 second.

Is my code sent to the cloud?

No. Everything runs locally. The index is stored in ~/.cce/projects/. Embeddings are computed on your CPU using a local ONNX model. No API keys, no cloud services, no data leaves your machine.

How do I see my savings?

cce savings

Shows tokens saved, dollar amounts (from live Anthropic pricing), and per-layer breakdown. Run cce savings --all to see savings across all your projects.

How do I remove it?

cce uninstall

Removes everything: hooks, config files, index data, editor settings. Clean removal, nothing left behind.

Supported languages

AST-aware chunking (tree-sitter parsed): Python, JavaScript, TypeScript, JSX, TSX, PHP, Go, Rust, Java.

Fallback chunking (line-based): Markdown, YAML, JSON, config files, and all other text files.

FAQ

Does it work on large codebases?

Tested on repos up to 400+ files (1M tokens). Indexing takes 30-60 seconds on first run, under 1 second for incremental updates.

What if the search returns wrong code?

Recall@10 = 0.90 (tested on FastAPI). 9/10 times it finds the right file. The 10% miss is usually cross-cutting queries spanning many files. The AI falls back to reading files normally when search doesn't help.

Can I use it alongside Cursor's built-in indexing?

Yes. They don't conflict. CCE provides an additional MCP-based search. Cursor's native indexing still works.

Is it free?

Yes. MIT licensed. Free forever. No paid tier, no usage limits.

Try it now

Three commands. 60 seconds. See your savings immediately.

uv tool install code-context-engine && cd your-project && cce init
View on GitHub
#CodeContextEngine #ClaudeCode #SaveTokens #AICoding #MCPServer #OpenSource #DeveloperTools #Cursor #VSCode #GeminiCLI #ReduceAICosts #TokenSavings #LLMTools #CodingAgent #CodeIndexing