cloudflare-vectorize
Build semantic search with Cloudflare Vectorize V2 (Sept 2024 GA). Covers V2 breaking changes: async mutations, 5M vectors/index (was 200K), 31ms latency (was 549ms), returnMetadata enum, and V1 deprecation (Dec 2024). Use when: migrating V1→V2, handling async mutations with mutationId, creating metadata indexes before insert, or troubleshooting "returnMetadata must be 'all'", V2 timing issues, metadata index errors, dimension mismatches.
What this skill does
# Cloudflare Vectorize Complete implementation guide for Cloudflare Vectorize - a globally distributed vector database for building semantic search, RAG (Retrieval Augmented Generation), and AI-powered applications with Cloudflare Workers. **Status**: Production Ready ✅ **Last Updated**: 2025-10-21 **Dependencies**: cloudflare-worker-base (for Worker setup), cloudflare-workers-ai (for embeddings) **Latest Versions**: [email protected], @cloudflare/[email protected] **Token Savings**: ~65% **Errors Prevented**: 8 **Dev Time Saved**: ~3 hours ## What This Skill Provides ### Core Capabilities - ✅ **Index Management**: Create, configure, and manage vector indexes - ✅ **Vector Operations**: Insert, upsert, query, delete, and list vectors - ✅ **Metadata Filtering**: Advanced filtering with 10 metadata indexes per index - ✅ **Semantic Search**: Find similar vectors using cosine, euclidean, or dot-product metrics - ✅ **RAG Patterns**: Complete retrieval-augmented generation workflows - ✅ **Workers AI Integration**: Native embedding generation with @cf/baai/bge-base-en-v1.5 - ✅ **OpenAI Integration**: Support for text-embedding-3-small/large models - ✅ **Document Processing**: Text chunking and batch ingestion pipelines ### Templates Included 1. **basic-search.ts** - Simple vector search with Workers AI 2. **rag-chat.ts** - Full RAG chatbot with context retrieval 3. **document-ingestion.ts** - Document chunking and embedding pipeline 4. **metadata-filtering.ts** - Advanced filtering patterns --- ## ⚠️ Vectorize V2 Breaking Changes (September 2024) **IMPORTANT**: Vectorize V2 became GA in September 2024 with significant breaking changes. ### What Changed in V2 **Performance Improvements**: - **Index capacity**: 200,000 → **5 million vectors** per index - **Query latency**: 549ms → **31ms** median (18× faster) - **TopK limit**: 20 → **100** results per query - **Scale limits**: 100 → **50,000 indexes** per account - **Namespace limits**: 100 → **50,000 namespaces** per index **Breaking API Changes**: 1. **Async Mutations** - All mutations now asynchronous: ```typescript // V2: Returns mutationId const result = await env.VECTORIZE_INDEX.insert(vectors); console.log(result.mutationId); // "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" // Vector inserts/deletes may take a few seconds to be reflected ``` 2. **returnMetadata Parameter** - Boolean → String enum: ```typescript // ❌ V1 (deprecated) { returnMetadata: true } // ✅ V2 (required) { returnMetadata: 'all' | 'indexed' | 'none' } ``` 3. **Metadata Indexes Required Before Insert**: - V2 requires metadata indexes created BEFORE vectors inserted - Vectors added before metadata index won't be indexed - Must re-upsert vectors after creating metadata index **V1 Deprecation Timeline**: - **December 2024**: Can no longer create V1 indexes - **Existing V1 indexes**: Continue to work (other operations unaffected) - **Migration**: Use `wrangler vectorize --deprecated-v1` flag for V1 operations **Wrangler Version Required**: - **Minimum**: [email protected] for V2 commands - **Recommended**: [email protected]+ (latest) ### Check Mutation Status ```typescript // Get index info to check last mutation processed const info = await env.VECTORIZE_INDEX.describe(); console.log(info.mutationId); // Last mutation ID console.log(info.processedUpToMutation); // Last processed timestamp ``` --- ## Critical Setup Rules ### ⚠️ MUST DO BEFORE INSERTING VECTORS ```bash # 1. Create the index with FIXED dimensions and metric npx wrangler vectorize create my-index \ --dimensions=768 \ --metric=cosine # 2. Create metadata indexes IMMEDIATELY (before inserting vectors!) npx wrangler vectorize create-metadata-index my-index \ --property-name=category \ --type=string npx wrangler vectorize create-metadata-index my-index \ --property-name=timestamp \ --type=number ``` **Why**: Metadata indexes MUST exist before vectors are inserted. Vectors added before a metadata index was created won't be filterable on that property. ### Index Configuration (Cannot Be Changed Later) ```bash # Dimensions MUST match your embedding model output: # - Workers AI @cf/baai/bge-base-en-v1.5: 768 dimensions # - OpenAI text-embedding-3-small: 1536 dimensions # - OpenAI text-embedding-3-large: 3072 dimensions # Metrics determine similarity calculation: # - cosine: Best for normalized embeddings (most common) # - euclidean: Absolute distance between vectors # - dot-product: For non-normalized vectors ``` ## Wrangler Configuration **wrangler.jsonc**: ```jsonc { "name": "my-vectorize-worker", "main": "src/index.ts", "compatibility_date": "2025-10-21", "vectorize": [ { "binding": "VECTORIZE_INDEX", "index_name": "my-index" } ], "ai": { "binding": "AI" } } ``` ## TypeScript Types ```typescript export interface Env { VECTORIZE_INDEX: VectorizeIndex; AI: Ai; } interface VectorizeVector { id: string; values: number[] | Float32Array | Float64Array; namespace?: string; metadata?: Record<string, string | number | boolean | string[]>; } interface VectorizeMatches { matches: Array<{ id: string; score: number; values?: number[]; metadata?: Record<string, any>; namespace?: string; }>; count: number; } ``` ## Metadata Filter Operators (V2) Vectorize V2 supports advanced metadata filtering with range queries: ```typescript // Equality (implicit $eq) { category: "docs" } // Not equals { status: { $ne: "archived" } } // In/Not in arrays { category: { $in: ["docs", "tutorials"] } } { category: { $nin: ["deprecated", "draft"] } } // Range queries (numbers) - NEW in V2 { timestamp: { $gte: 1704067200, $lt: 1735689600 } } // Range queries (strings) - prefix searching { url: { $gte: "/docs/workers", $lt: "/docs/workersz" } } // Nested metadata with dot notation { "author.id": "user123" } // Multiple conditions (implicit AND) { category: "docs", language: "en", "metadata.published": true } ``` ## Metadata Best Practices ### 1. Cardinality Considerations **Low Cardinality (Good for $eq filters)**: ```typescript // Few unique values - efficient filtering metadata: { category: "docs", // ~10 categories language: "en", // ~5 languages published: true // 2 values (boolean) } ``` **High Cardinality (Avoid in range queries)**: ```typescript // Many unique values - avoid large range scans metadata: { user_id: "uuid-v4...", // Millions of unique values timestamp_ms: 1704067200123 // Use seconds instead } ``` ### 2. Metadata Limits - **Max 10 metadata indexes** per Vectorize index - **Max 10 KiB metadata** per vector - **String indexes**: First 64 bytes (UTF-8) - **Number indexes**: Float64 precision - **Filter size**: Max 2048 bytes (compact JSON) ### 3. Key Restrictions ```typescript // ❌ INVALID metadata keys metadata: { "": "value", // Empty key "user.name": "John", // Contains dot (reserved for nesting) "$admin": true, // Starts with $ "key\"with\"quotes": 1 // Contains quotes } // ✅ VALID metadata keys metadata: { "user_name": "John", "isAdmin": true, "nested": { "allowed": true } // Access as "nested.allowed" in filters } ``` ## Common Errors & Solutions ### Error 1: Metadata Index Created After Vectors Inserted ``` Problem: Filtering doesn't work on existing vectors Solution: Delete and re-insert vectors OR create metadata indexes BEFORE inserting ``` ### Error 2: Dimension Mismatch ``` Problem: "Vector dimensions do not match index configuration" Solution: Ensure embedding model output matches index dimensions: - Workers AI bge-base: 768 - OpenAI small: 1536 - OpenAI large: 3072 ``` ### Error 3: Invalid Metadata Keys ``` Problem: "Invalid metadata key" Solution: Keys cannot: - Be empty - Contain . (dot) - Contain " (quote) - Start with $ (dollar sign) ``` ### Error 4: Filter Too Large ``` Problem: "Filter exc
Related in Cloud & DevOps
appbuilder-action-scaffolder
IncludedCreate, implement, deploy, and debug Adobe Runtime actions with consistent layout, validation, and error handling. Use this skill whenever the user needs to add actions to an App Builder project, understand action structure (params, response format, web/raw actions), configure actions in the manifest, use App Builder SDKs (State, Files, Events, database), deploy and invoke actions via CLI, debug action issues, or implement patterns such as webhook receivers, custom event providers, journaling consumers, large payload redirects, action sequence pipelines, and Asset Compute workers. Also trigger when users mention serverless functions in Adobe context, action logging, IMS authentication for actions, or cron-style scheduled actions.
orchestrating-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. Use this skill when the user needs a multi-step Data Cloud pipeline, cross-phase troubleshooting, or data space and data kit management. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase sf data360 workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching phase-specific skill), the task is STDM/session tracing/parquet telemetry (use observing-agentforce), standard CRM SOQL (use querying-soql), or Apex implementation (use generating-apex).
github-project-automation
IncludedAutomate GitHub repository setup with CI/CD workflows, issue templates, Dependabot, and CodeQL security scanning. Includes 12 production-tested workflows and prevents 18 errors: YAML syntax, action pinning, and configuration. Use when: setting up GitHub Actions CI/CD, creating issue/PR templates, enabling Dependabot or CodeQL scanning, deploying to Cloudflare Workers, implementing matrix testing, or troubleshooting YAML indentation, action version pinning, secrets syntax, runner versions, or CodeQL configuration. Keywords: github actions, github workflow, ci/cd, issue templates, pull request templates, dependabot, codeql, security scanning, yaml syntax, github automation, repository setup, workflow templates, github actions matrix, secrets management, branch protection, codeowners, github projects, continuous integration, continuous deployment, workflow syntax error, action version pinning, runner version, github context, yaml indentation error
sf-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase `sf data360` workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching sf-datacloud-* skill), the task is STDM/session tracing/parquet telemetry (use sf-ai-agentforce-observability), standard CRM SOQL (use sf-soql), or Apex implementation (use sf-apex).
fabric-cli
IncludedUse this skill for Fabric.so CLI workflows with the `fabric` terminal command: diagnose/install/login, search or browse a Fabric library, save notes/links/files, create folders, ask the Fabric AI assistant, manage tasks/workspaces, generate shell completion, check subscription usage, produce JSON output, and use Fabric as persistent agent memory. Do not use for Microsoft Fabric/Azure/Power BI `fab`, Daniel Miessler's Fabric framework, Python Fabric SSH, Fabric.js, or textile/fashion fabric.
lark
IncludedLark/Feishu CLI skills: lark-cli operations for docs, markdown, sheets, base, calendar, im, mail, task, okr, drive, wiki, slides, whiteboard, apps, approval, attendance, contact, vc, minutes, event. Use when the user needs to operate Lark/Feishu resources via lark-cli, send messages, manage documents, spreadsheets, calendars, tasks, OKRs, deploy web pages, or any Feishu/Lark workspace operations.