Agent skill

Convex Agents

by waynesutton in waynesutton/builder-skills

Builds AI agents on the Convex agent component: threads, messages, tools that call queries and mutations, streaming, RAG with vector search, and workflows for multi step jobs.

Apache-2.0Auto-check passedAI & LLM Engineering

Install Convex Agents

skills CLI
$ npx skills add waynesutton/builder-skills --skill convex-agents -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install waynesutton/builder-skills convex-agents --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/waynesutton/builder-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/convex-agents .claude/skills/convex-agents && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
convex-agents
GitHub stars
404
Token cost
~2.2k tokens
SKILL.md length
580 words
Files
6 (incl. references, assets)
Skills in repo
17
Repo updated
First seen
Licence
Apache-2.0

At a glance

Builds AI agents on the Convex agent component: threads, messages, tools that call queries and mutations, streaming, RAG with vector search, and workflows for multi step jobs.

  • Adding a chat assistant
  • SKILL.md covers When to reach for this, Install and register, Define an agent and Create a thread and generate a…, plus 6 more sections
  • Calls npx and npm; needs OPENAI_API_KEY
  • Tool calling agent

What it does

Convex Agents is an agent skill from waynesutton/builder-skills. Builds AI agents on the Convex agent component: threads, messages, tools that call queries and mutations, streaming, RAG with vector search, and workflows for multi step jobs. Use when adding a chat assistant, tool calling agent, or retrieval feature to a Convex app.

Its SKILL.md is about 2.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 8 other files, including reference files and assets (for example `agents/openai.yaml`, `references/rag-and-workflows.md` and `references/tools-and-streaming.md`).

It sits in AI & LLM Engineering, covering Structured output and tool calling, Vector databases and Retrieval-augmented generation. It works with Convex. The repository describes itself as: Builder skills for Convex apps. Convex patterns plus a PRD, task.md, changelog, and files.md workflow for Claude Code, Codex, Cursor, and OpenCode. The licence is Apache-2.0.

When your agent uses it

  • Adding a chat assistant
  • Tool calling agent
  • Retrieval feature to a Convex app

Example prompts

  • “Use the convex-agents skill to build AI agents on the Convex agent component: threads, messages, tools that call queries and mutations, streaming…”
  • “/convex-agents”

Requirements

  • Node.js
  • A credential in OPENAI_API_KEY

What it can do on your machine

Read from SKILL.md and the folder at commit 82d1ce2. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npx
    • npm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • docs.convex.dev
    • convex.dev

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • OPENAI_API_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Convex Agents loads about 2.2k tokens when it runs, and up to ~6.6k if it reads all its reference files. Until then it costs about 70 tokens; SKILL.md has 580 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~70
When it runs · the whole SKILL.md, loaded when a task matches
~2.2k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~6.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from waynesutton/builder-skills at commit 82d1ce2, republished under its Apache-2.0 licence (© waynesutton). 580 words, ~2,225 tokens.

Download SKILL.mdSave it as .claude/skills/convex-agents/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.
name
convex-agents
description
Builds AI agents on the Convex agent component: threads, messages, tools that call queries and mutations, streaming, RAG with vector search, and workflows for multi step jobs. Use when adding a chat assistant, tool calling agent, or retrieval feature to a Convex app.

Convex agents

Produces a chat or tool calling agent backed by @convex-dev/agent, with thread history stored in Convex and a reactive message list for the UI. The one rule: every LLM call runs inside an action. Mutations save the prompt and schedule the action; they never call a model.

When to reach for this

  • Adding a chat assistant with persistent conversation history
  • Letting an LLM call your queries and mutations as tools
  • Streaming a model reply to one or more clients
  • Answering questions over your own documents (RAG)
  • Chaining several LLM steps into a durable job that survives restarts

Install and register

bash
npm install @convex-dev/agent ai @ai-sdk/openai zod
npx convex env set OPENAI_API_KEY sk-...
typescript
// convex/convex.config.ts
import { defineApp } from "convex/server";
import agent from "@convex-dev/agent/convex.config";

const app = defineApp();
app.use(agent);
export default app;

Run npx convex dev once so components.agent is generated before defining an agent.

Define an agent

typescript
// convex/agent.ts
import { Agent, stepCountIs } from "@convex-dev/agent";
import { openai } from "@ai-sdk/openai";
import { components } from "./_generated/api";

