Agent skill

convex-backend-development

Develop and maintain Convex backend functions including queries, mutations, and actions. Use when working with database operations, authentication, game management, scoring logic, and real-time data updates in the dev-quiz-battle app.

Stars 0
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/violabg/dev-quiz-battle/tree/main/skills/convex-backend-development

Metadata

Additional technical details for this skill

author
dev-quiz-battle
version
1.0

SKILL.md

Convex Backend Development

This skill covers building and maintaining Convex backend functions for the dev-quiz-battle application.

Step-by-step instructions

1. Understanding the Project Structure

The Convex backend is located in the convex/ directory with:

  • queries/ - Read-only functions (games, users, answers, leaderboard)
  • mutations/ - Write operations (creating games, submitting answers, updating user scores)
  • actions/ - Long-running operations (AI question generation)
  • schema.ts - Database schema definition
  • auth.ts - Authentication configuration

2. Creating Queries

Queries fetch data from the database without modifying it. Common patterns:

typescript
import { query } from "convex/server";
import { v } from "convex/values";

export const getGameData = query({
  args: { gameCode: v.string() },
  handler: async (ctx, args) => {
    const game = await ctx.db
      .query("games")
      .filter((q) => q.eq(q.field("code"), args.gameCode))
      .first();
    return game;
  },
});

3. Creating Mutations

Mutations modify the database state. Always validate input:

typescript
import { mutation } from "convex/server";
import { v } from "convex/values";

export const createGame = mutation({
  args: { creatorId: v.id("users"), language: v.string() },
  handler: async (ctx, args) => {
    const gameId = await ctx.db.insert("games", {
      creatorId: args.creatorId,
      language: args.language,
      code: generateUniqueCode(),
      status: "waiting",
      createdAt: Date.now(),
    });
    return gameId;
  },
});

4. Creating Actions

Actions handle async operations like API calls:

typescript
import { action } from "convex/server";
import { v } from "convex/values";

export const generateQuestion = action({
  args: { language: v.string(), difficulty: v.string() },
  handler: async (ctx, args) => {
    // Call external API or perform async work
    const response = await fetch("https://api.example.com/questions");
    return response.json();
  },
});

5. Using Authentication

Access the authenticated user:

typescript
const identity = await ctx.auth.getUserIdentity();
if (!identity) {
  throw new Error("Not authenticated");
}
const userId = identity.subject;

6. Validation Patterns

Always validate arguments using Convex validators:

typescript
args: {
  email: v.string(),
  password: v.string(),
  language: v.string(),
}

Common Edge Cases

  • Invalid game codes: Check if game exists before operations
  • Concurrent submissions: Use game status to prevent duplicate answers
  • User authentication: Always verify identity for sensitive mutations
  • Score calculations: Account for time-based bonuses and difficulty multipliers

Key Files to Reference

See Convex Schema Reference for complete schema definition.

Expand your agent's capabilities with these related and highly-rated skills.

violabg/dev-quiz-battle

next-best-practices

Next.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling

0 0
Explore
violabg/dev-quiz-battle

vercel-react-best-practices

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

0 0
Explore
violabg/dev-quiz-battle

shadcn

Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI. Provides project context, component docs, and usage examples. Applies when working with shadcn/ui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for "shadcn init", "create an app with --preset", or "switch to --preset".

0 0
Explore
violabg/dev-quiz-battle

frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.

0 0
Explore
violabg/dev-quiz-battle

convex

Umbrella skill for all Convex development patterns. Routes to specific skills like convex-functions, convex-realtime, convex-agents, etc.

0 0
Explore
violabg/dev-quiz-battle

tailwind-theme-styling

Style the dev-quiz-battle app using Tailwind CSS v4 with OKLCH colors, dark mode support, and modern design patterns. Use when creating responsive layouts, applying themes, and implementing visual components.

0 0
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results