Agent skill

Convex Best Practices

by waynesutton in waynesutton/builder-skills

Production patterns for Convex apps and the rules the @convex-dev/eslint-plugin enforces: validators, indexes, idempotent mutations, avoiding OCC conflicts, thin function wrappers, error handling.

Apache-2.0Auto-check passedDevelopment

Install Convex Best Practices

skills CLI
$ npx skills add waynesutton/builder-skills --skill convex-best-practices -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install waynesutton/builder-skills convex-best-practices --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/waynesutton/builder-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/convex-best-practices .claude/skills/convex-best-practices && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
convex-best-practices
GitHub stars
406
Token cost
~2.6k tokens
SKILL.md length
794 words
Files
5 (incl. references, assets)
Skills in repo
17
Repo updated
First seen
Licence
Apache-2.0

At a glance

Production patterns for Convex apps and the rules the @convex-dev/eslint-plugin enforces: validators, indexes, idempotent mutations, avoiding OCC conflicts, thin function wrappers, error handling.

  • Works in 8 steps: Validators on every function. args and… → Indexes, not filters. Every table read… → Idempotent mutations. Return early when… → …
  • Reviewing Convex code
  • SKILL.md covers Rules that matter most, OCC and write conflicts, Pagination over collect and No Date.now() in queries, plus 4 more sections
  • Calls npm

What it does

Convex Best Practices is an agent skill from waynesutton/builder-skills. Production patterns for Convex apps and the rules the @convex-dev/eslint-plugin enforces: validators, indexes, idempotent mutations, avoiding OCC conflicts, thin function wrappers, error handling. Use when reviewing Convex code, asking whether a pattern is right, setting up ESLint, or fixing write conflicts and slow queries.

Its SKILL.md is about 2.6k tokens, which your agent loads only when the skill is triggered. The skill folder holds 7 other files, including reference files and assets (for example `agents/openai.yaml` and `references/eslint-setup.md`).

It sits in Development, covering Linting and formatting and Query optimization. It works with ESLint and Convex. The repository describes itself as: Builder skills for Convex apps. Convex patterns plus a PRD, task.md, changelog, and files.md workflow for Claude Code, Codex, Cursor, and OpenCode. The licence is Apache-2.0.

When your agent uses it

  • Reviewing Convex code
  • Asking whether a pattern is right
  • Setting up ESLint
  • Fixing write conflicts and slow queries

Example prompts

  • “/convex-best-practices”

Requirements

  • Node.js

Workflow steps

8 steps, taken from the first numbered list in SKILL.md.

  1. Validators on every function. args and returns, with returns: v.null() when nothing comes back.
  2. Indexes, not filters. Every table read goes through withIndex against an index in convex/schema.ts.
  3. Idempotent mutations. Return early when the document is already in the target state so retries are safe.
  4. Patch without reading first. ctx.db.patch(id, fields) throws if the doc is missing; you rarely need the old value.
  5. Promise.all for independent writes. Do not await them one at a time.
  6. Schedule internal.* only. Crons and ctx.scheduler run without a client, so public targets skip auth.
  7. Thin wrappers. Auth and business logic live in plain helpers that take ctx.
  8. ConvexError for anything a client should read. Plain Error messages are redacted in production.

What it can do on your machine

Read from SKILL.md and the folder at commit 82d1ce2. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • docs.convex.dev

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Convex Best Practices loads about 2.6k tokens when it runs, and up to ~3.8k if it reads all its reference files. Until then it costs about 87 tokens; SKILL.md has 794 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~87
When it runs · the whole SKILL.md, loaded when a task matches
~2.6k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~3.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from waynesutton/builder-skills at commit 82d1ce2, republished under its Apache-2.0 licence (© waynesutton). 794 words, ~2,571 tokens.

Download SKILL.mdSave it as .claude/skills/convex-best-practices/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
convex-best-practices
description
Production patterns for Convex apps and the rules the @convex-dev/eslint-plugin enforces: validators, indexes, idempotent mutations, avoiding OCC conflicts, thin function wrappers, error handling. Use when reviewing Convex code, asking whether a pattern is right, setting up ESLint, or fixing write conflicts and slow queries.