export const supportAgent = new Agent(components.agent, {
  name: "Support Agent",
  languageModel: openai.chat("gpt-4o-mini"),
  instructions: "You are a support assistant. Answer briefly and cite docs when possible.",
  // Lets the model call tools and then respond, up to 5 steps
  stopWhen: stepCountIs(5),
});

name tags each saved message with the agent that wrote it. Everything except name can be overridden per call.

Create a thread and generate a reply

Save the user prompt in a mutation, then schedule an internal action that generates the reply. Clients subscribed to the thread see the new message without the action returning anything.

typescript
// convex/chat.ts
import { v } from "convex/values";
import { mutation, internalAction, QueryCtx, MutationCtx } from "./_generated/server";
import { components, internal } from "./_generated/api";
import { saveMessage } from "@convex-dev/agent";
import { supportAgent } from "./agent";

// Throws unless the signed in user owns the thread
async function authorizeThreadAccess(ctx: QueryCtx | MutationCtx, threadId: string) {
  const identity = await ctx.auth.getUserIdentity();
  if (!identity) throw new Error("Not authenticated");
  const thread = await ctx.runQuery(components.agent.threads.getThread, { threadId });
  if (!thread || thread.userId !== identity.subject) throw new Error("Unauthorized");
}

export const startThread = mutation({
  args: {},
  returns: v.string(),
  handler: async (ctx) => {
    const identity = await ctx.auth.getUserIdentity();
    if (!identity) throw new Error("Not authenticated");
    const { threadId } = await supportAgent.createThread(ctx, { userId: identity.subject });
    return threadId;
  },
});

export const sendMessage = mutation({
  args: { threadId: v.string(), prompt: v.string() },
  returns: v.null(),
  handler: async (ctx, args) => {
    await authorizeThreadAccess(ctx, args.threadId);
    const { messageId } = await saveMessage(ctx, components.agent, {
      threadId: args.threadId,
      prompt: args.prompt,
    });
    await ctx.scheduler.runAfter(0, internal.chat.generateReply, {
      threadId: args.threadId,
      promptMessageId: messageId,
    });
    return null;
  },
});

export const generateReply = internalAction({
  args: { threadId: v.string(), promptMessageId: v.string() },
  returns: v.null(),
  handler: async (ctx, args) => {
    // promptMessageId makes retries safe: the same prompt is reused, never duplicated
    await supportAgent.generateText(
      ctx,
      { threadId: args.threadId },
      { promptMessageId: args.promptMessageId },
    );
    return null;
  },
});

Thread ids are strings, not v.id(...), since the table lives inside the component.

List messages for the UI

typescript
// convex/chat.ts (continued)
import { paginationOptsValidator } from "convex/server";
import { listUIMessages } from "@convex-dev/agent";
import { query } from "./_generated/server";

export const listMessages = query({
  args: { threadId: v.string(), paginationOpts: paginationOptsValidator },
  handler: async (ctx, args) => {
    await authorizeThreadAccess(ctx, args.threadId);
    return await listUIMessages(ctx, components.agent, args);
  },
});
tsx
// src/Chat.tsx
import { useUIMessages } from "@convex-dev/agent/react";
import { api } from "../convex/_generated/api";

function Chat({ threadId }: { threadId: string }) {
  const { results, status, loadMore } = useUIMessages(
    api.chat.listMessages,
    { threadId },
    { initialNumItems: 20 },
  );
  return (
    <div>
      {results.map((m) => (
        <div key={m.key} data-role={m.role}>{m.text}</div>
      ))}
      {status === "CanLoadMore" && <button onClick={() => loadMore(20)}>Older</button>}
    </div>
  );
}

listUIMessages merges tool calls and the assistant text that follows them into one UIMessage, which keeps rendering simple.

One tool

Tools are defined with createTool and get a ctx that includes runQuery, runMutation, userId, and threadId. Annotate the handler return type to avoid circular type errors.

typescript
// convex/tools.ts
import { createTool } from "@convex-dev/agent";
import { z } from "zod";
import { api } from "./_generated/api";

export const searchOrders = createTool({
  description: "Find the current user's orders that match a search term",
  args: z.object({
    term: z.string().describe("Product name or order number to look for"),
  }),
  handler: async (ctx, args): Promise<Array<{ id: string; status: string }>> => {
    return await ctx.runQuery(api.orders.search, { term: args.term });
  },
});

Pass it to the agent with tools: { searchOrders } in the constructor or at the call site. For tool error handling, runtime tools with closures, and delta streaming to the client, open references/tools-and-streaming.md.

Retrieval and multi step jobs

