convex
Skill0 starsChanged 56 days agoMITView on GitHub
Convex patterns for schema, queries, mutations, and auth. Use before writing or reviewing Convex code in a repo with no `docs/convex.md`.
11 other projects use a version of this.
Adopted by
Most recently taken up by
- waynesutton/builder-skillstheir own version, first seen Sep 28, 2026
- get-convex/agent-skillstheir own version, first seen Sep 9, 2026
- FabienGreard/TouchGrassBartheir own version, first seen Sep 8, 2026
- getsentry/fridaytheir own version, first seen Aug 28, 2026
- sholajegede/mastra-vs-langchaintheir own version, first seen Jun 6, 2026
- yisiliu/agent-towntheir own version, first seen May 19, 2026
Used with
Projects with it also use convex-migration-helper, convex-performance-audit and 1 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
elpiartheraSkillconvex-migration-helper
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.
Also in 3 projects that use this
elpiartheraSkillconvex-performance-audit
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.
Also in 3 projects that use this
- +1 more from elpiarthera
Other versions11 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 11
- raroque/boop-agent★ 1.4ksame name
- waynesutton/builder-skills★ 404same name
- Mindrally/skills★ 266same name
- get-convex/agent-skills★ 63same name
- sholajegede/mastra-vs-langchain★ 18same name
- PolarCoding85/convex-agent-skillz★ 16same name
- FabienGreard/TouchGrassBar★ 4same name
- gmickel/my-claude-skills★ 4same name
- StillScripts/cursor-agents-manager★ 1same name
- yisiliu/agent-town★ 1same name
1 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- rules/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- design-planSkill
- frontend-designSkill
- new-projectSkill
- prdSkill
- prSkill
- retroSkill
- setup-hostingSkill
- standardsSkill
- unslopSkill
- writing-for-agentsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
16 rules. 0 are common, 3 are distinctive, and 13 are very specific to this project.
0
Common
Most of the 11 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Read this before writing or reviewing Convex schema, queries, mutations, actions, or auth.
- Very specific: line 12
Use userId: v.id("users") as the ownership field on every user-owned table.
- Very specific: line 13
Never use email as a foreign key.
- Very specific: line 14
Never join or filter across tables by email.
- Very specific: line 15
Every table with a userId field needs a by_userId index.
- Very specific: line 16
Use compound indexes for common filters, e.g.
- Very specific: line 21
Never trust client-supplied userId, email, role, or platformRole for authorization.
- Very specific: line 23
Every public Convex query/mutation that accepts userId must:
- Very specific: line 26
Use ctx.auth.getUserIdentity() as canonical actor identity and reject mismatches.
- Very specific: line 32
Do not use raw query/mutation for protected operations.
- Very specific: line 35
Prefer internalQuery/internalMutation for server-to-server work.
- Distinctive: line 84
Every list the UI shows comes from a query that already applied the view's filters.
- Very specific: line 86
Put each filter the view uses (status, date range, parent id, search text) in the query's args and apply it in the handler.
- Very specific: line 88
Run text search through a search index with .withSearchIndex().
- Very specific: line 89
Use .paginate() with usePaginatedQuery for any list that grows with usage.
- Distinctive: line 91
When a view needs a different subset, write a query for that subset rather than reusing a broader one.
“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Convex Patterns
Read this before writing or reviewing Convex schema, queries, mutations, actions, or auth.
User IDs & Data Ownership
- Use
userId: v.id("users")as the ownership field on every user-owned table. - Never use email as a foreign key. Email lives only on the
userstable. - Never join or filter across tables by email. Use
userId. - Every table with a
userIdfield needs aby_userIdindex. - Use compound indexes for common filters, e.g.
by_userId_status. - The
by_emailindex onusersexists only for Auth.js session lookup ingetAuthUser(). After that, useuser._id.
Authorization (non-negotiable)
Never trust client-supplied userId, email, role, or platformRole for authorization.
Every public Convex query/mutation that accepts userId must:
- Receive the canonical value derived from the authenticated NextAuth session.
- Enforce ownership and role checks in Convex against stored records.
- Use
ctx.auth.getUserIdentity()as canonical actor identity and reject mismatches.
Deny by default: missing auth, missing ownership, or identity mismatch fails immediately. No deterministic or default secret/key fallbacks in production. Development-only auth providers must be disabled in production builds.
Enforcement Pattern
- Do not use raw
query/mutationfor protected operations. Use shared wrappers:authenticatedQuery,authenticatedMutation,superAdmin*. - Public functions accepting
userIdmust callrequireAuthenticatedUserId(ctx, args.userId). - Admin operations enforce role checks inside Convex, not only in Next.js pages or server actions.
- Prefer
internalQuery/internalMutationfor server-to-server work.
For custom JWT auth with Convex:
convex/auth.config.tswith issuer, JWKS, and audience.- Short-lived server-minted JWTs for server-side Convex clients.
- A rotation-compatible JWKS endpoint.
File Organization
convex/
├── lib/auth.ts # Shared auth utilities
├── {domain}/
│ ├── queries.ts # Public queries
│ ├── mutations.ts # Public mutations
│ ├── internalQueries.ts # Server-to-server only
│ ├── internalMutations.ts
│ ├── actions.ts # External API calls
│ └── index.ts
├── schema.ts
└── _generated/Reference internal functions as internal.{domain}.internalQueries.fn, not .queries..
Auth Utilities (convex/lib/auth.ts)
export async function getAuthUser(ctx, requestedUserId?): Promise<Doc<"users"> | null>
export async function getAuthUserId(ctx, requestedUserId?): Promise<Id<"users"> | null>
export async function requireAuth(ctx, requestedUserId?): Promise<Doc<"users">>
export async function requireAuthUserId(ctx, requestedUserId?): Promise<Id<"users">>
export async function requireAuthenticatedUserId(ctx, requestedUserId?): Promise<Id<"users">>
export async function requireOwnership<T extends { userId: Id<"users"> }>(ctx, resource: T | null, name?): Promise<T>
export async function requirePremium(ctx): Promise<Doc<"users">>
export async function hasPremiumAccess(ctx): Promise<boolean>Frontend Hook (src/hooks/use-auth-user.ts)
export function useAuthUser() {
// { userId, user, isLoading, isAuthenticated, authArgs }
// authArgs builds query args with userId, or returns "skip"
}Server-Side Filtering
Every list the UI shows comes from a query that already applied the view's filters. The component renders what it receives.
- Put each filter the view uses (status, date range, parent id, search text) in the query's
argsand apply it in the handler. - Apply filters with
.withIndex(). A.collect()followed by a JS.filter()still reads every row, even on the server. - Run text search through a search index with
.withSearchIndex(). - Use
.paginate()withusePaginatedQueryfor any list that grows with usage. Keep.collect()for small, bounded sets. - Map documents to the fields the view renders before returning. Other users' emails, internal flags, and tokens stay on the server.
- When a view needs a different subset, write a query for that subset rather than reusing a broader one.
Query & Mutation Shape
// Good: filter, paginate, and select fields inside the query
export const listGoalsByStatus = query({
args: { userId: v.id("users"), status: goalStatus, paginationOpts: paginationOptsValidator },
handler: async (ctx, args) => {
const userId = await requireAuthenticatedUserId(ctx, args.userId);
const result = await ctx.db
.query("goals")
.withIndex("by_userId_status", (q) => q.eq("userId", userId).eq("status", args.status))
.paginate(args.paginationOpts);
return { ...result, page: result.page.map(({ _id, title, status }) => ({ _id, title, status })) };
},
});
// Good: filter by userId via index
export const getGoals = query({
args: { userId: v.id("users") },
handler: async (ctx, args) =>
ctx.db.query("goals").withIndex("by_userId", (q) => q.eq("userId", args.userId)).collect(),
});
// Good: verify ownership before writing
export const updateGoal = mutation({
args: { goalId: v.id("goals"), title: v.string() },
handler: async (ctx, args) => {
const goal = await ctx.db.get(args.goalId);
await requireOwnership(ctx, goal, "Goal");
},
});
// Bad: no userId filter, returns every row
export const getAllGoals = query({ handler: async (ctx) => ctx.db.query("goals").collect() });
// Bad: ships every goal to the client, which filters in the component
const goals = useQuery(api.goals.queries.getGoals, authArgs);
const active = goals?.filter((goal) => goal.status === "active");Required Security Tests
One negative authorization test per sensitive domain:
- Mismatched
userIdis rejected. - Unauthenticated call is rejected.
- Non-admin actor cannot reach admin-only paths.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

