Basic Usage Example
This example demonstrates the basic usage of Claude Context.
Prerequisites
-
OpenAI API Key: Set your OpenAI API key for embeddings:
export OPENAI_API_KEY="your-openai-api-key" -
Milvus Server: Make sure Milvus server is running:
-
You can also use fully managed Milvus on Zilliz Cloud. In this case, set the
MILVUS_ADDRESSas the Public Endpoint andMILVUS_TOKENas the Token like this:export MILVUS_ADDRESS="https://your-cluster.zillizcloud.com" export MILVUS_TOKEN="your-zilliz-token" -
You can also set up a Milvus server on Docker or Kubernetes. In this setup, please use the server address and port as your
uri, e.g.http://localhost:19530. If you enable the authentication feature on Milvus, set thetokenas"<your_username>:<your_password>", otherwise there is no need to set the token.export MILVUS_ADDRESS="http://localhost:19530" export MILVUS_TOKEN="<your_username>:<your_password>"
Running the Example
-
Install dependencies:
pnpm install -
Set environment variables (see examples above)
-
Run the example:
pnpm run start
What This Example Does
- Indexes Codebase: Indexes the entire Claude Context project
- Performs Searches: Executes semantic searches for different code patterns
- Shows Results: Displays search results with similarity scores and file locations
Expected Output
🚀 Claude Context Real Usage Example
===============================
...
🔌 Connecting to vector database at: ...
📖 Starting to index codebase...
🗑️ Existing index found, clearing it first...
📊 Indexing stats: 45 files, 234 code chunks
🔍 Performing semantic search...
🔎 Search: "vector database operations"
1. Similarity: 89.23%
File: /path/to/packages/core/src/vectordb/milvus-vectordb.ts
Language: typescript
Lines: 147-177
Preview: async search(collectionName: string, queryVector: number[], options?: SearchOptions)...
🎉 Example completed successfully!