Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

convex

БесплатноБез исполняемых скриптовНе проверен

Convex is a reactive backend where the database, server functions and file storage are written in TypeScript and query results update live in every connected…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Convex

Overview

Convex runs your TypeScript server functions next to a transactional document database. Queries are reactive: a useQuery subscription re-renders when the data it read changes, with no WebSocket, polling or cache-invalidation code. Mutations are ACID transactions with optimistic concurrency control. Functions live in the convex/ folder and are called through the generated api object.

Three function kinds: query (read-only, reactive, deterministic), mutation (transactional writes), action (may call external APIs, not transactional, can run queries and mutations through ctx.runQuery and ctx.runMutation). Use internalQuery, internalMutation and internalAction for functions that only other Convex functions may call.

Instructions

Step 1: Create the project

$ npm create convex@latest          # new app with Convex wired in
$ npm install convex                # or add to an existing app
$ npx convex dev                    # logs in, creates a deployment, syncs convex/ and writes convex/_generated

npx convex dev keeps running and pushes every change to your dev deployment; it writes the deployment URL to .env.local (for Vite, VITE_CONVEX_URL). Never commit deploy keys; production deploys use npx convex deploy with CONVEX_DEPLOY_KEY set in CI.

Step 2: Schema and indexes

// convex/schema.ts
import { defineSchema, defineTable } from "convex/server";
import { v } from "convex/values";

export default defineSchema({
  messages: defineTable({
    channel: v.string(),
    author: v.string(),
    body: v.string(),
    imageId: v.optional(v.id("_storage")),
  })
    .index("by_channel", ["channel"])
    .searchIndex("search_body", { searchField: "body", filterFields: ["channel"] }),
});

Every document also gets _id and _creationTime; by_channel implicitly ends with _creationTime, so results come back in creation order. Use .withIndex(...) rather than .filter(...) for anything that must scale.

Step 3: Functions

Functions take an object with args validators and a handler.

// convex/messages.ts
import { query, mutation } from "./_generated/server";
import { v } from "convex/values";
import { paginationOptsValidator } from "convex/server";

export const list = query({
  args: { channel: v.string(), paginationOpts: paginationOptsValidator },
  handler: async (ctx, args) =>
    ctx.db.query("messages").withIndex("by_channel", (q) => q.eq("channel", args.channel)).order("desc").paginate(args.paginationOpts),
});

export const send = mutation({
  args: { channel: v.string(), body: v.string() },
  handler: async (ctx, args) => {
    const identity = await ctx.auth.getUserIdentity();
    if (identity === null) throw new Error("Not signed in");
    await ctx.db.insert("messages", {
      channel: args.channel,
      author: identity.name ?? identity.tokenIdentifier,
      body: args.body,
    });
  },
});

Step 4: Use it from React

import { useMutation, usePaginatedQuery } from "convex/react";
import { api } from "../convex/_generated/api";

export function Channel({ name }: { name: string }) {
  const { results, status, loadMore } = usePaginatedQuery(api.messages.list, { channel: name }, { initialNumItems: 25 });
  const send = useMutation(api.messages.send);
  return (
    <>
      {results.map((m) => <p key={m._id}>{m.author}: {m.body}</p>)}
      {status === "CanLoadMore" && <button onClick={() => loadMore(25)}>Older</button>}
      <button onClick={() => send({ channel: name, body: "deploy finished" })}>Post</button>
    </>
  );
}

Wrap the app in ConvexProvider with new ConvexReactClient(import.meta.env.VITE_CONVEX_URL). Use useQuery(api.x.y, args) for non-paginated reads, and useMutation(...).withOptimisticUpdate((localStore, args) => ...) to show a change before the server confirms.

Step 5: Auth, files, scheduling, search

  • Auth: integrate Clerk, Auth0 or WorkOS AuthKit, or use Convex Auth (@convex-dev/auth, documented as beta). In functions call ctx.auth.getUserIdentity(); it returns null when not signed in.
  • File upload: a mutation returns await ctx.storage.generateUploadUrl() (valid one hour); the client POSTs the file to it and receives { storageId }, which another mutation saves. Serve with await ctx.storage.getUrl(storageId). ctx.storage.store(blob) exists only in actions and HTTP actions.
  • Scheduling: await ctx.scheduler.runAfter(60_000, internal.billing.retryCharge, { orderId }) from a mutation or action. Recurring jobs go in convex/crons.ts using cronJobs() with crons.interval, crons.daily, crons.cron; avoid minute 0 of the hour.
  • Full-text search: ctx.db.query("messages").withSearchIndex("search_body", (q) => q.search("body", "deploy failed").eq("channel", "ops")).take(10).
  • Vector search: declare `.vectorIndex("by_embedding", { vectorField: "embedding", dimensions: 1536, filterFields: ["cui
Полный SKILL.md на GitHub

Установить convex в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл convex?

Convex is a reactive backend where the database, server functions and file storage are written in TypeScript and query results update live in every connected client. Use when building a Convex app: schema and indexes, queries, mutations and actions, useQuery and useMutation in React, auth, pagination, file uploads, scheduled functions and cron jobs, full-text and vector search. Trigger words: convex, reactive backend, convex schema, convex functions, npx convex dev.

Как установить скилл convex?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл convex запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить convex с