Skip to main content
skill CX Codex

convex-agent — Claude Code skill: AI agent and RAG on Convex

Adds an AI agent backend to a Convex app: durable threads, message history, tool calls and vector search for RAG.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add convex/agent-skills --skill convex-agent -a claude-code
Open on GitHub

What convex-agent does

The skill walks through the setup in order: install @convex-dev/agent and @convex-dev/ai-sdk-provider, register the agent component in convex.config.ts, define tools and instructions, then create threads and stream messages. History lives in Convex, so it survives restarts and stays reactive.

Model calls default to the Convex AI Gateway via languageModel: convexGateway("provider/model"). Convex holds the provider credentials, so there is no LLM key to obtain or rotate. The catch: this needs convex 1.45+ on a Convex Cloud deployment and a paid plan. On a free plan, self-hosted or local backend the gateway is unavailable, and the skill falls back to calling the provider SDK with a key stored in Convex env through the env micro power.

For RAG, documents are embedded into a vector index and retrieved inside the tool. The gateway does not serve embeddings yet, so the embedding provider's key goes into env. Model calls belong in actions, with 'use node' where the SDK needs it. A provider key should never reach the client.

What it helps with

  • wire an AI agent backend into a Convex app
  • keep threads and message history across requests
  • build RAG retrieval over documents with a vector index
  • attach tool calls to the agent
  • call a model without holding your own LLM key

Example prompts for the agent

  • add an agent to this Convex app with @convex-dev/agent, threads and streamed messages
  • set up RAG: embed the docs into a vector index and retrieve them in the tool
  • switch model calls to convexGateway, no provider key needed

How to install convex-agent

1Skills CLI (Vercel)

npx skills add convex/agent-skills --skill convex-agent -a claude-code

2Manually: put the files in place

~/.claude/skills/convex-agent/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/convex-agent/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about convex-agent

How do I install convex-agent in Claude?

Run npx skills add convex/agent-skills --skill convex-agent -a claude-code. The skill lands in ~/.claude/skills/convex-agent/SKILL.md.

What does convex-agent do?

It guides you through adding an AI agent backend to a Convex app: threads, message history, tool calls and vector search for RAG.

Do I need an LLM provider key?

Not by default — model calls go through the Convex AI Gateway and Convex holds the credentials. A key is needed for embeddings and as a fallback where the gateway is unavailable.

Source text

SKILL.md · Apache-2.0
---
name: convex-agent
description: "Add an AI agent / RAG backend (@convex-dev/agent) to the Convex app."
---

<!-- GENERATED from convex-agents content/capabilities/agent.json — do not edit by hand. -->

# Add an AI agent / RAG backend

Install @convex-dev/agent for durable threads, message history, tool-calls, and vector search/RAG — the backend for an in-app AI agent. Call models through the Convex AI Gateway by default: Convex holds the provider credentials, so there is no LLM key to obtain, store, or rotate.

## Workflow

1. Install @convex-dev/agent + @convex-dev/ai-sdk-provider; add the agent component to convex.config.ts.
2. Define the agent (tools, instructions) with `languageModel: convexGateway("provider/model")` — no API key needed (needs convex 1.45+ on a Convex Cloud deployment, paid plan).
3. Create threads + stream messages; persist history in Convex.
4. For RAG: embed docs into a vector index and retrieve in the tool. The gateway does not serve embeddings yet, so store the embedding provider's key via the `env` micro power.
5. Only if the gateway is unavailable (free plan, self-hosted, local backend): call the provider SDK with a key stored via the `env` micro power.

## Rules

- Default to the Convex AI Gateway (`convexGateway` from @convex-dev/ai-sdk-provider) for model calls; fall back to a provider key in Convex env only where the gateway is unavailable (free plan, self-hosted, local backend).
- Never expose a provider API key client-side; when one is needed (embeddings, gateway fallback), keep it in Convex env via the `env` micro power.
- Run model calls in actions ('use node' if the SDK needs it).
- Persist threads/messages in Convex for durability + reactivity.

© convex · Apache-2.0 · convex/agent-skills

Similar skills

All skills for Agent setup: memory, context, orchestration →

From the same set32

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor