convex-functions

Write Convex queries, mutations, actions, and HTTP endpoints with validation and error handling.

1|Updated Oct 10, 2025
One-click install
npx skills add https://github.com/Rocktown-Labs/rivercitymd --skill convex-functions-rocktown-labs
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: convex-functions
Source: https://github.com/Rocktown-Labs/rivercitymd/tree/main/.cursor/skills/convex-functions
Command: npx skills add https://github.com/Rocktown-Labs/rivercitymd --skill convex-functions-rocktown-labs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Convex backend functions correctly requires knowing when to use queries versus mutations versus actions, how to validate arguments and return values, and how to handle errors and external API calls. This Skill provides the patterns and rules to implement Convex functions without common mistakes. ## Core Features & Use Cases - Function Type Guidance: Clear rules for choosing between reactive queries, transactional mutations, external-API actions, and HTTP webhook endpoints. - Validation & Error Handling: Enforces args and returns validators with convex/values and ConvexError for user-facing failures. - Internal Functions & Scheduling: Patterns for internalMutation/internalAction to protect sensitive logic and ctx.scheduler for deferred execution. - Use Case: When adding a Stripe webhook to a Next.js + Convex app, use this Skill to create an HTTP action that verifies the signature and routes the event to an internal mutation that updates payment records. ## Quick Start Write a Convex mutation that creates an appointment with argument validation, a not-found error, and a scheduled reminder notification.

Frequently Asked Questions about convex-functions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a Convex mutation with argument validation?▼

Define the mutation with the mutation function from _generated/server, specify args using validators from convex/values like v.string() or v.id(), and declare a returns validator. Throw ConvexError inside the handler for user-facing validation failures.

When should I use a Convex action instead of a mutation?▼

Use an action only when calling external APIs, since actions have no direct database access and must use ctx.runQuery or ctx.runMutation for data. Use mutations for transactional database writes and queries for cached, reactive reads.

Can Convex actions use Node.js APIs like fetch or fs?▼

Actions can call external APIs with fetch by default, but using Node.js-specific APIs requires adding the "use node"; directive at the top of the file. Queries and mutations always run in the Convex runtime without Node.js access.

How do I create a Stripe webhook endpoint in Convex?▼

Define an HTTP action in convex/http.ts using httpRouter, route the POST path, verify the stripe-signature header against the raw request body, then forward the event to an internal mutation via ctx.runMutation to update payment records.

Why should sensitive Convex functions be internal?▼

Internal functions created with internalMutation, internalQuery, or internalAction cannot be called from client code, only from other Convex functions. This protects privileged operations like credit adjustments or webhook handlers from direct public access.