opensourceprojects.dev

A broadsheet for software that doesn't ask for your email

AST-based semantic code search that saves 70% of tokens
GitHub RepoImpressions3

Project Description

View on GitHub

AST-Based Semantic Code Search That Cuts Your Token Usage by 70%

You've probably watched your coding agent burn through context window space just to find a function definition. Maybe you've pasted entire files into a prompt when you only needed one class. Semantic code search tools exist, but many of them are heavy, slow to set up, or require you to configure an entire pipeline before you get a single useful result. CocoIndex Code takes a different approach: it uses AST-based parsing to index your codebase, and it claims to save 70% of tokens in the process. It's a lightweight semantic search tool built on top of CocoIndex, a Rust-based data transformation engine.

What It Does

CocoIndex Code is a semantic code search tool that indexes your codebase using Abstract Syntax Tree (AST) parsing. Instead of treating your code as plain text and running it through a generic embedding model, it understands the structural boundaries of your code—functions, classes, modules—and indexes those units semantically. The result is a search tool that returns relevant code chunks rather than entire files.

It's built on CocoIndex, which the README describes as a "Rust-based ultra performant data transformation engine." That means the heavy lifting of indexing and transforming your code happens in Rust, while the interface you interact with is a Python package installed via pipx or uv.

You can use it in three ways: from the command line, as a Skill for coding agents like Claude and Codex, or via an MCP server for tools like Cursor. The README mentions a single plugin marketplace that works with both Claude Code and Grok using the same plugin ID and the same ccc skill. If you're already using a coding agent, the integration path is straightforward.

Why It's Cool

The token savings are real and practical. When your coding agent searches for code, it typically retrieves whole files or large chunks that include irrelevant imports, comments, and unrelated functions. By indexing at the AST level, CocoIndex Code can return just the function or class you need. The README claims 70% token savings, and given how AST-based chunking works, that number is plausible. Fewer tokens means lower costs and more room in the context window for actual reasoning.

Setup is genuinely minimal. The README promises "1 min setup — install and go, zero config needed." You install it, run ccc init, and you're done. There's no YAML file to write, no embedding pipeline to configure, no vector database to spin up manually. The interactive prompt defaults to a local embedding model (Snowflake/snowflake-arctic-embed-xs), so you don't even need an API key if you install the full version.

Two install flavors for different constraints. The cocoindex-code[full] package includes sentence-transformers for local embeddings—no API key required, but it pulls in about 1 GB of torch and transformers dependencies. The slim version (cocoindex-code) is LiteLLM-only and requires a cloud embedding provider with an API key. That's a thoughtful split. If you're on a machine with limited disk space or you already have a cloud embedding provider you like, you can skip the heavy local dependencies.

Works with the tools you already use. The integration story is well thought out. Whether you're using Claude Code, Codex, Cursor, Grok, or something else, there's a path to wire it up. The Skill approach and the MCP server approach cover the major agent frameworks. You're not locked into a single ecosystem.

Built on a real engine. CocoIndex isn't a toy. It's a Rust-based data transformation engine with its own documentation, CI pipeline, and active development. Using it as the foundation means the indexing and search performance should be solid, even on larger codebases. The README links to the CocoIndex repository and documentation, so you can dig into the underlying engine if you want to understand how it works under the hood.

How to Try It

Getting started is a two-step process: install the tool, then wire it into your coding agent or use it directly from the CLI.

  1. Install using pipx (recommended for isolation):
pipx install 'cocoindex-code[full]'

Or using uv:

uv tool install --upgrade 'cocoindex-code[full]'

The [full] extra includes local embeddings, so you don't need an API key. If you'd rather use a cloud embedding provider, install the slim version instead: pipx install cocoindex-code.

  1. Run the initialization:
ccc init

This sets up the index and defaults to the Snowflake Arctic embedding model. From there, you can either use the CLI directly or set up the coding agent integration.

  1. For coding agent integration, the README points to a Skill and an MCP server. The repository includes a .claude-plugin/marketplace.json file that works with both Claude Code and Grok. If you're using Cursor or another MCP-compatible tool, you'll want to configure the MCP server.

The repository is at github.com/cocoindex-io/cocoindex-code. The README is concise but covers the essentials. If you want more detail on the underlying engine, check out the CocoIndex documentation.

Final Thoughts

CocoIndex Code is a focused tool that solves a specific problem: semantic code search that doesn't waste tokens and doesn't require a weekend of setup. It's best suited for developers who are already using coding agents and want to reduce token costs or improve retrieval quality. The AST-based approach is the right call for code—plain text embeddings miss too much structure. The main trade-off is the local embedding dependency in the full install; if you're tight on disk space, the slim version with a cloud provider is a reasonable alternative. If you've been looking for a semantic search tool that integrates cleanly with your existing agent workflow, this one is worth a look.

Back to Projects
Project ID: e69c8567-811f-4e6b-bfd7-d16158c94774Last updated: October 6, 2026 at 02:47 AM