agentleFS
cocoindex-iococoindex-io/cocoindex-code/CLAUDE.md

cocoindex-code

CLAUDE.md2.7k starsChanged 8 months agoApache-2.0View on GitHub

This is an AST-based semantic code search tool built on top of CocoIndex v1. This project uses uv for project management. Docker E2E tests are excluded by default (need pytest -m docker_e2e to run them). The tool runs as a long-lived background daemon (daemon.py) that accepts connections over a Unix socket (Windows: named pipe). The ccc CLI and MCP server communicate with it via short-lived per-request connections (client.py): connect → handshake → send one request → receive response(s) → close.

Trending

More talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 2 mentionsMar 2026: 5 mentionsApr 2026: 1 mentionMay 2026: 1 mentionJun 2026: 1 mentionJul 2026: 0 mentionsAug 2026: 2 mentionsSep 2026: 3 mentionsOct 2026: 2 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the cocoindex-io/cocoindex-code repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about cocoindex-io/cocoindex-code

The biggest 5 of 17 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 17

Talked about on GitHub, Bluesky and Hacker News (17 times).

On GitHub · 14

9 more on GitHub

On Bluesky · 2

On Hacker News · 1

  • In this repositoryOne other file it gives its agents.

The file

We split this CLAUDE.md into the rules it gives an agent

6 rules. About 0 are common, 3 are distinctive, and 3 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.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use __all__ to explicitly list public exports

    line 78
  2. Very specific:

    Only prefix symbols that are truly private to the module itself (e.g.

    line 89
  3. Very specific:

    Specific types over Any: When a value enters as a weaker form (str, Any), convert to the strong type at the earliest point.

    line 94
  4. Distinctive:

    Single source of truth: When the same value or logic appears in multiple places, consolidate it.

    line 96
  5. Distinctive:

    Delete dead code and dead config: When a change makes something unreachable, the code, the tests, and the knobs all go.

    line 97
  6. Distinctive:

    When tests fail, fix the underlying issue.

    line 104

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

This is an AST-based semantic code search tool built on top of CocoIndex v1.

Build and Test Commands

This project uses uv for project management.

uv sync                                # Install all dev dependencies
uv run pytest tests/                   # Run all tests
uv run pytest tests/test_settings.py  # Run a single test file
uv run pytest tests/ -k test_name     # Run tests matching a name
uv run mypy .                          # Type check Python code
uv run ruff check .                    # Lint
uv run ruff format .                   # Format
uv run prek run --all-files            # Full CI suite (lint, format, mypy, pytest)

Docker E2E tests are excluded by default (need pytest -m docker_e2e to run them).

Architecture

Process Model

The tool runs as a long-lived background daemon (daemon.py) that accepts connections over a Unix socket (Windows: named pipe). The ccc CLI and MCP server communicate with it via short-lived per-request connections (client.py): connect → handshake → send one request → receive response(s) → close.

The daemon is auto-started by client.py when not running. It is restarted automatically when the global_settings.yml mtime changes (version bump or settings edit), detected via the HandshakeResponse.global_settings_mtime_us field.

The daemon idle-exits after daemon.idle_timeout_minutes (default 180, 0 = never) without client activity. A live MCP session sends heartbeats by default; users can set daemon.keep_alive_with_mcp: false to allow idle exit during a connected session. Clients transparently restart the daemon on the next real request. Graceful exits leave a last_exit marker file so the client can tell an expected exit from a crash (which triggers a loud restart, capped after consecutive crashes).

Key Layers

protocol.py — All IPC message types as msgspec.Struct tagged unions, serialized as msgpack. Every request type, response type, and streaming wrapper lives here. The Request and Response type aliases are the union types used by the decoder.

daemon.py — The daemon entry point (run_daemon()). Holds a ProjectRegistry that lazily creates and caches Project instances keyed by project root. Each connection is handled by handle_connection() running as an asyncio task. Dispatches to project operations or daemon-level operations (_dispatch()).

project.py — Project wraps a CocoIndex Environment + App. Manages an asyncio.Lock so only one indexing run is active at a time, and an asyncio.Event so search can wait for the initial index pass.

indexer.py — Defines the CocoIndex app (process_file): reads files from LocalFS, detects language, applies custom chunkers or the default RecursiveSplitter, embeds chunks, and stores them in SQLite via sqlite-vec. This is the @coco.fn(memo=True) function that CocoIndex tracks for incremental re-indexing.

shared.py — CocoIndex ContextKey definitions (EMBEDDER, SQLITE_DB, CODEBASE_DIR, INDEXING_EMBED_PARAMS, QUERY_EMBED_PARAMS), the CodeChunk dataclass (SQLite schema), and the create_embedder() factory.

settings.py — YAML config loading for both global (~/.cocoindex_code/global_settings.yml) and per-project (.cocoindex_code/settings.yml) settings. Also provides all path helpers (cocoindex_db_path, target_sqlite_db_path, resolve_db_dir, etc.) and host-path-mapping logic for Docker.

server.py — MCPServer wrapper that delegates search calls to the daemon client. Also contains the legacy main() entry point (cocoindex-code command) for backward-compatible env-var-based configuration.

cli.py — Typer app with ccc subcommands (init, index, search, grep, status, reset, doctor, mcp, version, daemon status/restart/stop). CLI logic only — delegates to client.py or grep.py.

grep.py — Structural code search (ccc grep) using CocoIndex's code_match. Runs entirely locally with no daemon or index. Matches in parallel, streams results per file.

chunking.py — Public Chunk type and the CHUNKER_REGISTRY context key. Custom chunkers in settings.yml are resolved at daemon startup and injected via this context.

Embedding Model Flow

The embedder is created once at daemon startup (create_embedder() in shared.py) and stored in the ProjectRegistry. Two param dicts (indexing_params, query_params) are threaded through CocoIndex context keys so asymmetric models (Cohere, Voyage, nomic-embed) can use different kwargs for document vs. query embedding.

Two install flavors: [full] bundles sentence-transformers (local inference); slim uses only LiteLLM (cloud APIs). The PacedLiteLLMEmbedder in litellm_embedder.py adds rate-limiting between requests.

Settings and Project Discovery

find_project_root() walks up from CWD looking for .cocoindex_code/settings.yml. Global settings at ~/.cocoindex_code/global_settings.yml (location overridable via COCOINDEX_CODE_DIR). The COCOINDEX_CODE_DB_PATH_MAPPING env var redirects database files to a different directory (used in Docker to avoid LMDB on bind mounts).

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
  • Exception: TYPE_CHECKING imports for type hints don't need prefixing

Internal modules (e.g. cocoindex/_internal/component_ctx.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_var for a module-private ContextVar)

General principles

  • 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. When a value enters as a weaker form (str, Any), convert to the strong type at the earliest point. Don't propagate the weak form.
  • NamedTuple/small dataclass for multi-value returns. Access fields by name at call sites.
  • Single source of truth. When the same value or logic appears in multiple places, consolidate it.
  • Delete dead code and dead config. When a change makes something unreachable, the code, the tests, and the knobs all go.
  • Honest names. The name describes what the code 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.

When tests fail, fix the underlying issue. Don't skip, ignore, or exclude to get a green result.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.