convex
Skill16 starsChanged 10 months agoMITView on GitHub
Expert guidance for Convex backend development including queries, mutations, actions, schemas, authentication, scheduling, file storage, search, and Next.js integration. Use when working with Convex functions, database operations, convex/ directory code, or Next.js App Router with Convex. Triggers: convex functions, ctx.db, useQuery, useMutation, usePreloadedQuery, preloadQuery, fetchQuery, convex schema, convex auth, convex cron, convex actions, convex scheduling, ctx.storage, generateUploadUrl, file upload, storage.store, storage.getUrl, Id<"_storage">, ConvexProvider, ConvexClientProvider, db.system, _scheduled_functions, _storage system table, OCC, optimistic concurrency, transaction atomicity, schema evolution, searchIndex, vectorIndex, withSearchIndex, ctx.vectorSearch, full-text search, vector search, embeddings, RAG, semantic search, typeahead search, ConvexError, httpAction, httpRouter, CORS, webhook.
11 other projects use a version of this.
Adopted by
Most recently taken up by
- grezxune/ai-toolstheir own version, first seen Oct 5, 2026
- waynesutton/builder-skillstheir own version, first seen Sep 28, 2026
- get-convex/agent-skillstheir own version, first seen Sep 9, 2026
- FabienGreard/TouchGrassBartheir own version, first seen Sep 8, 2026
- getsentry/fridaytheir own version, first seen Aug 28, 2026
- sholajegede/mastra-vs-langchaintheir own version, first seen Jun 6, 2026
Used with
Projects with it also use convex-migration-helper, convex-performance-audit and 1 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
elpiartheraSkillconvex-migration-helper
Plans and executes safe Convex schema and data migrations using the widen-migrate-narrow workflow and the @convex-dev/migrations component. Use this skill when a deployment fails schema validation, existing documents need backfilling, fields need adding or removing or changing type, tables need splitting or merging, or a zero-downtime migration strategy is needed. Also use when the user mentions breaking schema changes, multi-deploy rollouts, or data transformations on existing Convex tables.
Also in 3 projects that use this
elpiartheraSkillconvex-performance-audit
Audits and optimizes Convex application performance across hot-path reads, write contention, subscription cost, and function limits. Use this skill when a Convex feature is slow or expensive, npx convex insights shows high bytes or documents read, OCC conflict errors or mutation retries appear, subscriptions or UI updates are costly, functions hit execution or transaction limits, or the user mentions performance, latency, read amplification, or invalidation problems in a Convex app.
Also in 3 projects that use this
- +1 more from elpiarthera
Other versions11 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 11
- raroque/boop-agent★ 1.4ksame name
- waynesutton/builder-skills★ 404same name
- Mindrally/skills★ 266same name
- get-convex/agent-skills★ 63same name
- sholajegede/mastra-vs-langchain★ 18same name
- FabienGreard/TouchGrassBar★ 4same name
- gmickel/my-claude-skills★ 4same name
- StillScripts/cursor-agents-manager★ 1same name
- yisiliu/agent-town★ 1same name
- getsentry/friday★ 0same name
1 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository5 other files it gives its agents.
- convex-agentSkill
- convex-authSkill
- convex-clerkSkill
- convex-componentsSkill
- convex-workosSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. 0 are common, 2 are distinctive, and 11 are very specific to this project.
0
Common
Most of the 11 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 192
Use internal. functions for all ctx.run*, ctx.scheduler, and crons
- Very specific: line 193
Always validate args for public functions with v.* validators
- Very specific: line 194
Always check auth in public functions: ctx.auth.getUserIdentity()
- Very specific: line 195
Use indexes with .withIndex() instead of .filter()
- Distinctive: line 197
Keep actions small — put logic in queries/mutations
- Very specific: line 199
Use ConvexError for user-facing errors
- Very specific: line 203
Don't use api. functions for scheduling (use internal.)
- Very specific: line 204
Don't use .filter() on queries — use indexes or TypeScript filter
- Very specific: line 205
Don't use .collect() on unbounded queries (use .take() or pagination)
- Very specific: line 206
Don't use Date.now() in queries (breaks caching)
- Distinctive: line 207
Don't call actions directly from client (trigger via mutation + scheduler)
- Very specific: line 208
Don't make sequential ctx.runQuery/runMutation calls in actions (batch them)
- Very specific: line 209
Don't use ctx.runAction unless switching runtimes (use helper functions)
“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Convex Backend Development
Core Architecture
Convex is a reactive database where queries are TypeScript functions. The sync engine (queries + mutations + database) is the heart of Convex — center your app around it.
Function Types
| Type | DB Access | Deterministic | Cached/Reactive | Use For |
query | Read only | Yes | Yes | All reads, subscriptions |
mutation | Read/Write | Yes | No | All writes (transactions) |
action | Via ctx.run* | No | No | External APIs, LLMs, email |
httpAction | Via ctx.run* | No | No | Webhooks, custom HTTP |
Key rule: Queries and mutations cannot make network requests. Actions cannot directly access the database.
Project Structure (Best Practice)
convex/
├── _generated/ # Auto-generated types (commit this)
├── schema.ts # Database schema
├── model/ # Helper functions (most logic lives here)
│ ├── users.ts
│ └── messages.ts
├── users.ts # Thin wrappers exposing public API
├── messages.ts
├── crons.ts # Cron job definitions
└── http.ts # HTTP action routesEssential Patterns
1. Function Structure
// convex/messages.ts
import { query, mutation, internalMutation } from './_generated/server';
import { internal } from './_generated/api';
import { v } from 'convex/values';
// PUBLIC query with validators (always validate public functions)
export const list = query({
args: { channelId: v.id('channels') },
handler: async (ctx, { channelId }) => {
return await ctx.db
.query('messages')
.withIndex('by_channel', (q) => q.eq('channelId', channelId))
.order('desc')
.take(50);
}
});
// PUBLIC mutation with validators and auth check
export const send = mutation({
args: { channelId: v.id('channels'), body: v.string() },
handler: async (ctx, { channelId, body }) => {
const user = await ctx.auth.getUserIdentity();
if (!user) throw new Error('Unauthorized');
await ctx.db.insert('messages', {
channelId,
body,
authorId: user.subject
});
}
});
// INTERNAL mutation (for scheduling, crons, actions)
export const deleteOld = internalMutation({
args: { before: v.number() },
handler: async (ctx, { before }) => {
const old = await ctx.db
.query('messages')
.withIndex('by_createdAt', (q) => q.lt('_creationTime', before))
.take(100);
for (const msg of old) {
await ctx.db.delete(msg._id);
}
}
});2. Helper Functions Pattern
Most logic should live in helper functions, NOT in query/mutation handlers:
// convex/model/users.ts
import { QueryCtx, MutationCtx } from '../_generated/server';
import { Doc } from '../_generated/dataModel';
export async function getCurrentUser(
ctx: QueryCtx
): Promise<Doc<'users'> | null> {
const identity = await ctx.auth.getUserIdentity();
if (!identity) return null;
return await ctx.db
.query('users')
.withIndex('by_tokenIdentifier', (q) =>
q.eq('tokenIdentifier', identity.tokenIdentifier)
)
.unique();
}
export async function requireUser(ctx: QueryCtx): Promise<Doc<'users'>> {
const user = await getCurrentUser(ctx);
if (!user) throw new Error('Unauthorized');
return user;
}3. Actions with Scheduling
// convex/ai.ts
import { action, internalMutation } from './_generated/server';
import { internal } from './_generated/api';
import { v } from 'convex/values';
export const summarize = action({
args: { documentId: v.id('documents') },
handler: async (ctx, { documentId }) => {
// Read data via internal query
const doc = await ctx.runQuery(internal.documents.get, { documentId });
// Call external API
const response = await fetch('https://api.openai.com/v1/...', {...});
const summary = await response.json();
// Write result via internal mutation
await ctx.runMutation(internal.documents.setSummary, {
documentId,
summary: summary.text
});
}
});
// Trigger action from mutation (not directly from client)
export const requestSummary = mutation({
args: { documentId: v.id('documents') },
handler: async (ctx, { documentId }) => {
const user = await ctx.auth.getUserIdentity();
if (!user) throw new Error('Unauthorized');
await ctx.db.patch(documentId, { status: 'processing' });
// Schedule action (runs after mutation commits)
await ctx.scheduler.runAfter(0, internal.ai.summarizeInternal, {
documentId
});
}
});4. Application Errors
import { ConvexError } from 'convex/values';
export const assignRole = mutation({
args: { roleId: v.id('roles'), userId: v.id('users') },
handler: async (ctx, { roleId, userId }) => {
const existing = await ctx.db
.query('assignments')
.withIndex('by_role', (q) => q.eq('roleId', roleId))
.first();
if (existing) {
throw new ConvexError({
code: 'ROLE_TAKEN',
message: 'Role is already assigned'
});
}
await ctx.db.insert('assignments', { roleId, userId });
}
});Critical Rules
DO ✅
- Use
internal.functions for allctx.run*,ctx.scheduler, and crons - Always validate args for public functions with
v.*validators - Always check auth in public functions:
ctx.auth.getUserIdentity() - Use indexes with
.withIndex()instead of.filter() - Await all promises (enable
no-floating-promisesESLint rule) - Keep actions small — put logic in queries/mutations
- Batch database operations in single mutations
- Use
ConvexErrorfor user-facing errors
DON'T ❌
- Don't use
api.functions for scheduling (useinternal.) - Don't use
.filter()on queries — use indexes or TypeScript filter - Don't use
.collect()on unbounded queries (use.take()or pagination) - Don't use
Date.now()in queries (breaks caching) - Don't call actions directly from client (trigger via mutation + scheduler)
- Don't make sequential
ctx.runQuery/runMutationcalls in actions (batch them) - Don't use
ctx.runActionunless switching runtimes (use helper functions)
Reference Guides
For detailed patterns, see:
- FUNCTIONS.md — Queries, mutations, actions, internal functions
- VALIDATION.md — Argument validation, extended validators
- ERROR_HANDLING.md — ConvexError, application errors
- HTTP_ACTIONS.md — HTTP actions, CORS, webhooks
- RUNTIMES.md — Default vs Node.js runtime, bundling, debugging
- DATABASE.md — Schema, indexes, reading/writing data
- SEARCH.md — Full-text search, vector search, RAG patterns
- ADVANCED.md — System tables, schema philosophy, OCC
- AUTH.md — Row-level security, Convex Auth (first-party)
- SCHEDULING.md — Crons, scheduled functions, workflows
- FILE_STORAGE.md — Upload, store, serve, delete files
- NEXTJS.md — Next.js App Router, SSR, Server Actions
Auth Provider Skills (add to project as needed):
convex-auth— Universal auth patterns, storing users, debuggingconvex-clerk— Clerk setup, webhooks, JWT configurationconvex-workos— WorkOS AuthKit setup, auto-provisioning
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

