Back to Skills

Convex Agents RAG

Sstobo
Updated Yesterday
34 views
5
5
View on GitHub
Metaworddata

About

This skill implements Retrieval-Augmented Generation (RAG) to enhance Claude agents with custom knowledge bases, enabling them to search documents and retrieve relevant context. Use it when you need to ground agent responses in specific data like policies, product docs, or FAQs to reduce hallucinations. It provides semantic search capabilities combined with generation for building accurate, context-aware systems.

Quick Install

Claude Code

Recommended
Plugin CommandRecommended
/plugin add https://github.com/Sstobo/convex-skills
Git CloneAlternative
git clone https://github.com/Sstobo/convex-skills.git ~/.claude/skills/Convex Agents RAG

Copy and paste this command in Claude Code to install this skill

Documentation

Purpose

Enables agents to search through custom content and knowledge bases to provide accurate, context-grounded responses. RAG combines LLM capabilities with semantic search.

When to Use This Skill

  • Agents need to reference a knowledge base or document collection
  • Grounding answers in specific data (policies, product docs, etc.)
  • Semantic search across custom content
  • Building a search + generation system (FAQ, documentation, support)
  • Reducing hallucinations by constraining responses to known information
  • Managing user-specific or team-specific knowledge namespaces

Setup

Install and configure RAG in your convex.config.ts:

import { defineApp } from "convex/server";
import agent from "@convex-dev/agent/convex.config";
import rag from "@convex-dev/rag/convex.config";

const app = defineApp();
app.use(agent);
app.use(rag);

export default app;

Add Content

Ingest documents into a namespace:

import { rag } from "@convex-dev/rag";

export const addContent = action({
  args: { userId: v.string(), key: v.string(), text: v.string() },
  handler: async (ctx, { userId, key, text }) => {
    const namespace = `user:${userId}`;
    await rag.addContent(ctx, components.rag, {
      namespace,
      key,
      text,
      filters: { filterNames: [filename] },
    });
  },
});

Search and Generate

Use RAG with agents:

export const answerWithContext = action({
  args: { threadId: v.string(), userId: v.string(), question: v.string() },
  handler: async (ctx, { threadId, userId, question }) => {
    const { thread } = await myAgent.continueThread(ctx, { threadId });

    const context = await rag.search(ctx, components.rag, {
      namespace: `user:${userId}`,
      query: question,
      limit: 10,
    });

    const augmentedPrompt = `# Context:\n\n${context.text}\n\n# Question:\n\n${question}`;
    const result = await thread.generateText({ prompt: augmentedPrompt });

    return result.text;
  },
});

Key Principles

  • Namespaces isolate data: Use user:userId or team:teamId for multi-tenant safety
  • Hybrid search: Combine text and vector search for better results
  • Filtering: Use filterNames to target specific documents

Next Steps

  • See fundamentals for basic agent setup
  • See context for advanced context customization

GitHub Repository

Sstobo/convex-skills
Path: convex-agents-rag

Related Skills

content-collections

Meta

This skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.

View skill

hybrid-cloud-networking

Meta

This skill configures secure hybrid cloud networking between on-premises infrastructure and cloud platforms like AWS, Azure, and GCP. Use it when connecting data centers to the cloud, building hybrid architectures, or implementing secure cross-premises connectivity. It supports key capabilities such as VPNs and dedicated connections like AWS Direct Connect for high-performance, reliable setups.

View skill

llamaindex

Meta

LlamaIndex is a data framework for building RAG-powered LLM applications, specializing in document ingestion, indexing, and querying. It provides key features like vector indices, query engines, and agents, and supports over 300 data connectors. Use it for document Q&A, chatbots, and knowledge retrieval when building data-centric applications.

View skill

csv-data-summarizer

Meta

This skill automatically analyzes CSV files to generate comprehensive statistical summaries and visualizations using Python's pandas and matplotlib/seaborn. It should be triggered whenever a user uploads or references CSV data without prompting for analysis preferences. The tool provides immediate insights into data structure, quality, and patterns through automated analysis and visualization.

View skill