cocoindex
AGENTS.md12k starsChanged 5 months agoApache-2.0View on GitHub
Claude Code compatibility is kept through CLAUDE.md, which imports this file. This project uses uv for Python project management. CI enforces the full pre-commit hook suite from .pre-commit-config.yaml, which covers more than the commands above — notably regenerating the CLI docs (docs/src/content/docs/cli.mdx) whenever cli.py changes. Run it locally before pushing: After changing a core engine API (rust/core), run cargo check --workspace --all-targets to catch call sites in every workspace crate — both rust/py and the Rust SDK under rust/sdk/ call…
- Installs packages
Trending
Quiet since July.about the whole repository
Who's talking about cocoindex-io/cocoindex
- @devshorts.in“OSS Highlight of the Week: CocoIndex – the open-source data indexing platform designed for AI applications! …”Bluesky · Mar 29, 2025 · 15 likes
- @badmonster0.bsky.social“CocoIndex - #opensource Real-time data transformation framework for AI. Ultra performant, with incremental …”Bluesky · May 22, 2025 · 14 likes
- A Hacker News story“Show HN: CocoIndex – Open-Source Data framework for AI, built for data freshness”Hacker News · Apr 23, 2025 · 14 points
- @cocoindex.bsky.social“🎉 CocoIndex just hit 1,000 ⭐️ on GitHub! Huge thanks to everyone who starred, forked, contributed, or …”Bluesky · May 6, 2025 · 12 likes
- @badmonster0.bsky.social“CocoIndex - github.com/cocoindex-io... - Build fresh knowledge for AI made to the top 3 in trending github …”Bluesky · Aug 14, 2025 · 10 likes
The biggest 5 of 93 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 93
Talked about on Bluesky, GitHub and Hacker News (93 times).
On Bluesky · 50
- Mar 29, 2025OSS Highlight of the Week: CocoIndex – the open-source data indexing platform designed for AI applications! 🎯 It simplifies RAG pipelines… — @devshorts.in15 likes and reposts
- May 22, 2025CocoIndex - #opensource Real-time data transformation framework for AI. Ultra performant, with incremental processing.… — @badmonster0.bsky.social14 likes and reposts · 1 reply
- May 6, 2025🎉 CocoIndex just hit 1,000 ⭐️ on GitHub! Huge thanks to everyone who starred, forked, contributed, or shared the love! We’re just getting… — @cocoindex.bsky.social12 likes and reposts · 1 reply
- Aug 14, 2025CocoIndex - github.com/cocoindex-io... - Build fresh knowledge for AI made to the top 3 in trending github in #rustlang! 🌟 star if you… — @badmonster0.bsky.social10 likes and reposts
- May 19, 2025Build Real-Time Product Recommendation Engine 👍 with LLM #OpenAI and Graph Database @neo4j.com 🔗 repo: github.com/cocoindex-io... 🔗… — @badmonster0.bsky.social10 likes and reposts
45 more on Bluesky
- Mar 29, 2025CocoIndex is open source under Apache License 2.0. We believe open sourcing CocoIndex will foster innovation, and create a vibrant… — @cocoindex.bsky.social9 likes and reposts · 1 reply
- Aug 12, 2025Multi-dimensional vectors? That’s how AI understands everything — text, images, audio, all at once. We broke it down here.… — @badmonster0.bsky.social8 likes and reposts · 1 reply
- Apr 13, 2025Knowledge graphs made easy 🚀! we added native builtins for Knowledge Graph in CocoIndex - github.com/cocoindex-io..., looking for… — @badmonster0.bsky.social8 likes and reposts · 2 replies
- Dec 6, 2025CocoIndex just hit Rust Trending! 🚀 github.com/cocoindex-io... Simplest way to connect data sources & keep targets fresh for AI… — @cocoindex.bsky.social7 likes and reposts · 1 reply
- Sep 5, 2025🛒 Building + Explaining a real-time product recommendation engine with LLM + Graph DB - #OpenSource 🚀 Tutorial:… — @badmonster0.bsky.social7 likes and reposts
- Aug 5, 2025CocoIndex (github.com/cocoindex-io...) now supports custom targets - make the AI agents to operate on always-current context effortlessly.… — @badmonster0.bsky.social7 likes and reposts
- Jul 13, 2025Context + Reliable LLM e.g., Claude code will be the future of coding agents. Checkout Cocoindex that brings fresh context for reliable… — @badmonster0.bsky.social7 likes and reposts
- Jul 10, 2025📚 Build LLM-ready, metadata-rich indexes from academic papers PDF in minutes. Get started:… — @badmonster0.bsky.social7 likes and reposts · 1 reply
- Jul 4, 2025wow cocoindex got to @github.com trending yesterday in Rust 🦀. But i missed the moment. Anyways, way to go! github.com/cocoindex-io...… — @badmonster0.bsky.social7 likes and reposts · 1 reply
- Jul 3, 2025github.com/cocoindex-io... Prepare data like LEGO. Few lines in Python, powered by Rust 🦀 for ultra performance Appreciate a star for the… — @badmonster0.bsky.social7 likes and reposts
- May 5, 2025992 ⭐️ Thank you! 🙏 Fresh data for AI www.star-history.com#cocoindex-io... github.com/cocoindex-io/cocoindex #starhistory #GitHub… — @badmonster0.bsky.social7 likes and reposts
- May 1, 2025Great data frameworks needs to be open sourced 🌟 #opensource github.com/cocoindex-io... #buildinpublic — @cocoindex.bsky.social7 likes and reposts · 1 reply
- Apr 20, 2025Speaking of consistent :) Just crossed 600 ⭐ today. Taking a break to celebrate ❤️ github.com/cocoindex-io... @cocoindex.bsky.social… — @badmonster0.bsky.social7 likes and reposts · 1 reply
- Jun 26, 2025🚀 Introducing CocoInsight - Make your AI data pipeline exceptionally easy to understand — step-by-step. 🌟Works with CocoIndex:… — @badmonster0.bsky.social6 likes and reposts
- Jun 1, 2025Tired of clunky ETL pipelines and stale data? Meet CocoIndex—the ultra-performant, open-source framework built in Rust for real-time data… — @cocoindex.bsky.social6 likes and reposts · 1 reply
- May 4, 2025built a real-time knowledge graph from docs using CocoIndex — extracts relationships + entity mentions with LLMs clean setup, incremental… — @badmonster0.bsky.social6 likes and reposts
- May 2, 2025The core engine of CocoIndex is written in #Rust. It is our first choice on the #OpenSource project for the data framework because of 1)… — @cocoindex.bsky.social6 likes and reposts
- Apr 19, 2025Make something people want (and cute;) ! Cute and mighty addition to the community - github.com/cocoindex-io... We are constantly… — @badmonster0.bsky.social6 likes and reposts
- Apr 6, 2025CocoIndex - Open source ETL to transform data for AI; with realtime incremental updates for low latency between source and index updates.… — @cocoindex.bsky.social6 likes and reposts
- Jul 7, 2025CocoIndex Crossed 2k stars last week with one day on Github Trending in Rust 🦀 . Thank you everyone who contributed, starred the repo and… — @badmonster0.bsky.social5 likes and reposts · 1 reply
- Jun 9, 2025🚀 Build Real-Time #Codebase Indexing for LLMs with Tree-sitter for coding agents. ~100 lines of Python get started: 🔗… — @badmonster0.bsky.social5 likes and reposts · 1 reply
- May 30, 2025🚀 Just launched: CocoIndex now supports real-time incremental processing from #AmazonS3 with #AmazonSQS. If your AI agent needs fresh data… — @badmonster0.bsky.social5 likes and reposts · 1 reply
- Dec 1, 2025github.com/cocoindex-io... — @badmonster0.bsky.social4 likes and reposts
- Jul 10, 2025What you get: ✅ LLM-extracted title, authors, abstract ✅ Embeddings for smart search ✅ Build 3 tables in one shot: metadata, author→paper,… — @badmonster0.bsky.social4 likes and reposts
- Jul 6, 2025github.com/cocoindex-io... Transform data for AI got to @github.com Rust Trending this week 🚀! @github-trending.bsky.social #rustlang… — @badmonster0.bsky.social4 likes and reposts
- Jul 5, 2025build code index for your coding agents ~ in 10 min cocoindex.io/blogs/index-... appreciate a star on my repo: github.com/cocoindex-io...… — @badmonster0.bsky.social4 likes and reposts · 1 reply
- Jul 1, 2025CocoIndex - super simple etl to prepare data for ai agents, with dynamic index - cross 2k Github stars today. github.com/cocoindex-io...… — @badmonster0.bsky.social4 likes and reposts · 1 reply
- Jun 23, 2025🚀 CocoIndex now officially supports LiteLLM. You can now plug any LiteLLM-supported model directly into your Coco AI data pipelines —… — @badmonster0.bsky.social4 likes and reposts
- May 30, 2025Prototype: "Does it work?" Production: "Will it keep working?" CocoIndex is built for production from day 0 — no hacks, no hand-waving.… — @cocoindex.bsky.socialsays it tested it4 likes and reposts
- May 25, 2025I've been a big fan of #Rust before I leave my last job. It is my first choice on the #OpenSource project github.com/cocoindex-io... for… — @badmonster0.bsky.social4 likes and reposts
- May 24, 2025CocoIndex is an ultra performant data transformation framework, with its core engine written in Rust. github.com/cocoindex-io... — @badmonster0.bsky.social4 likes and reposts
- May 22, 2025Build Real-Time Image Search 🔍 with vision model #CLIP by #OpenAI and #VectorDatabase @qdrant.bsky.social 🔗 repo:… — @badmonster0.bsky.social4 likes and reposts · 1 reply
- May 12, 2025github.com/cocoindex-io... — @badmonster0.bsky.social4 likes and reposts · 1 reply
- May 11, 2025CocoIndex - Open-source real-time data framework for AI Open-source real-time data framework for AI, supporting incremental processing and… — @pythonhub.dev4 likes and reposts
- May 1, 2025🚀 CocoIndex @cocoindex.bsky.social now officially supports @supabase.com 🎉! Super impressed by how exceptionally easy and smooth Supabase… — @badmonster0.bsky.social4 likes and reposts · 1 reply
- Apr 1, 2025checkout github.com/cocoindex-io... #buildinpublic #opensource — @cocoindex.bsky.social4 likes and reposts
- Mar 18, 2025We are officially open sourced! 🎉 We are thrilled to announce the open-source release of CocoIndex, the world's first engine that supports… — @cocoindex.bsky.social4 likes and reposts
- Dec 13, 2025🚀 CocoIndex + DSPy: structured extraction from patient intake forms LLMs as typed extractors, not black boxes. Production-ready with… — @cocoindex.bsky.social3 likes and reposts
- Dec 12, 2025🚀 CocoIndex just hit Rust Trending Again! 🦀 Why Rust? ⚡ Speed - C++ speed + memory safety 🔒 Reliability - No GC pauses or segfaults.… — @cocoindex.bsky.social3 likes and reposts
- Dec 8, 2025CocoIndex just hit Rust Trending Again! 🚀 github.com/cocoindex-io... With all the AI agents development, CocoIndex is becoming critical… — @cocoindex.bsky.social3 likes and reposts
- Nov 13, 2025checkout - github.com/cocoindex-io... — @badmonster0.bsky.social3 likes and reposts
- Oct 2, 2025Happy Hacktoberfest! Trick-or-treat 🎃🎃 CocoIndex - github.com/cocoindex-io... - tagged with hacktoberfest and fun issues, and ready to go… — @badmonster0.bsky.social3 likes and reposts
- Aug 10, 2025Effortless code context for AI - Star github.com/cocoindex-io... if you like it! link to full write up cocoindex.io/blogs/index-... — @badmonster0.bsky.social3 likes and reposts · 1 reply
- Jul 25, 2025Indexing Faces for Scalable Visual Search 🚀 Build your own Google‑style photo finder in minutes with face detection, embeddings and Qdrant… — @badmonster0.bsky.social3 likes and reposts · 1 reply
- Jul 11, 2025Build real-time knowledge graph from documents with LLM youtu.be/2KVkpUGRtnk?... Checkout - github.com/cocoindex-io... #OpenSource #Dev… — @badmonster0.bsky.social3 likes and reposts
On GitHub · 35
- Jul 10, 2026Add slides-to-speech blog proposal — cocoindex-io/blog-proposal4 reactions
- Jun 29, 2026`CocoIndex x Zvec` blog proposal — cocoindex-io/blog-proposal1 reaction · 2 comments
- Mar 23, 2026[upstream-sync] Rename prev_possible_states to prev_possible_records in TargetHandler::reconcile() (upstream PR #1783) — knitli/recoco1 reaction · 5 comments
- Mar 19, 2026[upstream-sync] Expose progress watching API for App/execution engine (upstream PR #1767) — knitli/recoco1 reaction · 2 comments
- Mar 16, 2026[upstream-sync] LocalFile source: ignore errors and warn in list() for resilient directory listing (upstream PR #1753) — knitli/recoco1 reaction · 2 comments
30 more on GitHub
- Mar 16, 2026[upstream-sync] ops_text module refactor: move output_positions and split elements (upstream PRs #1751, #1752) — knitli/recoco1 reaction · 2 comments
- Mar 16, 2026[upstream-sync] Support attachment providers for target states (upstream PR #1745) — knitli/recoco1 reaction · 2 comments
- Mar 16, 2026[upstream-sync] Expose progress watching API for App/execution engine (upstream PR #1767) — knitli/recoco1 reaction · 5 comments
- Mar 10, 2026[Upstream-Sync] [FEATURE] Add Ladybug target (Kuzu successor) — upstream PR #1487 — knitli/recoco1 reaction · 4 comments
- Mar 10, 2026[Upstream-Sync] Track dependency updates from upstream (not specific to v1.0.0 branch) — knitli/recoco1 reaction · 4 comments
- Mar 9, 2026[upstream-sync] Fix: function memoization must bypass cache when full_reprocess is set — knitli/recoco1 reaction · 3 comments
- Mar 9, 2026[upstream-sync] Batch LMDB write transactions automatically for improved throughput — knitli/recoco1 reaction · 3 comments
- May 25, 2026[upstream-sync] fix(engine): submit parent target states after child readiness (upstream #2014) — knitli/recoco0 reactions
- May 25, 2026[upstream-sync] refactor(state_store): remove ReadTxn from API; standalone reads per call (upstream #2010) — knitli/recoco0 reactions
- May 25, 2026[upstream-sync] fix(engine): scope GC-sweep read transaction to list_tombstones only (upstream #2004) — knitli/recoco0 reactions
- May 25, 2026[upstream-sync] fix(engine): concurrent preempt race + pending_process_token refactor (upstream #1994, #1996) — knitli/recoco0 reactions
- May 25, 2026[upstream-sync] feat(telemetry): add optional application label via env var (upstream #1992) — knitli/recoco0 reactions
- May 25, 2026[upstream-sync] feat(splitter): add Astro tree-sitter language support (upstream #1984) — knitli/recoco0 reactions
- May 18, 2026[upstream-sync] refactor(state_store): LMDB isolation, async I/O, and fn-memo cache series (upstream #1981–#1991) — knitli/recoco0 reactions
- May 11, 2026[upstream-sync] feat(splitters): add Svelte, Vue, and Julia tree-sitter language support (upstream #1937, #1942) — knitli/recoco0 reactions
- May 4, 2026[upstream-sync] security: bump Rust dep versions to clear Dependabot advisories (upstream #1907, #1850) — knitli/recoco0 reactions
- May 4, 2026[upstream-sync] fix(core): cancellation not propagated through tokio spawn boundaries (upstream #1902) — knitli/recoco0 reactions
- Apr 27, 2026[upstream-sync] feat(telemetry): add anonymous usage tracking in Rust core (upstream #1879) — knitli/recoco0 reactions
- Apr 27, 2026[upstream-sync] fix: eagerly register attachment providers for orphaned cleanup (upstream #1844) — knitli/recoco0 reactions
- Apr 13, 2026[upstream-sync] feat: Kafka source/target connectors and LiveMapFeed/LiveMapView protocol split (upstream #1809, #1801) — knitli/recoco0 reactions
- Apr 13, 2026[upstream-sync] fix(progress): elapsed timer freeze and PTY reader hang fixes (upstream #1821, #1822) — knitli/recoco0 reactions
- Apr 6, 2026[upstream-sync] fix: reset version on preempted target state ownership transfer (upstream #1797) — knitli/recoco0 reactions
- Apr 6, 2026[upstream-sync] feat: live_component.rs updates for LiveItemsView mount_each integration (upstream #1799) — knitli/recoco0 reactions
- Apr 6, 2026[upstream-sync] fix: add is_cancelled() to HostError trait for clean shutdown (upstream #1805) — knitli/recoco0 reactions
- Apr 6, 2026[upstream-sync] fix: clean up stale GC tombstone after live component incremental delete (upstream #1808) — knitli/recoco0 reactions
- Mar 30, 2026[upstream-sync] Fix component context plumbing for state/memo functions (upstream PR #1777) — knitli/recoco0 reactions
- Mar 30, 2026[upstream-sync] Add Novita AI as LLM provider (upstream PR #1781) — knitli/recoco0 reactions · 1 comment
- Mar 3, 2026Bump cocoindex from 0.3.33 to 0.3.34 — ryanyen2/semipy-package0 reactions
- Aug 8, 2025Add CocoIndex to LLM Framework — openbestof/awesome-ai0 reactions
- Apr 24, 2025Add cocoindex.md — hilmanski/freeStuffDev0 reactions · 1 comment
On Hacker News · 8
- Apr 23, 2025Show HN: CocoIndex – Open-Source Data framework for AI, built for data freshness14 points · 11 comments
- Mar 20, 2025Show HN: Open-Source Structured Extraction with LLM Using Ollama5 points · 2 comments
- Aug 12, 2025CocoIndex – open-source ETL saves you >90% compute for AI workloadssays it tested it4 points · 1 comment
- Jun 15, 2025Show HN: CocoIndex – Open-Source Data transformation for AI, only process delta4 points · 1 comment
- Mar 9, 2025Show HN: Fresh Data for AI (Open Source)4 points · 1 comment
3 more on Hacker News
- Mar 7, 2025Show HN: Open-Source ETL to index data4 points · 2 comments
- Dec 8, 2025Show HN: CocoIndex – Open-Source Data Engine for Dynamic Context Engineering2 points
- Jun 4, 2025Show HN: CocoIndex – Open-Source Real-time Data transformation framework2 points
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository3 other files it gives its agents.
- examples/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- cocoindexSkill
The file
We split this AGENTS.md into the rules it gives an agent
11 rules. About 0 are common, 3 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 173
When a processing component finishes, CocoIndex compares its declared target states with those from the previous run at the same component …
- Very specific: line 226
Use __all__ to explicitly list public exports
- Very specific: line 237
Only prefix symbols that are truly private to the module itself (e.g.
- Very specific: line 246
Specific types over
Any: Use concrete types — including concrete types from third-party libraries. - Distinctive: line 250
Single source of truth, delete dead code, honest names: When the same value/logic appears in multiple places, consolidate.
- Very specific: line 258
Use common.create_test_env(__file__) to create a CocoIndex Environment for tests.
- Very specific: line 282
Use testcontainers[postgres] (in the build-test dependency group) to spin up real database instances automatically — no manual setup or …
- Very specific: line 300
All LMDB writes must go through Storage::run_txn (uses the single-writer batcher).
- Distinctive: line 301
Do not open a heed write txn directly or wrap the env in a separate mutex/semaphore — bypassing the batcher loses fsync coalescing and …
- Distinctive: line 313
When adding new functionality that involves I/O or concurrency:
- Very specific: line 337
If ccc search reports no index, set it up once:
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
This file provides guidance to coding agents working with code in this repository.
Claude Code compatibility is kept through CLAUDE.md, which imports this file.
Build and Test Commands
This project uses uv for Python project management.
Building
uv run maturin develop # Build Rust code and install Python package (required after Rust changes)Testing
cargo test # Run Rust tests
uv run mypy # Type check Python code
uv run pytest python/ # Run Python tests (use after both Rust and Python changes)Code Formatting and Linting
uv run ruff format . # Format Python code
uv run ruff format --check . # Check formatting without making changes (same as CI)
uv run ruff check . # Lint Python code
cargo fmt # Format Rust codePre-submission Checks
CI enforces the full pre-commit hook suite from .pre-commit-config.yaml, which
covers more than the commands above — notably regenerating the CLI docs
(docs/src/content/docs/cli.mdx) whenever cli.py changes. Run it locally
before pushing:
uv tool install prek # one-time; some hooks also need `protoc` (brew install protobuf)
prek run --all-filesWorkflow Summary
| Change Type | Commands to Run |
| Rust code only | uv run maturin develop && cargo test |
| Python code only | uv run mypy && uv run pytest python/ |
| Both Rust and Python | Run all commands from both categories above |
| Python formatting | uv run ruff format . |
| Before pushing | prek run --all-files |
After changing a core engine API (rust/core), run cargo check --workspace --all-targets to catch call sites in every workspace crate — both rust/py and the Rust SDK under rust/sdk/ call core directly, and the SDK is easy to miss when grepping. The examples/rust/* and benchmarks/*/rust crates are standalone workspaces that consume the SDK; the prek suite's cargo check (rust examples + benchmarks) hook covers those.
Code Structure
cocoindex/
├── rust/ # Rust crates (workspace)
│ ├── core/ # Core engine crate
│ │ └── src/
│ │ ├── engine/ # Core engine
│ │ ├── state/ # States of the core engine
│ │ └── inspect/ # Database inspection utilities
│ ├── py/ # Python bindings (PyO3); calls core engine APIs
│ ├── py_utils/ # Python-Rust utility helpers (error, convert, future)
│ ├── utils/ # General utilities: error, batching, fingerprint, etc.
│ ├── code_ast/ # Tree-sitter foundation: language registry (links all grammars), CodeSource, positions
│ ├── ops_text/ # Text processing operations (splitter, language detection)
│ ├── code_match/ # Structural code pattern matching over tree-sitter ASTs
│ └── sdk/
│ ├── cocoindex/ # Rust SDK (`cocoindex` crate); calls core engine APIs directly, like py/
│ └── cocoindex_macros/ # Proc macros for the Rust SDK (`#[function]`)
│
├── python/
│ ├── cocoindex/ # Python package
│ │ ├── __init__.py # Package entry point
│ │ ├── cli.py # CLI commands
│ │ ├── _internal/ # Internal implementation for the core engine
│ │ │ ├── api.py # Public API: mount, use_mount, mount_each, map, mount_target, App, fn, start/stop
│ │ │ ├── app.py # App base implementation
│ │ │ ├── context_keys.py # ContextKey and ContextProvider
│ │ │ ├── environment.py # Environment and lifespan handling
│ │ │ ├── function.py # @coco.fn decorator implementation
│ │ │ ├── component_ctx.py # ComponentContext and component_subpath
│ │ │ ├── target_state.py # Target state implementation
│ │ │ └── core.pyi # Type stubs for the Rust extension module (update when PyO3 APIs change)
│ │ ├── connectors/ # External system connectors (localfs, postgres, qdrant, lancedb, google_drive)
│ │ ├── connectorkits/ # Connector building utilities
│ │ ├── resources/ # Abstractions: file.py (FileLike), chunk.py (Chunk), schema.py
│ │ └── ops/ # Operations: text.py (RecursiveSplitter), sentence_transformers.py
│ └── tests/ # Python tests
│
├── examples/ # Example applications
├── docs/ # Documentation
└── dev/ # Development utilitiesKey Concepts
Mental model: declarative data pipelines
CocoIndex uses a declarative programming model — you specify what your output should look like (target states), not how to incrementally update it. The engine handles change detection and applies minimal updates automatically.
Think of it like:
- React: declare UI as function of state → React re-renders what changed
- Spreadsheets: declare formulas → cells recompute when inputs change
- CocoIndex: declare target states as function of source → engine syncs what changed
Core concepts
App — The top-level runnable unit. Bundles a main function with its arguments. When you call app.update(), the main function runs as the root processing component.
Processing Component — The unit of execution that owns a set of target states. Created by mount() or use_mount() at a specific component path. When a component finishes, its target states sync atomically to external systems.
Component Path — Stable identifier for a processing component across runs. Created via coco.component_subpath("process", filename). CocoIndex uses component paths to:
- Match components to their previous runs for change detection
- Determine ownership of target states (if a path disappears, its target states are cleaned up)
Target State — What you want to exist in an external system (a file, a database row, a table). You declare target states; CocoIndex keeps them in sync — creating, updating, or removing as needed.
Target — The API object used to declare target states (e.g., DirTarget, TableTarget). Targets can be nested: a container target state (directory/table) provides a Target for declaring child target states (files/rows).
Function — A Python function decorated with @coco.fn. Use memo=True to enable memoization (skip execution when inputs and code are unchanged).
Context — React-style provider mechanism for sharing resources. Define keys with ContextKey[T], provide values in lifespan via builder.provide(), use in functions via coco.use_context(key).
Key APIs
# Mounting processing components (subpath auto-derived from fn.__name__)
await coco.mount(fn, *args, **kw) # child runs independently
result = await coco.use_mount(fn, *args, **kw) # returns value directly
# Explicit subpath (for multi-part paths or multiple mounts of same function)
await coco.mount(coco.component_subpath("process", filename), fn, *args, **kw)
result = await coco.use_mount(coco.component_subpath("name"), fn, *args, **kw)
# Component subpath composition
subpath = coco.component_subpath("process", filename) # multiple parts
subpath = coco.component_subpath("a") / "b" / "c" # chaining with /
# Using component_subpath as context manager (applies to all nested mount calls)
with coco.component_subpath("process"):
for f in files:
await coco.mount(coco.component_subpath(str(f.relative_path)), process_file, f, target)
# Declaring target states (typically via Target methods)
dir_target.declare_file(filename=name, content=data)
table_target.declare_row(row=MyRow(...))
# Using context values
db = coco.use_context(PG_DB) # retrieve value provided in lifespan
# Explicit context management (for ThreadPoolExecutor)
ctx = coco.get_component_context()
with ctx.attach():
# coco APIs work correctly in this thread
coco.mount(...)Mount handles:
mount()→ComponentMountHandle: callawait handle.ready()to wait until target states are synceduse_mount()→ returns the result value directly (awaitable)
How syncing works
When a processing component finishes, CocoIndex compares its declared target states with those from the previous run at the same component path:
- New target states → create (insert row, create file)
- Changed target states → update
- Missing target states → delete
Changes are applied atomically per component. If a source item is deleted (path no longer mounted), all its target states are cleaned up automatically.
Example
import pathlib
import cocoindex as coco
from cocoindex.connectors import localfs
from cocoindex.resources.file import FileLike, PatternFilePathMatcher
@coco.fn(memo=True)
async def process_file(file: FileLike, target: localfs.DirTarget) -> None:
html = _markdown_it.render(await file.read_text())
outname = "__".join(file.file_path.path.parts) + ".html"
target.declare_file(filename=outname, content=html)
@coco.fn
async def app_main(sourcedir: pathlib.Path, outdir: pathlib.Path) -> None:
target = await coco.use_mount(localfs.declare_dir_target, outdir)
files = localfs.walk_dir(
sourcedir,
recursive=True,
path_matcher=PatternFilePathMatcher(included_patterns=["**/*.md"]),
)
await coco.mount_each(process_file, files.items(), target)
app = coco.App(
coco.AppConfig(name="FilesTransform"),
app_main,
sourcedir=pathlib.Path("./docs"),
outdir=pathlib.Path("./out"),
)
app.update_blocking(report_to_stdout=True)Code Conventions
Internal vs External Modules
We distinguish between internal modules (under packages with _ prefix, e.g. _internal.* or connectors.*._source) and external modules (which users can directly import).
External modules (user-facing, e.g. cocoindex/ops/sentence_transformers.py):
- Be strict about not leaking implementation details
- Use
__all__to explicitly list public exports - Prefix ALL non-public symbols with
_, including:- Standard library imports:
import threading as _threading,import typing as _typing - Third-party imports:
import numpy as _np,from numpy.typing import NDArray as _NDArray - Internal package imports:
from cocoindex.resources import schema as _schema
- Standard library imports:
- Exception:
TYPE_CHECKINGimports for type hints don't need prefixing
Internal modules (e.g. cocoindex/_internal/component_ctx.py, **/_target.py):
- Less strict since users shouldn't import these directly
- Standard library and internal imports don't need underscore prefix
- Only prefix symbols that are truly private to the module itself (e.g.
_context_varfor a module-private ContextVar)
Minimize API surface until deemed necessary
When adding a new public API (function, class, kwarg, configuration option), prefer the smallest surface that solves the concrete need in front of you. Do not pre-expose tunables, hooks, or alternatives "in case someone needs them." Adding a kwarg later is straightforward and backwards-compatible; removing or renaming one is disruptive. If a knob is currently a hardcoded constant inside the implementation, leave it there until a real use case demands it — at which point promoting it to a kwarg is mechanical. This applies equally to optional parameters, callback hooks, parser/transformer plug-points, and configuration keys.
General principles (also covered by /review-changes)
- Top-level imports. Defer to in-function only for a real circular dependency or a heavy import that isn't always needed.
- Specific types over
Any. Use concrete types — including concrete types from third-party libraries.Anyonly when the type is truly generic and no downstream code needs to downcast it. - Validate and exchange early. When a value enters as a weaker form (
str,Any, raw identifier), convert to the strong type at the earliest point. Don't propagate the weak form. Concrete example in this codebase: connector handlers receive aContextKeystring as part of a target-state key. The parent handler resolves the key once (when constructing the child handler) and passes the typed connection directly — the child stores_pool: asyncpg.Pool, not_db_key: str. NamedTuple/small dataclass for multi-value returns. Access fields by name (result.can_reuse) at call sites.- Exceptions for exceptional situations only. Reserve exceptions (Python) and errors (Rust) for truly unexpected failures — not for end-of-iteration, "not found", or other expected state transitions. Use explicit return values (sentinel, enum variant,
None) for those. - Single source of truth, delete dead code, honest names. When the same value/logic appears in multiple places, consolidate. When changes make code unreachable, delete it (and its tests, and any dead config knobs). Function and field names should describe what the implementation does today.
Testing Guidelines
We prefer end-to-end tests on user-facing APIs, over unit tests on smaller internal functions. With this said, there're cases where unit tests are necessary, e.g. for internal logic with various situations and edge cases, in which case it's usually easier to cover various scenarios with unit tests.
Test Environment Setup
Use common.create_test_env(__file__) to create a CocoIndex Environment for tests. It derives a unique db_path from the test file path and picks up the current event loop automatically.
Sync tests (module-level creation): Call at module level — the Environment creates a background loop for async callbacks.
coco_env = common.create_test_env(__file__)Async tests with async resources (e.g., asyncpg pools): Call inside an async fixture so the Environment binds to the test's running event loop (same loop the pool is on). Use the
suffixparameter when each test needs its own Environment:@pytest_asyncio.fixture async def pg_env(request: pytest.FixtureRequest) -> Any: pool = await asyncpg.create_pool(dsn) coco_env = common.create_test_env(__file__, suffix=request.node.name) coco_env.context_provider.provide(DB_KEY, pool) yield pool, coco_env await pool.close()The
suffixensures each test gets a uniquedb_path, avoiding "environment already open" errors.
Testcontainers for Database Tests
Use testcontainers[postgres] (in the build-test dependency group) to spin up real database instances automatically — no manual setup or environment variables needed. Use a module-scoped sync fixture for the container and a function-scoped async fixture for per-test resources:
@pytest.fixture(scope="module")
def pg_dsn() -> Any:
with PostgresContainer("postgres:16-alpine") as pg:
dsn = pg.get_connection_url().replace("postgresql+psycopg2://", "postgresql://")
yield dsn
@pytest_asyncio.fixture
async def pool(pg_dsn: str) -> Any:
p = await asyncpg.create_pool(pg_dsn)
yield p
await p.close()LMDB write paths
- All LMDB writes must go through
Storage::run_txn(uses the single-writer batcher). - Do not open a heed write txn directly or wrap the env in a separate mutex/semaphore — bypassing the batcher loses fsync coalescing and regresses concurrent-submit throughput by 10-100×.
- LMDB has no savepoints. If a sub-operation needs to "abort" without failing its caller, handle it at the body level (e.g. return a sentinel result without writing). A body that returns
Errfails only its own caller: the batcher drops its writes by aborting the txn and re-running the bodies ahead of it, so every body must be safe to re-run. - An LMDB write txn must begin and end (commit or abort) on the same OS thread: the writer lock is thread-owned and LMDB ignores a failed release, so a txn that migrates between runtime workers blocks every later writer for good. heed marks
RwTxnasSendregardless, so the compiler won't catch it.Storage::run_txnruns each batch on one blocking thread for this reason; never hold a write txn across an.awaiton the multi-thread runtime.
Sync vs Async
The Rust core (rust/core, rust/utils) uses async-first design with Tokio. The rust/py crate bridges Rust async to Python, offering both sync and async APIs:
- Rust core exposes async functions
rust/pyprovides sync wrappers that useblock_on()to call async Rust from sync Python- Python's
cocoindexAPI is async-first: mount APIs (mount,use_mount,mount_each,map) are allasync def;App.update()/App.drop()are async; sync entry points (App.update_blocking(),App.drop_blocking(),start_blocking(),stop_blocking()) are available for CLI and blocking contexts
When adding new functionality that involves I/O or concurrency:
- Implement async in Rust
- Bridge to Python via
rust/py, providing both sync and async variants if needed
Versioning
The current codebase is for CocoIndex v1, which is a fundamental redesign from CocoIndex v0. CocoIndex v1 lives on the main branch; the legacy v0 code is preserved on the v0 branch.
Docs diagrams
All diagrams embedded in docs pages are built as inline Astro components under docs/src/components/diagrams/, not exported SVG files. See docs/src/components/diagrams/README.md for the palette, primitives, shared CSS classes, animation conventions, and step-by-step authoring guidelines. Follow that guide for any new or updated diagram.
Agent Tooling
Semantic code search over this repo (cocoindex-code)
To find where a concept lives, prefer semantic search over blind grep. This repo keeps a local
cocoindex-code index; query it from any agent's shell with the ccc CLI:
ccc search "where is X handled" # semantic search; add --refresh to reindex firstIf ccc search reports no index, set it up once:
command -v ccc >/dev/null || uv tool install 'cocoindex-code[full]' # per machine; local embeddings, no API key
ccc init -f && ccc index # repo-scoped index (first build ~1-2 min)Everything is local — SQLite index, local embeddings, no keys — and a background daemon keeps it
fresh. On a brand-new machine ccc init asks once for an embedding provider; choose the local
default. The -f matters: if a parent directory is also a ccc project, plain ccc init refuses
and search silently uses the parent's index, so run ccc status to confirm the root is this repo.
We register no MCP server on purpose — an ccc mcp mode exists, but the CLI costs no context until
invoked and behaves the same across agents. Source:
github.com/cocoindex-io/cocoindex-code.
Agent Playbooks
Reusable task-specific agent guidance lives under dev/agent-skills/. These playbooks use a SKILL.md format so Claude Code can load them directly from .claude/skills/, but the content is intended to be readable by any coding agent.
- For docs diagrams, read
dev/agent-skills/cocoindex-diagrams/SKILL.md. - For new target connectors, read
dev/agent-skills/target-connector/SKILL.md. - For upgrading example package versions, read
dev/agent-skills/upgrade-examples/SKILL.md.
Agent Skills-compatible clients, including Codex, discover the checked-in symlinks under .agents/skills/. The public CocoIndex skill is exposed there as cocoindex, and contributor playbooks are exposed there from dev/agent-skills/.
Claude Code compatibility remains under .claude/: hooks/settings live there, and .claude/skills/ mirrors the contributor playbooks with symlinks. Do not duplicate skill content under .agents/skills/ or .claude/skills/; edit the source directories (skills/cocoindex/ for the public skill, dev/agent-skills/ for contributor playbooks) and keep dot-directory entries as symlinks.
Portable agent checks live under dev/agent-checks/. Claude Code hooks in .claude/hooks/ are thin adapters that call these scripts when relevant files changed.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

