Incremental engine for long horizon agents π Star if you like it!
AGENTS.md β CocoIndex examples
Guidance for AI coding agents (Claude Code, Cursor, etc.) working in this examples/
directory. Most top-level Python subfolders are self-contained, runnable
CocoIndex v1 apps; rust/ contains Rust ports with per-example READMEs.
Before you write CocoIndex code: install the skill
CocoIndex v1 is a fundamental redesign from v0. Without context, LLMs tend to hallucinate the v0 flow-builder DSL and deprecated decorators. Install the official skill first β it teaches the correct v1 API. Quickest portable path for Codex and other Agent Skills-compatible clients is the hosted skill:
mkdir -p .agents/skills/cocoindex/references
curl -fsSL https://cocoindex.io/docs/skill.md -o .agents/skills/cocoindex/SKILL.md
for f in api_reference connectors patterns setup_database setup_project; do
curl -fsSL https://cocoindex.io/docs/references/$f.md -o .agents/skills/cocoindex/references/$f.md
done
Or clone the repo and copy the folder:
git clone --depth=1 https://github.com/cocoindex-io/cocoindex.git /tmp/cocoindex-skill
mkdir -p .agents/skills && cp -r /tmp/cocoindex-skill/skills/cocoindex .agents/skills/
For Claude Code's native project path, use .claude/skills/cocoindex instead
of .agents/skills/cocoindex; the skill format is the same.
The skill itself lives at skills/cocoindex/ (SKILL.md +
references/). For Cursor, copy SKILL.md into .cursor/rules/. Full machine-readable
docs: https://cocoindex.io/docs/llms.txt (index) and
https://cocoindex.io/docs/llms-full.txt (everything, including example
walkthroughs). Regular docs pages also have raw Markdown twins by replacing the
trailing slash with .md (e.g.
https://cocoindex.io/docs/programming_guide/core_concepts.md).
The v1 mental model
target_state = transform(source_state). You declare what the target should look
like; the Rust engine keeps it in sync, reprocessing only what changed (state is
tracked in a local LMDB store β no database is required for the engine itself,
only when an example writes to one). Key APIs: @coco.fn, mount / use_mount /
mount_each, ContextKey, target-state declarations. See the skill for details.
Running examples
Most Python examples are standalone projects with their own pyproject.toml:
cd <example_dir>
cp .env.example .env # if present β fill in the blanks (see below)
pip install -e . # or: uv pip install -e .
cocoindex update main # catch-up: scan sources, sync, exit
cocoindex update -L main # live mode: catch up, then watch for changes (where supported)
Use the example's README as the source of truth. Known exceptions:
multi_codebase_summarization,audio_to_text,patient_intake_extraction_baml,patient_intake_extraction_dspy:cocoindex update main.pyconversation_to_knowledge:cocoindex update conv_knowledge.appimage_search,image_search_colpali: start the API withpython -m uvicorn api:app --reload --host 0.0.0.0 --port 8000; it runs the CocoIndex app in live mode, then start the frontend fromfrontend/.csv_to_kafka,kafka_to_lancedb:cocoindex update -L main.pyrust/<example>: follow that example's README. Many usecargo run -- indexfor indexing andcargo run -- query "..."for search; a few take custom paths or service-specific subcommands.
Some examples expose a query/CLI demo via python main.py "<query>"; check the
example's README.md. Examples that need extra services or a code-gen step
(e.g. baml generate) say so in their README.
Environment / credentials
When an example needs credentials or service configuration, required env vars
are templated in that example's .env.example β cp it to .env and fill
in the blanks; both python main.py and the cocoindex CLI load .env
automatically. Common ones:
POSTGRES_URLβ for Postgres/pgvector targets. Local instance:docker compose -f ../../dev/postgres.yaml up -dfrom inside an example directory.OPENAI_API_KEY/GEMINI_API_KEYβ for examples that call an LLM.- Service-specific (
QDRANT_URL,LANCEDB_URI,NEO4J_*,KAFKA_*,GOOGLE_SERVICE_ACCOUNT_CREDENTIAL, β¦) β see that example's.env.example.
Examples with no .env.example (e.g. files_transform, pdf_to_markdown) run
fully locally with no credentials.
Never commit secrets. The .env files tracked in this repo hold only
non-secret defaults (COCOINDEX_DB, local service URLs); keep API keys and
credentials in your local .env edits and out of commits.
The examples
A walkthrough URL means there's a step-by-step guide at
https://cocoindex.io/docs/examples/<slug>/; otherwise start from the example's README.
Vector indexes (embed β store β search by meaning)
text_embeddingβ Markdown β pgvector; the simplest end-to-end index. (walkthrough: text-embedding)code_embeddingβ repo β Tree-sitter chunks β pgvector; query code in English. (walkthrough: index-codebase)text_embedding_qdrant/text_embedding_lancedb/text_embedding_turbopufferβ same flow, different vector store.code_embedding_lancedbβ code chunks β LanceDB.pdf_embeddingβ PDFs β markdown β chunks β pgvector.paper_metadataβ extract title/authors/abstract from PDFs β Postgres + embeddings.amazon_s3_embedding/gdrive_text_embedding/oci_object_storage_embeddingβ same flow, remote source (S3 / Google Drive / OCI).discord_text_embeddingβ Discord forum posts and messages β chunks β pgvector, with a script that seeds a forum.postgres_sourceβ read from an existing Postgres table as the source.entire_session_searchβ semantic search over AI coding sessions captured by Entire.sec_edgar_analyticsβ multi-format SEC filings β Apache Doris with a vector and a full-text index; hybrid (semantic + keyword) RRF search. (walkthrough: sec-edgar-analytics)
Multimodal
image_searchβ CLIP embeddings + Qdrant, queried via FastAPI + React.image_search_colpaliβ ColPali multi-vector model + Qdrant MaxSim.pdf_elements_embeddingβ PDF pages β text chunks (MiniLM) + images (CLIP) β two Qdrant collections; one query searches both.multi_format_indexingβ PDFs + images as page screenshots β ColPali β Qdrant; no OCR, no chunking. (walkthrough: multi-format-indexing)face_recognitionβ detect faces (dlib) β 128-d embeddings β Qdrant face search. (walkthrough: face-recognition)audio_to_textβ transcribe audio with LiteLLM β Postgres.slides_to_speechβ slides β vision-LLM notes β Pocket TTS narration β LanceDB semantic search. (walkthrough: slides-to-speech)
Structured extraction (LLM / BAML / DSPy)
multi_codebase_summarizationβ LLM per-file summaries across many repos. (walkthrough: multi-codebase-summarization)hn_trending_topicsβ scrape HackerNews β LLM topic extraction β Postgres.manuals_llm_extractionβ PDF manuals β Markdown (docling) β typed module records β Postgres. (walkthrough: manuals-llm-extraction)patient_intake_extraction_baml/patient_intake_extraction_dspyβ structured PDF extraction with BAML / DSPy (Gemini vision).discord_support_faqβ Discord support threads β LLM question and answer β entity resolution merges repeats βFAQ.md, a knowledge base for an agent that stays current, with a script that seeds a forum.
Knowledge graphs
conversation_to_knowledgeβ YouTube podcasts β SurrealDB knowledge graph. (walkthrough: podcast-to-knowledge-graph)docs_to_knowledge_graphβ Markdown docs β Neo4j concept graph of LLM-extracted triples. (walkthrough: docs-to-knowledge-graph)product_recommendationβ product catalog β LLM taxonomy extraction β Neo4j recommendation graph. (walkthrough: product-recommendation)meeting_notes_graph_neo4j/meeting_notes_graph_falkordbβ Google Drive meeting notes β Neo4j / FalkorDB graph.meeting_notes_graph_surrealdbβ local Markdown meeting notes β SurrealDB graph.
Custom sources / targets / streaming
pdf_to_markdownβ incremental PDF β Markdown with docling (local, no services). (walkthrough: pdf-to-markdown)files_transformβ watch Markdown files β HTML, live mode (local, no services).csv_to_kafkaβ watch CSVs β publish rows to Kafka.kafka_to_lancedbβ consume Kafka β route to LanceDB tables.
Rust
rust/β Rust ports of many of the above, using the CocoIndex Rust API.
Conventions for edits
- Keep each Python example self-contained: its own
pyproject.tomlandREADME.md; add.env.examplewhen credentials or configurable services are required. When you add an example, also add a line toEXAMPLE_CATALOGin the docs repo (docs/src/data/examples.ts) so it appears in/docs/llms.txt. - Match the surrounding code's low comment density.
- Don't commit generated artifacts (
cocoindex.db,__pycache__, build output) β they're already git-ignored.