For embedding documents, searching them with @convex-dev/rag or a hand rolled vector index, injecting results into the prompt, and running several LLM steps as a durable @convex-dev/workflow job, open references/rag-and-workflows.md.

Show full SKILL.md (275 more words)Show less

Common mistakes

MistakeWhy it breaksDo instead
Calling generateText in a mutationMutations cannot make network calls and must be deterministicSave the prompt with saveMessage, schedule an internalAction
v.id("threads") for thread idsThe threads table lives in the component, so ids are strings outside itUse v.string()
Skipping npx convex dev after app.use(agent)components.agent is not generated, so types failRun dev once before writing agent code
Returning the reply text from the action to the clientLoses the reply if the client disconnects, no reactivityLet clients read listUIMessages; the saved message shows up on its own
Tools without .describe() on argsThe model guesses what each field means and calls tools badlyDescribe every zod field
Tool handler with no return type annotationTypeScript circularity errors from ctx.runQueryAdd : Promise<...> to the handler
Exposing the message query with no auth checkAny client can read any threadCall an authorizeThreadAccess helper first
stopWhen left at the default with tools definedThe model calls a tool and stops without a text replySet stopWhen: stepCountIs(n) with n > 1

Checklist

  • app.use(agent) in convex.config.ts and npx convex dev has run
  • Provider key stored with npx convex env set, never in client code
  • Agent has a name, languageModel, and instructions
  • Prompts saved in a mutation, replies generated in an internalAction with promptMessageId
  • Thread and message ids typed as v.string()
  • Message list query checks thread ownership before calling listUIMessages
  • Every tool arg has a zod .describe() and the handler has a return type
  • stopWhen: stepCountIs(n) set when tools are in play
  • Client uses useUIMessages rather than reading action return values

Docs

© waynesutton, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 5 other files (references, assets) in skills/convex-agents of waynesutton/builder-skills.

  • SKILL.md
  • agents/openai.yaml
  • assets/large-logo.png
  • assets/small-logo.svg
  • references/rag-and-workflows.md
  • references/tools-and-streaming.md

Open the folder on GitHubat commit 82d1ce2

Compare with similar skills

Convex Agents next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Convex Agents compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Convex Agents this skillwaynesutton/builder-skills404—~2.2kAutomated safety check: PassApache-2.0
AI Native Developmentaiskillstore/marketplace4301 repos~4.5kAutomated safety check: PassNone
AI SDK Developmenttrypostit/trypost6782 repos~3.5kAutomated safety check: PassMIT
LangchainOrchestra-Research/AI-Research-SKILLs13k2 repos~3.2kAutomated safety check: PassMIT
Sap AI Coresecondsky/sap-skills462—~3.3kAutomated safety check: PassGPL-3.0
Spring AI Integrationrrezartprebreza/spring-boot-skills2981 repos~2.1kAutomated safety check: PassMIT

Similar skills

  • AI Native Development

    aiskillstore/marketplace

    Build AI-first applications with RAG pipelines, embeddings, vector databases, agentic workflows, and LLM integration.

    430 GitHub starsUsed in 1 repo~4.5k tokens
    AI & LLM EngineeringAuto-check passed
  • AI SDK Development

    trypostit/trypost

    TRIGGER when working with ai-sdk which is Laravel official first-party AI SDK.

    678 GitHub starsUsed in 2 repos~3.5k tokens
    AI & LLM EngineeringAuto-check passed
  • Langchain

    Orchestra-Research/AI-Research-SKILLs

    Framework for building LLM-powered applications with agents, chains, and RAG.

    13k GitHub starsUsed in 2 repos~3.2k tokens
    AI & LLM EngineeringAuto-check passed
  • Sap AI Core

    secondsky/sap-skills

    Guides development with SAP AI Core and SAP AI Launchpad for enterprise AI/ML workloads on SAP BTP.

    462 GitHub stars~3.3k tokensUpdated 3 days ago
    AI & LLM EngineeringAuto-check passed
  • Spring AI Integration

    rrezartprebreza/spring-boot-skills

    A skill your agent uses when integrating LLMs, chat clients, embeddings, RAG pipelines, or AI agents into Spring Boot.

    298 GitHub starsUsed in 1 repo~2.1k tokens
    AI & LLM EngineeringAuto-check passed
  • Spring AI Integration

    rrezartprebreza/spring-boot-skills

    A skill your agent uses when integrating LLMs, chat clients, embeddings, RAG pipelines, or AI agents into Spring Boot.

    298 GitHub starsUsed in 1 repo~2.5k tokens
    AI & LLM EngineeringAuto-check passed

