convex-functions

Implements Convex queries, mutations, actions, and HTTP actions with argument validation and error handling.

Updated Jun 28, 2026
One-click install
npx skills add https://github.com/AO-HyS/aohys.com --skill convex-functions-ao-hys
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: convex-functions
Source: https://github.com/AO-HyS/aohys.com/tree/main/.agents/skills/convex-functions
Command: npx skills add https://github.com/AO-HyS/aohys.com --skill convex-functions-ao-hys

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Convex backend functions correctly requires knowing when to use queries, mutations, actions, or HTTP actions, plus proper argument validation and error handling. This Skill provides patterns and code examples that prevent common mistakes like calling external APIs from queries or skipping return validators. ## 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 on every function, ConvexError for user-facing failures, and internal functions for sensitive operations. - Use Case: When building a chat backend, use this Skill to write a query listing channel messages with an index, a mutation that validates input and inserts messages, and an internal mutation scheduled to notify subscribers. ## Quick Start Write a Convex mutation that creates a task with argument validation and throws a ConvexError if the user does not exist.

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 query with argument validation?▼

Define the query with the query function from ./_generated/server, passing an object with args using v validators, a returns validator, and a handler. Use ctx.db.query with withIndex for indexed lookups and collect or take for results.

What is the difference between Convex queries, mutations, and actions?▼

Queries are read-only, cached, and reactive. Mutations perform transactional database writes. Actions can call external APIs but access the database only indirectly through runQuery and runMutation.

Can Convex mutations call external APIs like Stripe?▼

No, mutations and queries cannot make network requests. Use an action to call the external API, then persist results by invoking a mutation through ctx.runMutation, typically an internalMutation for sensitive updates.

How do I create an HTTP webhook endpoint in Convex?▼

Define routes in convex/http.ts using httpRouter and httpAction. Each route specifies a path and method, and the handler receives the request, verifies signatures, and calls internal mutations via ctx.runMutation.

Why does my Convex action fail when using Node.js APIs?▼

Convex actions run in a custom runtime by default without Node.js built-ins. Add "use node"; at the top of the file to run the action in the Node.js runtime with access to Node APIs.

When should I use internal functions in Convex?▼

Use internalMutation, internalQuery, and internalAction for sensitive logic that must not be exposed to clients, such as credit adjustments or webhook handlers. They are only callable from other Convex functions or scheduled jobs.