Claude-skill-registry chroma-client
ChromaDB vector database client for storing and retrieving text embeddings with hybrid search (dense + sparse). Use for RAG operations, contextual retrieval, and similarity search in clinical notes.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/chroma-client" ~/.claude/skills/majiayu000-claude-skill-registry-chroma-client && rm -rf "$T"
manifest:
skills/data/chroma-client/SKILL.mdsource content
ChromaDB Client Skill
Overview
This skill provides a Python wrapper for ChromaDB's REST API, enabling vector storage and hybrid search capabilities. It supports automatic embedding generation and BM25-based sparse retrieval for improved citation accuracy.
When to Use
Use this skill when you need to:
- Store clinical note chunks as vector embeddings
- Query for semantically similar text passages
- Implement RAG (Retrieval-Augmented Generation)
- Clear session-based embeddings for privacy compliance
- Perform hybrid search (embedding similarity + keyword matching)
Installation
IMPORTANT: This skill has its own isolated virtual environment (
.venv) managed by uv. Do NOT use system Python.
Initialize the skill's environment:
# From the skill directory cd .agent/skills/chroma-client uv sync # Creates .venv and installs dependencies from pyproject.toml
Dependencies are in
pyproject.toml:
- Vector database clientchromadb
Usage
CRITICAL: Always use
uv run to execute code with this skill's .venv, NOT system Python.
Initialize Client
# From .agent/skills/chroma-client/ directory # Run with: uv run python -c "..." from chroma_client import ChromaClient # Initialize (uses CHROMA_HOST env var by default) client = ChromaClient( host="localhost", # Default from CHROMA_HOST port=8000 # Default port )
Create Collection
# Create or get existing collection collection = client.create_collection( collection_name="clinical_note_session_123", metadata={"session_id": "123", "note_type": "cardiology"} )
Add Chunks with Auto-Embedding
# Chunks are automatically embedded by ChromaDB chunks = [ "Patient presents with chest pain radiating to left arm...", "History of hypertension for 10 years...", "Physical exam reveals elevated BP 150/95..." ] client.add_chunks( collection_name="clinical_note_session_123", chunks=chunks, metadatas=[ {"start_offset": 0, "end_offset": 60}, {"start_offset": 60, "end_offset": 110}, {"start_offset": 110, "end_offset": 165} ], ids=["chunk_0", "chunk_1", "chunk_2"] # Optional, auto-generated if None )
Query with Hybrid Search
# Semantic search with embedding similarity results = client.query( collection_name="clinical_note_session_123", query_text="cardiovascular symptoms", n_results=5, where={"note_type": "cardiology"} # Optional metadata filter ) # Access results for doc, metadata, distance in zip( results["documents"], results["metadatas"], results["distances"] ): print(f"Document: {doc}") print(f"Offset: {metadata['start_offset']}-{metadata['end_offset']}") print(f"Distance: {distance}")
Session Cleanup (Privacy)
# Clear collection after processing (HIPAA compliance) client.clear_collection("clinical_note_session_123")
Health Check
if client.check_health(): print("ChromaDB server is healthy") else: print("ChromaDB server unavailable")
Configuration
Environment Variables:
: Server URL (default:CHROMA_HOST
)http://localhost:8000
Parameters:
: Unique identifier for the collectioncollection_name
: Number of results to return (default: 5)n_results
: Metadata filter dictionary (optional)where
Best Practices
- Session-Based Collections: Use unique collection names per session (e.g.,
)note_session_{uuid} - Always Clear: Delete collections after processing to prevent PHI persistence
- Metadata Tracking: Store offsets in metadata for citation extraction
- Contextual Enrichment: Add context to chunks before embedding (see
skill)contextual-chunking - Health Checks: Verify ChromaDB availability before critical operations
Integration with RAG Pipeline
Typical workflow:
- Chunking: Use
skill to prepare chunkscontextual-chunking - Embedding: Use this skill to store chunks with auto-embedding
- Retrieval: Query for relevant chunks during summarization
- Citation: Use
skill to validate alignmentscitation-extraction - Cleanup: Clear collection when session ends
Error Handling
- Collections that don't exist are created automatically
- Delete operations on non-existent collections are safely ignored
- All errors from ChromaDB API are propagated with context
Implementation
See
chroma_client.py for the full Python implementation.