Convex best practices

The patterns that keep a Convex app fast and correct in production. The rule that matters most: read as little as possible before you write, and read through an index.

Rules that matter most

  1. Validators on every function. args and returns, with returns: v.null() when nothing comes back.
  2. Indexes, not filters. Every table read goes through withIndex against an index in convex/schema.ts.
  3. Idempotent mutations. Return early when the document is already in the target state so retries are safe.
  4. Patch without reading first. ctx.db.patch(id, fields) throws if the doc is missing; you rarely need the old value.
  5. Promise.all for independent writes. Do not await them one at a time.
  6. Schedule internal.* only. Crons and ctx.scheduler run without a client, so public targets skip auth.
  7. Thin wrappers. Auth and business logic live in plain helpers that take ctx.
  8. ConvexError for anything a client should read. Plain Error messages are redacted in production.
typescript
// convex/tasks.ts
import { query, mutation } from "./_generated/server";
import { v, ConvexError } from "convex/values";

const taskValidator = v.object({
  _id: v.id("tasks"),
  _creationTime: v.number(),
  userId: v.id("users"),
  title: v.string(),
  status: v.union(v.literal("open"), v.literal("done")),
});

export const listOpen = query({
  args: { userId: v.id("users") },
  returns: v.array(taskValidator),
  handler: async (ctx, args) => {
    return await ctx.db
      .query("tasks")
      .withIndex("by_user_and_status", (q) =>
        q.eq("userId", args.userId).eq("status", "open"),
      )
      .order("desc")
      .take(100);
  },
});

export const rename = mutation({
  args: { taskId: v.id("tasks"), title: v.string() },
  returns: v.null(),
  handler: async (ctx, args) => {
    if (args.title.trim().length === 0) {
      throw new ConvexError("Title cannot be empty");
    }
    await ctx.db.patch(args.taskId, { title: args.title.trim() });
    return null;
  },
});

The schema behind that index:

typescript
tasks: defineTable({
  userId: v.id("users"),
  title: v.string(),
  status: v.union(v.literal("open"), v.literal("done")),
})
  .index("by_user", ["userId"])
  .index("by_user_and_status", ["userId", "status"]),

Name indexes after their fields in order, and query fields in that same order.

OCC and write conflicts

Convex runs mutations under optimistic concurrency control. A mutation records what it read. If another mutation commits a change to any of that data first, Convex retries it. After enough retries it fails and the client sees a write conflict error.

Conflicts come from three places:

  • Two mutations writing the same document at once: counters, "last seen" fields, a shared settings doc
  • A mutation that reads a wide range, such as .collect() on a whole table, so any change in that range conflicts with it
  • A client calling the same mutation faster than it can commit: typing, dragging, polling
Idempotent and patch first
typescript
export const complete = mutation({
  args: { taskId: v.id("tasks") },
  returns: v.null(),
  handler: async (ctx, args) => {
    const task = await ctx.db.get(args.taskId);
    if (!task || task.status === "done") {
      return null;
    }
    await ctx.db.patch(args.taskId, { status: "done" });
    return null;
  },
});

export const reorder = mutation({
  args: { itemIds: v.array(v.id("items")) },
  returns: v.null(),
  handler: async (ctx, args) => {
    await Promise.all(
      args.itemIds.map((id, index) => ctx.db.patch(id, { order: index })),
    );
    return null;
  },
});

The read in complete is fine: one document, early exit. reorder never reads at all.

Event records instead of counters

A counter field on one document is the most common conflict source. Insert one row per event and count in a query.

typescript
export const trackView = mutation({
  args: { pageId: v.id("pages") },
  returns: v.null(),
  handler: async (ctx, args) => {
    await ctx.db.insert("pageViews", { pageId: args.pageId });
    return null;
  },
});

