Skip to main content

hybrid-coco

CI PyPI version PyPI downloads Python License: Apache 2.0 GitHub issues

Local code intelligence for AI agents. Index your codebase once, query it deterministically: ~94% fewer tokens than grep + cat.

hybrid-coco builds a local SQLite index of your source code using tree-sitter, exposes it via a CLI and an MCP server, and integrates with Claude Code via hooks. No embeddings, no vector database, no Docker. One install command.

pip install hybrid-coco && hc init

The problem it solves

When Claude reads a file to find one function, it pays for the entire file:

# Without hybrid-coco
Read("src/gitlab_helpers.py")             >  12,140 tokens  (whole file)

# With hybrid-coco
hc_file_context("src/gitlab_helpers.py")  >  297 tokens  (symbols only)  < 97.6% savings

The hook intercepts Read and Grep calls and suggests the equivalent hc_* tool. Same answer, fraction of the tokens.

How it works

Source files  ──tree-sitter──►  SQLite + FTS5  ──►  CLI (hc)
                                     │
                                     └──────────────►  MCP server (hc_*)
                                                           │
                                                    Claude Code hooks
                                                    intercept Read/Grep
                                                    > suggest hc_* tools
  1. hc index .: parses every source file with tree-sitter, extracts symbols (functions, classes, methods, imports) with their signatures, docstrings, and line numbers into a FTS5 trigram index
  2. hc query / symbol / file-context: queries the index and returns only what's relevant, not the whole file
  3. hc serve: exposes the same queries as MCP tools (hc_search, hc_symbol, hc_file_context, hc_status) for Claude Code
  4. Hooks: hc init registers PreToolUse/PostToolUse hooks that suggest hc_* tools whenever Claude is about to Read or Grep an indexed file

Benchmark

Measured on a real Rust codebase: 76 files, 2,242 symbols:

Query Traditional hybrid-coco Savings
Symbol lookup (TimedExecution) 2,227 tok 51 tok 97.7%
Pattern search (savings) 3,164 tok 334 tok 89.4%
File structure (tracking.rs) 12,140 tok 1,245 tok 89.7%
Schema grep (CREATE TABLE) 92 tok 29 tok 68.5%
File read (git.rs) 16,343 tok 377 tok 97.7%
Total (5 queries) 33,966 tok 2,036 tok ~94%

Traditional = grep -rn + cat. hybrid-coco = hc symbol + hc query + hc file-context.

Quickstart

1. Install

Option A: One-line installer (recommended)

curl -fsSL https://raw.githubusercontent.com/jmeiracorbal/hybrid-coco/main/install.sh | bash

Installs hc, configures Claude Code hooks, and adds the awareness file. Requires Python 3.11+ (detects uv, pipx, or pip automatically).

Option B: Claude Code plugin

claude plugin marketplace add jmeiracorbal/hybrid-coco
claude plugin install hybrid-coco@hybrid-coco

Registers the MCP server and hooks automatically. Requires hc in PATH — install the package first:

pip install hybrid-coco   # or: uv tool install hybrid-coco

2. Index your project and register with Claude Code

cd your-project/
hc init

hc init does three things:

  • Indexes the current directory (tree-sitter, SHA-256 incremental)
  • Registers the MCP server in .claude/settings.json
  • Installs global hooks in ~/.claude/hooks/ that intercept Read and Grep

Restart Claude Code to activate.

3. Use from Claude Code

The MCP tools are now available in every conversation:

hc_search("savings_pct")       # FTS5 search over names, signatures, docstrings
hc_symbol("TimedExecution")    # exact/prefix symbol lookup
hc_file_context("src/git.rs")  # all symbols in a file, structured
hc_status()                    # index stats

The hooks will remind you (via stderr) whenever Claude is about to read an indexed file directly.

CLI reference

hc index [PATH] [--exclude PATTERN]...
                         Index PATH (default: cwd); optional exclude patterns
hc update [PATH] [--exclude PATTERN]...
                         Re-index only changed files (SHA-256 diff)
