function-creator

Create type-safe Convex query, mutation, and action functions with validators and auth checks.

Updated Jun 8, 2024
One-click install
npx skills add https://github.com/shadeiskndr/portfolio --skill function-creator-shadeiskndr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: function-creator
Source: https://github.com/shadeiskndr/portfolio/tree/main/.agents/skills/function-creator
Command: npx skills add https://github.com/shadeiskndr/portfolio --skill function-creator-shadeiskndr

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It removes the friction of writing Convex query, mutation, and action functions by standardizing validation, authentication, authorization, and error-handling patterns so your backend endpoints are consistent and safe.

Core Features & Use Cases

  • Type-safe Convex API generation: Produce queries, mutations, and actions with explicit args validators and returns type schemas.
  • Secure auth + authorization checks: Enforce ctx.auth.getUserIdentity() for public endpoints and ownership/permission checks against stored resources.
  • Correct API semantics: Use queries for read-only data, mutations for transactional writes, and actions for external/long-running work (including handling the "use node" requirement for Node.js APIs).
  • Use Case: Implement a new “tasks” endpoint by defining a validated query to fetch task details, a mutation to create/update tasks with user ownership, and an action to call an external service and optionally update the database through ctx.runMutation.

Quick Start

Use the function-creator skill to implement a new Convex endpoint by asking it to generate the correct query/mutation/action with validators, returns schemas, auth checks, and the appropriate Node.js handling directive.

Frequently Asked Questions about function-creator

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

FAQPage Schema
How do I generate type-safe Convex query and mutation functions with argument validation?

To generate type-safe Convex functions, define explicit args validators and returns schemas for your queries and mutations. This ensures argument validation and consistent return types for read-only data access and transactional writes.

How do I add authentication and authorization checks to a Convex backend API?

Add authentication to Convex APIs by enforcing ctx.auth.getUserIdentity() for public endpoints and implementing ownership checks against stored database records. This ensures only authorized users can access or modify specific resources.

When do I need to use the "use node" directive in Convex action functions?

Use the "use node" directive in Convex action functions only when the action requires Node.js APIs. Actions are intended for external service calls or long-running operations that may optionally update the database through ctx.runMutation.

What is the difference between Convex queries, mutations, and actions for API development?

Convex queries handle read-only data access, mutations manage transactional writes, and actions handle external or long-running operations. Correct API semantics require using these distinct function types for their specific data access and modification purposes.

Does Convex support explicit return type schemas for backend functions?

Yes, Convex supports explicit returns type schemas. Defining return schemas alongside argument validators standardizes validation, authentication, and error-handling patterns so your backend endpoints remain consistent and type-safe.

Why does my Convex mutation fail without proper argument validation?

Convex mutations require explicit args validators to ensure type safety and correct API semantics. Without proper argument validation, transactional writes lack the necessary constraints to process data safely and consistently.