export const viewCount = query({
  args: { pageId: v.id("pages") },
  returns: v.number(),
  handler: async (ctx, args) => {
    const views = await ctx.db
      .query("pageViews")
      .withIndex("by_page", (q) => q.eq("pageId", args.pageId))
      .collect();
    return views.length;
  },
});

Once the event table gets large, move the count to the @convex-dev/sharded-counter or @convex-dev/aggregate component instead of collecting rows.

Dedup windows

For heartbeats and presence, skip the write when the last one was recent. Pair it with a client side debounce: 300 to 500 ms for typing, a few seconds for heartbeats.

typescript
const DEDUP_MS = 10_000;

export const heartbeat = mutation({
  args: { sessionId: v.string(), path: v.string() },
  returns: v.null(),
  handler: async (ctx, args) => {
    const now = Date.now();
    const existing = await ctx.db
      .query("sessions")
      .withIndex("by_session", (q) => q.eq("sessionId", args.sessionId))
      .unique();
    if (!existing) {
      await ctx.db.insert("sessions", { ...args, lastSeen: now });
      return null;
    }
    if (existing.path === args.path && now - existing.lastSeen < DEDUP_MS) {
      return null;
    }
    await ctx.db.patch(existing._id, { path: args.path, lastSeen: now });
    return null;
  },
});

Put hot fields such as lastSeen in their own table so those writes do not conflict with reads of the stable document.

Pagination over collect

.collect() on an unbounded table gets slower every day and eventually hits read limits. Paginate anything a user can grow. postValidator below is a hoisted document validator like taskValidator above.

typescript
import { paginationOptsValidator } from "convex/server";

export const feed = query({
  args: { userId: v.id("users"), paginationOpts: paginationOptsValidator },
  returns: v.object({
    page: v.array(postValidator),
    isDone: v.boolean(),
    continueCursor: v.string(),
    splitCursor: v.optional(v.union(v.string(), v.null())),
    pageStatus: v.optional(
      v.union(v.literal("SplitRecommended"), v.literal("SplitRequired"), v.null()),
    ),
  }),
  handler: async (ctx, args) => {
    return await ctx.db
      .query("posts")
      .withIndex("by_user", (q) => q.eq("userId", args.userId))
      .order("desc")
      .paginate(args.paginationOpts);
  },
});

On the client, usePaginatedQuery from convex/react drives loadMore.

No Date.now() in queries

Queries must be deterministic so Convex can cache them and rerun them when data changes. Pass time from the client, or store a status field that a scheduled mutation updates.

typescript
export const dueBefore = query({
  args: { userId: v.id("users"), now: v.number() },
  returns: v.array(taskValidator),
  handler: async (ctx, args) => {
    return await ctx.db
      .query("tasks")
      .withIndex("by_user_and_due", (q) =>
        q.eq("userId", args.userId).lt("dueAt", args.now),
      )
      .take(100);
  },
});

Mutations and actions may call Date.now().

Show full SKILL.md (309 more words)Show less

ESLint plugin

@convex-dev/eslint-plugin catches the old function syntax, missing arg validators, .filter() in queries, and top of the hour crons at lint time. Install it in every Convex project.

bash
npm i --save-dev @convex-dev/eslint-plugin
js
// eslint.config.js
import { defineConfig } from "eslint/config";
import convexPlugin from "@convex-dev/eslint-plugin";

export default defineConfig([...convexPlugin.configs.recommended]);

Open references/eslint-setup.md when you need the full rule list, the TypeScript aware config, package scripts, or a custom convex/ directory.

Common mistakes

MistakeWhy it breaksDo instead
.filter() on a table queryReads every row, then drops mostAdd an index, use withIndex
.collect() on an unbounded tableSlower every day, hits read limits, wide OCC footprint.paginate() or .take(n)
Read, compute, then patch a shared docTwo clients read the same version and both writePatch directly, or split into event rows
Counter field incremented per eventEvery increment conflicts with every otherEvent records or a sharded counter component
Mutation without an early returnRetries and double clicks apply the change twiceCheck state, return null if already done
Sequential await on independent writesSlow, and each read widens the conflict windowPromise.all
Date.now() in a queryResult changes every ms, cache and subscriptions breakPass now as an arg
Scheduling api.*Public function runs with no client authSchedule internal.*
Plain Error for user messagesRedacted to "Server Error" in productionConvexError
Business logic inside the handlerUntestable, duplicated across functionsPlain helper that takes ctx