hc status [PATH]         Index stats: files, symbols by kind, last update
hc query <TEXT>          FTS5 trigram search on name, signature, docstring
hc symbol <NAME>         Exact name lookup, then prefix fallback
hc file-context <PATH>   All symbols in PATH grouped by kind (~97% savings vs cat)
hc serve                 Start MCP server (stdio)
hc init [PATH]           Index + .gitignore entry + register MCP + install hooks

--exclude accepts gitignore-style patterns and may be repeated.

Supported languages

Language Parser
Python tree-sitter-python
Rust tree-sitter-rust
JavaScript tree-sitter-javascript
TypeScript tree-sitter-typescript

Adding a language requires implementing a ~100-line parser in src/hybrid_coco/parsers/.

Design decisions

SQLite + FTS5, not a vector database: deterministic results, zero infrastructure, single file. Trigram search covers partial matches and is fast enough for codebases up to ~100K files. Semantic (embedding) search can be layered on top via sqlite-vec without changing the schema.

tree-sitter, not regex: symbol extraction is grammar-aware. Signatures and docstrings are extracted structurally, not by pattern matching.

No server process: hc serve runs as a stdio MCP server launched on demand by Claude Code. There is no daemon to manage.

Incremental by default: hc update re-indexes only files whose SHA-256 has changed. Full re-index is only needed on first run or after .gitignore changes.

Using with gtk-ai

hybrid-coco and gtk-ai are independent tools that work well together:

  • hybrid-coco: reduces tokens on code navigation (Read, Grep, file structure queries)
  • gtk-ai: reduces tokens on command output (find, ls, git, grep and other Bash tools)

When used together, gtk-ai will by default compress all MCP tool output, including hc_* responses. To prevent that, add hc_ to GTK_MCP_PASSTHROUGH_PATTERNS in the gtk-ai hook script:

# ~/.claude/hooks/gtkai-post-tool-use.sh
export GTK_MCP_PASSTHROUGH_PATTERNS="hc_"

This tells gtk-ai to let hc_search, hc_symbol, hc_file_context, and hc_status responses through uncompressed. hybrid-coco already returns minimal output, so compressing it further would lose information.

Neither tool requires the other. Configure this only if you have both installed.

Relation to CocoIndex

hybrid-coco is inspired by CocoIndex but makes different trade-offs:

CocoIndex hybrid-coco
Search Vector (semantic) FTS5 trigram (lexical)
Backend PostgreSQL + pgvector SQLite (single file)
Infrastructure Docker required Zero
Install Complex `curl ...
Granularity Chunks Symbols (functions, classes)
Target Large-scale RAG Local dev, agent token reduction

Development

git clone https://github.com/jmeiracorbal/hybrid-coco
cd hybrid-coco
uv sync
uv pip install -e .
hc --version

Run tests:

uv run pytest

Run the benchmark against any indexed project:

cd path/to/project && hc index .
python scripts/benchmark.py path/to/project

Metadata

Release files for hybrid-coco 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hybrid-coco 0.1.6
File Size Uploaded Provenance Actions
hybrid_coco-0.1.6.tar.gz 87.9 kB Without provenance Details for hybrid_coco-0.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hybrid-coco 0.1.6
File Interpreter ABI Platform Actions
hybrid_coco-0.1.6-py3-none-any.whl Python 3 none any Details for hybrid_coco-0.1.6-py3-none-any.whl

Total release size: 120.8 kB

Release files / hybrid_coco-0.1.6.tar.gz

Download URL hybrid_coco-0.1.6.tar.gz
Size 87.9 kB
Tags Source
SHA-256 checksum
How to use checksums
43a4d88d9a3b813930fd1c1e3fff99a0d208a0b0c7e43f9bc42357dc7b32896a
BLAKE2b-256 checksum
How to use checksums
7aa7a2108227f7bb9ff2c29890cc40bcd679a5ec5d2fd0e0ae0cf51af4e4fd7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / hybrid_coco-0.1.6-py3-none-any.whl

Download URL hybrid_coco-0.1.6-py3-none-any.whl
Size 32.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d9c3507d16b65dc3babfeeaea0226a2c204b56299b323dd5ac751675e58ff02
BLAKE2b-256 checksum
How to use checksums
cee00b84d6a3de799ae383aac7e4a8395d9680ffd05e331aa0d073fd7b99648d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for hybrid-coco 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page