.claude/skills/convex-quickstart/SKILL.md
Initializes a new Convex project from scratch or adds Convex to an existing app. Use this skill when starting a new project with Convex, scaffolding with npm create convex@latest, adding Convex to an existing React, Next.js, Vue, Svelte, or other frontend, wiring up ConvexProvider, configuring environment variables for the deployment URL, or running npx convex dev for the first time, even if the user just says "set up Convex" or "add a backend."
npx skillsauth add RinKhimera/NOMAQbanq convex-quickstartInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Set up a working Convex project as fast as possible.
convex/ exists - just start buildingconvex-setup-auth skillnpm create convex@latestconvex and wire up the providernpx convex dev to connect a deployment and start the dev loopUse the official scaffolding tool. It creates a complete project with the frontend framework, Convex backend, and all config wired together.
| Template | Stack |
| -------------------------- | ----------------------------------------- |
| react-vite-shadcn | React + Vite + Tailwind + shadcn/ui |
| nextjs-shadcn | Next.js App Router + Tailwind + shadcn/ui |
| react-vite-clerk-shadcn | React + Vite + Clerk auth + shadcn/ui |
| nextjs-clerk | Next.js + Clerk auth |
| nextjs-convexauth-shadcn | Next.js + Convex Auth + shadcn/ui |
| nextjs-lucia-shadcn | Next.js + Lucia auth + shadcn/ui |
| bare | Convex backend only, no frontend |
If the user has not specified a preference, default to react-vite-shadcn for simple apps or nextjs-shadcn for apps that need SSR or API routes.
You can also use any GitHub repo as a template:
npm create convex@latest my-app -- -t owner/repo
npm create convex@latest my-app -- -t owner/repo#branch
Always pass the project name and template flag to avoid interactive prompts:
npm create convex@latest my-app -- -t react-vite-shadcn
cd my-app
npm install
The scaffolding tool creates files but does not run npm install, so you must run it yourself.
To scaffold in the current directory (if it is empty):
npm create convex@latest . -- -t react-vite-shadcn
npm install
npx convex dev is a long-running watcher process that syncs backend code to a Convex deployment on every save. It also requires authentication on first run (browser-based OAuth). Both of these make it unsuitable for an agent to run directly.
Ask the user to run this themselves:
Tell the user to run npx convex dev in their terminal. On first run it will prompt them to log in or develop anonymously. Once running, it will:
.env.localconvex/ directory with generated typesThe user should keep npx convex dev running in the background while you work on code. The watcher will automatically pick up any files you create or edit in convex/.
Exception - cloud or headless agents: Environments that cannot open a browser for interactive login should use Agent Mode (see below) to run anonymously without user interaction.
The user should also run the frontend dev server in a separate terminal:
npm run dev
Vite apps serve on http://localhost:5173, Next.js on http://localhost:3000.
After scaffolding, the project structure looks like:
my-app/
convex/ # Backend functions and schema
_generated/ # Auto-generated types (check this into git)
schema.ts # Database schema (if template includes one)
src/ # Frontend code (or app/ for Next.js)
package.json
.env.local # CONVEX_URL / VITE_CONVEX_URL / NEXT_PUBLIC_CONVEX_URL
The template already has:
ConvexProvider wired into the app rootProceed to adding schema, functions, and UI.
Use this when the user already has a frontend project and wants to add Convex as the backend.
npm install convex
Ask the user to run npx convex dev in their terminal. This handles login, creates the convex/ directory, writes the deployment URL to .env.local, and starts the file watcher. See the notes in Path 1 about why the agent should not run this directly.
The Convex client must wrap the app at the root. The setup varies by framework.
Create the ConvexReactClient at module scope, not inside a component:
// Bad: re-creates the client on every render
function App() {
const convex = new ConvexReactClient(
import.meta.env.VITE_CONVEX_URL as string,
)
return <ConvexProvider client={convex}>...</ConvexProvider>
}
// Good: created once at module scope
const convex = new ConvexReactClient(import.meta.env.VITE_CONVEX_URL as string)
function App() {
return <ConvexProvider client={convex}>...</ConvexProvider>
}
// src/main.tsx
import { ConvexProvider, ConvexReactClient } from "convex/react"
import { StrictMode } from "react"
import { createRoot } from "react-dom/client"
import App from "./App"
const convex = new ConvexReactClient(import.meta.env.VITE_CONVEX_URL as string)
createRoot(document.getElementById("root")!).render(
<StrictMode>
<ConvexProvider client={convex}>
<App />
</ConvexProvider>
</StrictMode>,
)
// app/ConvexClientProvider.tsx
"use client"
import { ConvexProvider, ConvexReactClient } from "convex/react"
import { ReactNode } from "react"
const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL!)
export function ConvexClientProvider({ children }: { children: ReactNode }) {
return <ConvexProvider client={convex}>{children}</ConvexProvider>
}
// app/layout.tsx
import { ConvexClientProvider } from "./ConvexClientProvider"
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body>
<ConvexClientProvider>{children}</ConvexClientProvider>
</body>
</html>
)
}
For Vue, Svelte, React Native, TanStack Start, Remix, and others, follow the matching quickstart guide:
The env var name depends on the framework:
| Framework | Variable |
| ------------ | ------------------------ |
| Vite | VITE_CONVEX_URL |
| Next.js | NEXT_PUBLIC_CONVEX_URL |
| Remix | CONVEX_URL |
| React Native | EXPO_PUBLIC_CONVEX_URL |
npx convex dev writes the correct variable to .env.local automatically.
When running in a cloud or headless agent environment where interactive browser login is not possible, set CONVEX_AGENT_MODE=anonymous to use a local anonymous deployment.
Add CONVEX_AGENT_MODE=anonymous to .env.local, or set it inline:
CONVEX_AGENT_MODE=anonymous npx convex dev
This runs a local Convex backend on the VM without requiring authentication, and avoids conflicting with the user's personal dev deployment.
After setup, confirm everything is working:
npx convex dev is running without errorsconvex/_generated/ directory exists and has api.ts and server.ts.env.local contains the deployment URLOnce the project is set up, create a schema and a query to verify the full loop works.
convex/schema.ts:
import { defineSchema, defineTable } from "convex/server"
import { v } from "convex/values"
export default defineSchema({
tasks: defineTable({
text: v.string(),
completed: v.boolean(),
}),
})
convex/tasks.ts:
import { v } from "convex/values"
import { mutation, query } from "./_generated/server"
export const list = query({
args: {},
handler: async (ctx) => {
return await ctx.db.query("tasks").collect()
},
})
export const create = mutation({
args: { text: v.string() },
handler: async (ctx, args) => {
await ctx.db.insert("tasks", { text: args.text, completed: false })
},
})
Use in a React component (adjust the import path based on your file location relative to convex/):
import { useMutation, useQuery } from "convex/react"
import { api } from "../convex/_generated/api"
function Tasks() {
const tasks = useQuery(api.tasks.list)
const create = useMutation(api.tasks.create)
return (
<div>
<button onClick={() => create({ text: "New task" })}>Add</button>
{tasks?.map((t) => (
<div key={t._id}>{t.text}</div>
))}
</div>
)
}
Always use npx convex dev during development. It runs against your personal dev deployment and syncs code on save.
When ready to ship, deploy to production:
npx convex deploy
This pushes to the production deployment, which is separate from dev. Do not use deploy during development.
convex-setup-auth skillconvex-create-component skillconvex-migration-helper skillnpm create convex@latest using appropriate templateconvex and wired up the providernpx convex dev running and connected to a deploymentconvex/_generated/ directory exists with types.env.local has the deployment URLtools
Sets up Convex authentication with user management, identity mapping, and access control. Use this skill when adding login or signup to a Convex app, configuring Convex Auth, Clerk, WorkOS AuthKit, Auth0, or custom JWT providers, wiring auth.config.ts, protecting queries and mutations with ctx.auth.getUserIdentity(), creating a users table with identity mapping, or setting up role-based access control, even if the user just says "add auth" or "make it require login."
testing
Audits and optimizes Convex application performance across hot-path reads, write contention, subscription cost, and function limits. Use this skill when a Convex feature is slow or expensive, npx convex insights shows high bytes or documents read, OCC conflict errors or mutation retries appear, subscriptions or UI updates are costly, functions hit execution or transaction limits, or the user mentions performance, latency, read amplification, or invalidation problems in a Convex app.
tools
Plans and executes safe Convex schema and data migrations using the widen-migrate-narrow workflow and the @convex-dev/migrations component. Use this skill when a deployment fails schema validation, existing documents need backfilling, fields need adding or removing or changing type, tables need splitting or merging, or a zero-downtime migration strategy is needed. Also use when the user mentions breaking schema changes, multi-deploy rollouts, or data transformations on existing Convex tables.
development
Designs and builds Convex components with isolated tables, clear boundaries, and app-facing wrappers. Use this skill when creating a new Convex component, extracting reusable backend logic into a component, building a third-party integration that owns its own tables, packaging Convex functionality for reuse, or when the user mentions defineComponent, app.use, ComponentApi, ctx.runQuery/runMutation across component boundaries, or wants to separate concerns into isolated Convex modules.