Build codebase index. CocoIndex provides built-in support for codebase chunking, with native Tree-sitter support. It works with large codebases, and can be updated in near real-time with incremental processing - only reprocess what's changed.
A wide range of applications can be built with an effective codebase index that is always up-to-date.
- Semantic code context for AI coding agents like Claude, Codex, Gemini CLI.
- MCP for code editors such as Cursor, Windsurf, and VSCode.
- Context-aware code search applications—semantic code search, natural language code retrieval.
- Context for code review agents—AI code review, automated code analysis, code quality checks, pull request summarization.
- Automated code refactoring, large-scale code migration.
- SRE workflows: enable rapid root cause analysis, incident response, and change impact assessment by indexing infrastructure-as-code, deployment scripts, and config files for semantic search and lineage tracking.
- Automatically generate design documentation from code—keep design docs up-to-date.
- We will ingest CocoIndex codebase.
- For each file, perform chunking (Tree-sitter) and then embedding.
- We will save the embeddings and the metadata in Postgres with PGVector.
We will match against user-provided text by a SQL query, reusing the embedding operation in the indexing flow.
Install Postgres if you don't have one.
-
Install dependencies:
pip install -e . -
Update index:
cocoindex update main
-
Run:
python main.py
I used CocoInsight (Free beta now) to troubleshoot the index generation and understand the data lineage of the pipeline. It just connects to your local CocoIndex server, with Zero pipeline data retention. Run the following command to start CocoInsight:
cocoindex server -ci main
Then open the CocoInsight UI at https://cocoindex.io/cocoinsight.