Checklist

  • Every function has args and returns
  • Every table read uses withIndex, never .filter()
  • Indexes are named after their fields in order
  • Mutations return early when the doc is already in the target state
  • Mutations patch without a prior read unless the old value is needed
  • Independent writes run under Promise.all
  • High frequency counts use event rows or a counter component
  • Unbounded lists use .paginate()
  • No Date.now() inside a query
  • Scheduled and cron targets are internal.*
  • @convex-dev/eslint-plugin is installed and npm run lint passes

Docs

© waynesutton, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (references, assets) in skills/convex-best-practices of waynesutton/builder-skills.

  • SKILL.md
  • agents/openai.yaml
  • assets/large-logo.png
  • assets/small-logo.svg
  • references/eslint-setup.md

Open the folder on GitHubat commit 82d1ce2

Compare with similar skills

Convex Best Practices next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Convex Best Practices compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Convex Best Practices this skillwaynesutton/builder-skills406—~2.6kAutomated safety check: PassApache-2.0
LobeHub Alint Rule Set Maintenancelobehub/lobehub83k—~1.9kAutomated safety check: PassCustom licence
Eslint Migrate Optionsbiomejs/biome26k—~1.4kAutomated safety check: PassApache-2.0
Ultraciteagustinusnathaniel/nextarter-tailwind1252 repos~1.2kAutomated safety check: PassMIT
Code Qualityredis/RedisInsight8.9k—~1.2kAutomated safety check: PassCustom licence
Boundaries Architectjavierbrea/eslint-plugin-boundaries997—~4.2kAutomated safety check: PassMIT

Similar skills

  • Maintains LobeHub's model-backed alint rule set: writing rules, removing false positives against real code, deciding warn versus error and tracking token cost.

    83k GitHub stars~1.9k tokensUpdated today
    DevelopmentAuto-check passed
  • Official

    A skill your agent uses when biome migrate eslint must preserve configurable ESLint rule options through source-option models, Biome conversions, typed rule variants, and migration fixtures.

    26k GitHub stars~1.4k tokensUpdated today
    DevelopmentAuto-check passed
  • Ultracite

    agustinusnathaniel/nextarter-tailwind

    Ultracite is a zero-config linting and formatting preset for JavaScript/TypeScript projects.

    125 GitHub starsUsed in 2 repos~1.2k tokens
    DevelopmentAuto-check passed
  • Code Quality

    redis/RedisInsight

    Official

    Code-quality standards for RedisInsight: TypeScript strictness, naming conventions (camelCase, PascalCase, UPPERSNAKECASE), linting rules, no any without reason, no !important in styles, and…

    8.9k GitHub stars~1.2k tokensUpdated 4 days ago
    DevelopmentAuto-check passed
  • Boundaries Architect

    javierbrea/eslint-plugin-boundaries

    Act as a software architect: analyze a repository's folder structure and cross-file import dependencies, detect its architectural pattern, design element/file boundaries with the user, and configure…

    997 GitHub stars~4.2k tokensUpdated today
    DevelopmentAuto-check passed
  • Port Rule

    web-infra-dev/rslint

    Port a new ESLint core or plugin rule to rslint, including explicitly requested batches.

    461 GitHub stars~1.7k tokensUpdated today
    DevelopmentAuto-check passed

More from waynesutton/builder-skills