More from waynesutton/builder-skills

All 17 skills in this repo
  • Convex Best Practices

    waynesutton/builder-skills

    Production patterns for Convex apps and the rules the @convex-dev/eslint-plugin enforces: validators, indexes, idempotent mutations, avoiding OCC conflicts, thin function wrappers, error handling.

    404 GitHub stars~2.6k tokensUpdated 10 days ago
    Auto-check passed
  • Convex Component Authoring

    waynesutton/builder-skills

    Creates reusable Convex components with defineComponent, a clean client wrapper, their own schema, and an npm publish setup.

    404 GitHub stars~2.6k tokensUpdated 10 days ago
    Auto-check passed
  • Convex Cron Jobs

    waynesutton/builder-skills

    Schedules work in Convex: cron jobs in convex/crons.ts, one off scheduled functions with runAfter and runAt, batching large jobs, and cancelling or inspecting the queue.

    404 GitHub stars~2k tokensUpdated 10 days ago
    Auto-check passed
  • Convex HTTP Actions

    waynesutton/builder-skills

    Adds HTTP endpoints in convex/http.ts: webhook receivers with signature checks, REST style routes, CORS, auth headers, streaming responses, and file uploads over HTTP.

    404 GitHub stars~2.6k tokensUpdated 10 days ago
    Auto-check passed
  • Convex Migrations

    waynesutton/builder-skills

    Changes a live Convex schema without downtime: make a field optional, backfill in batches, flip the validator, then clean up.

    404 GitHub stars~2.1k tokensUpdated 10 days ago
    Auto-check passed
  • Convex Security Audit

    waynesutton/builder-skills

    Deep security review of a Convex app: authorization model, data access paths per table, HTTP action exposure, rate limiting, file storage access, scheduled function trust, and a written findings…

    404 GitHub stars~2.6k tokensUpdated 10 days ago
    Auto-check passed

Works with

Questions about Convex Agents

What does Convex Agents do?

Builds AI agents on the Convex agent component: threads, messages, tools that call queries and mutations, streaming, RAG with vector search, and workflows for multi step jobs. Convex Agents is an agent skill from waynesutton/builder-skills. Builds AI agents on the Convex agent component: threads, messages, tools that call queries and mutations, streaming, RAG with vector search, and workflows for multi step jobs.

When should I use Convex Agents?

Convex Agents fits situations like: adding a chat assistant; tool calling agent; retrieval feature to a Convex app.

How do I install Convex Agents in Claude Code?

Run `npx skills add waynesutton/builder-skills --skill convex-agents -a claude-code`. Or copy the skill folder (skills/convex-agents in waynesutton/builder-skills) into .claude/skills/convex-agents in your project. Claude Code loads it when a task matches its description.

How do I install Convex Agents in Codex?

Run `npx skills add waynesutton/builder-skills --skill convex-agents -a codex`. Or copy the skill folder (skills/convex-agents in waynesutton/builder-skills) into .agents/skills/convex-agents in your project. Codex loads it when a task matches its description.

Can I use Convex Agents in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add waynesutton/builder-skills --skill convex-agents -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/convex-agents, .gemini/skills/convex-agents, .github/skills/convex-agents and .opencode/skills/convex-agents in your project.

What does Convex Agents need to run?

Going by SKILL.md and its folder, Convex Agents needs the command-line tools its instructions call (npx and npm) and credentials named OPENAI_API_KEY. Our summary lists: Node.js; A credential in OPENAI_API_KEY.

Does Convex Agents access the network?

SKILL.md names 2 domains. As links in the text: docs.convex.dev and convex.dev. This is read from the text; nothing was executed.

Is Convex Agents safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Convex Agents use?

Convex Agents is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Convex Agents use?

About 2.2k tokens (SKILL.md is roughly 8.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 4.4k tokens, read only when the agent opens those files.

What are the alternatives to Convex Agents?

Skills that share tags, products or a category with Convex Agents: AI Native Development (aiskillstore/marketplace, 430 stars), AI SDK Development (trypostit/trypost, 678 stars), Langchain (Orchestra-Research/AI-Research-SKILLs, 13k stars) and Sap AI Core (secondsky/sap-skills, 462 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Convex Agents?

waynesutton (a GitHub user) maintains it in waynesutton/builder-skills, which has 404 GitHub stars. The repository holds 17 skills in this directory. The repository was last updated on September 28, 2026.

Source: waynesutton/builder-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.