All 17 skills in this repo
  • Convex Agents

    waynesutton/builder-skills

    Builds AI agents on the Convex agent component: threads, messages, tools that call queries and mutations, streaming, RAG with vector search, and workflows for multi step jobs.

    406 GitHub stars~2.2k tokensUpdated 11 days ago
    Auto-check passed
  • Convex Component Authoring

    waynesutton/builder-skills

    Creates reusable Convex components with defineComponent, a clean client wrapper, their own schema, and an npm publish setup.

    406 GitHub stars~2.6k tokensUpdated 11 days ago
    Auto-check passed
  • Convex Cron Jobs

    waynesutton/builder-skills

    Schedules work in Convex: cron jobs in convex/crons.ts, one off scheduled functions with runAfter and runAt, batching large jobs, and cancelling or inspecting the queue.

    406 GitHub stars~2k tokensUpdated 11 days ago
    Auto-check passed
  • Convex HTTP Actions

    waynesutton/builder-skills

    Adds HTTP endpoints in convex/http.ts: webhook receivers with signature checks, REST style routes, CORS, auth headers, streaming responses, and file uploads over HTTP.

    406 GitHub stars~2.6k tokensUpdated 11 days ago
    Auto-check passed
  • Convex Migrations

    waynesutton/builder-skills

    Changes a live Convex schema without downtime: make a field optional, backfill in batches, flip the validator, then clean up.

    406 GitHub stars~2.1k tokensUpdated 11 days ago
    Auto-check passed
  • Convex Security Audit

    waynesutton/builder-skills

    Deep security review of a Convex app: authorization model, data access paths per table, HTTP action exposure, rate limiting, file storage access, scheduled function trust, and a written findings…

    406 GitHub stars~2.6k tokensUpdated 11 days ago
    Auto-check passed

Works with

Categories

Questions about Convex Best Practices

What does Convex Best Practices do?

Production patterns for Convex apps and the rules the @convex-dev/eslint-plugin enforces: validators, indexes, idempotent mutations, avoiding OCC conflicts, thin function wrappers, error handling. Convex Best Practices is an agent skill from waynesutton/builder-skills. Production patterns for Convex apps and the rules the @convex-dev/eslint-plugin enforces: validators, indexes, idempotent mutations, avoiding OCC conflicts, thin function wrappers, error handling.

When should I use Convex Best Practices?

Convex Best Practices fits situations like: reviewing Convex code; asking whether a pattern is right; setting up ESLint; fixing write conflicts and slow queries.

How do I install Convex Best Practices in Claude Code?

Run `npx skills add waynesutton/builder-skills --skill convex-best-practices -a claude-code`. Or copy the skill folder (skills/convex-best-practices in waynesutton/builder-skills) into .claude/skills/convex-best-practices in your project. Claude Code loads it when a task matches its description.

How do I install Convex Best Practices in Codex?

Run `npx skills add waynesutton/builder-skills --skill convex-best-practices -a codex`. Or copy the skill folder (skills/convex-best-practices in waynesutton/builder-skills) into .agents/skills/convex-best-practices in your project. Codex loads it when a task matches its description.

Can I use Convex Best Practices in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add waynesutton/builder-skills --skill convex-best-practices -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/convex-best-practices, .gemini/skills/convex-best-practices, .github/skills/convex-best-practices and .opencode/skills/convex-best-practices in your project.

What does Convex Best Practices need to run?

Going by SKILL.md and its folder, Convex Best Practices needs the command-line tools its instructions call (npm). Our summary lists: Node.js.

Does Convex Best Practices access the network?

SKILL.md names 1 domain. As links in the text: docs.convex.dev. This is read from the text; nothing was executed.

Is Convex Best Practices safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Convex Best Practices use?

Convex Best Practices is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Convex Best Practices use?

About 2.6k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1.2k tokens, read only when the agent opens those files.

What are the alternatives to Convex Best Practices?

Skills that share tags, products or a category with Convex Best Practices: LobeHub Alint Rule Set Maintenance (lobehub/lobehub, 83k stars), Eslint Migrate Options (biomejs/biome, 26k stars), Ultracite (agustinusnathaniel/nextarter-tailwind, 125 stars) and Code Quality (redis/RedisInsight, 8.9k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Convex Best Practices?

waynesutton (a GitHub user) maintains it in waynesutton/builder-skills, which has 406 GitHub stars. The repository holds 17 skills in this directory. The repository was last updated on September 28, 2026.

Source: waynesutton/builder-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.