convex-setup-auth
Skill628 starsChanged 7 months agoMITView on GitHub
Set up Convex authentication with proper user management, identity mapping, and access control patterns. Use when implementing auth flows, setting up OAuth providers, or adding role-based access control.
15 other projects use a version of this, 15 of them edited.
Adopted by
Most recently taken up by
- get-convex/workflowedited, first seen Oct 9, 2026
- moltbot/molthubedited, first seen Oct 8, 2026
- get-convex/convex-helpersedited, first seen Oct 8, 2026
- clawdbot/clawdhubedited, first seen Oct 8, 2026
- pingdotgg/lawnedited, first seen Oct 8, 2026
- openclaw/clawhubedited, first seen Oct 8, 2026
Used with
Projects with it also use clawhub-ban-appeals, clawhub-clawscan and 10 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.
openclawSkillclawhub-ban-appeals
Review ClawHub account-ban appeals, distinguish bans from moderation holds or blocked releases, and prepare an evidence-backed moderation decision. Route validated scanner inaccuracies to clawhub-clawscan.
Also in 3 projects that use this
openclawSkillclawhub-clawscan
Investigate ClawScan health alerts, diagnose scanner or ClawHub integration failures, prepare operational repairs, and route validated verdict inaccuracies upstream. Account ban appeals use clawhub-ban-appeals.
Also in 3 projects that use this
FabienGreardSkillconvex-acquire-domain
Find and buy a domain for the current Convex app through Convex, then bind it (labs; spend action).
Also in 3 projects that use this
- +9 more from openclaw
Other versions15 projects use a version of this.
Word for word · 0
None found.
Edited · 15
- openclaw/clawhub★ 9.6k22% same
- clawdbot/clawdhub★ 9.5k22% same
- moltbot/molthub★ 9.5k22% same
- raroque/boop-agent★ 1.3k22% same
- pingdotgg/lawn★ 69022% same
- get-convex/convex-helpers★ 49621% same
- get-convex/workflow★ 8621% same
- sholajegede/mastra-vs-langchain★ 1722% same
- vantageos-agency/vantage-peers★ 421% same
- Decentralized-Rights-Protocol/Dr-Blockchain★ 221% same
5 more not listed
Wrote their own version · 0
None found.
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 repository40 other files it gives its agents.
- AGENTS.mdAGENTS.md
- public/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/convex2.mdcCursor rule
- .cursor/rules/convex-doctor.mdcCursor rule
- .cursor/rules/convex-write-conflicts.mdcCursor rule
- .cursor/rules/dev2.mdcCursor rule
- .cursor/rules/gitruels.mdcCursor rule
- .cursor/rules/help.mdcCursor rule
- .cursor/rules/rulesforconvex.mdcCursor rule
- .cursor/rules/sec-check.mdcCursor rule
- .cursor/rules/task.mdcCursor rule
- .cursor/rules/workflow.mdcCursor rule
- .cursor/rules/write.mdcCursor rule
- public/llms.txtllms.txt
- convex-create-componentSkill
- convex-migration-helperSkill
- convex-performance-auditSkill
- convex-quickstartSkill
- convex-setup-authSkill
- convexSkill
- impeccableSkill
- convex-quickstartSkill
- devSkill
- function-creatorSkill
- gitrulesSkill
- helpSkill
- migration-helperSkill
- react-effect-decisionSkill
- real-time-backendSkill
- schema-builderSkill
- sec-checkSkill
- workflowSkill
- writeSkill
- convex-doctorSkill
- convex-return-validatorsSkill
- convex-self-hostingSkill
- create-prdSkill
- robel-authSkill
- update-project-docsSkill
The file
We split this skill into the rules it gives an agent
5 rules. 4 are common, 1 is distinctive, and 0 are very specific to this project.
4
Common
Most of the 15 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Do not assume a provider. Before writing setup code:
- Common: line 21
Ask the user which auth solution they want, unless the repository already makes it obvious
- Common: line 22
If the repo already uses a provider, continue with that provider unless the user wants to switch
- Common: line 23
If the user has not chosen and the repo does not make it obvious, ask before proceeding
- Common: line 33
Look for signals in the repo before asking:
“Common” is measured: kept by at least 6 in 10 of the 15 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 Authentication Setup
Implement secure authentication in Convex with user management and access control.
When to Use
- Setting up authentication for the first time
- Implementing user management (users table, identity mapping)
- Creating authentication helper functions
- Setting up auth providers (Convex Auth, Clerk, WorkOS AuthKit, Auth0, custom JWT)
First Step: Choose the Auth Provider
Do not assume a provider. Before writing setup code:
- Ask the user which auth solution they want, unless the repository already makes it obvious
- If the repo already uses a provider, continue with that provider unless the user wants to switch
- If the user has not chosen and the repo does not make it obvious, ask before proceeding
Common options:
- Convex Auth: good default when the user wants auth handled directly in Convex
- Clerk: use when the app already uses Clerk
- WorkOS AuthKit: use when the app already uses WorkOS
- Auth0: use when the app already uses Auth0
- Custom JWT provider: use when integrating an existing auth system
Look for signals in the repo before asking:
- Dependencies such as
@clerk/*,@workos-inc/*,@auth0/* - Existing files such as
convex/auth.config.ts, auth middleware, provider wrappers - Environment variables that clearly point at a provider
Schema Setup
// convex/schema.ts
import { defineSchema, defineTable } from "convex/server";
import { v } from "convex/values";
export default defineSchema({
users: defineTable({
tokenIdentifier: v.string(),
name: v.string(),
email: v.string(),
pictureUrl: v.optional(v.string()),
role: v.union(v.literal("user"), v.literal("admin")),
createdAt: v.number(),
updatedAt: v.optional(v.number()),
})
.index("by_token", ["tokenIdentifier"])
.index("by_email", ["email"]),
});Core Helper Functions
Get Current User
// convex/lib/auth.ts
import { QueryCtx, MutationCtx } from "./_generated/server";
import { Doc } from "./_generated/dataModel";
export async function getCurrentUser(
ctx: QueryCtx | MutationCtx
): Promise<Doc<"users">> {
const identity = await ctx.auth.getUserIdentity();
if (!identity) throw new Error("Not authenticated");
const user = await ctx.db
.query("users")
.withIndex("by_token", q =>
q.eq("tokenIdentifier", identity.tokenIdentifier)
)
.unique();
if (!user) throw new Error("User not found");
return user;
}
export async function getCurrentUserOrNull(
ctx: QueryCtx | MutationCtx
): Promise<Doc<"users"> | null> {
const identity = await ctx.auth.getUserIdentity();
if (!identity) return null;
return await ctx.db
.query("users")
.withIndex("by_token", q =>
q.eq("tokenIdentifier", identity.tokenIdentifier)
)
.unique();
}
export async function requireAdmin(
ctx: QueryCtx | MutationCtx
): Promise<Doc<"users">> {
const user = await getCurrentUser(ctx);
if (user.role !== "admin") throw new Error("Admin access required");
return user;
}User Creation/Upsert
// convex/users.ts
import { mutation } from "./_generated/server";
import { v } from "convex/values";
export const storeUser = mutation({
args: {},
handler: async (ctx) => {
const identity = await ctx.auth.getUserIdentity();
if (!identity) throw new Error("Not authenticated");
const existingUser = await ctx.db
.query("users")
.withIndex("by_token", q =>
q.eq("tokenIdentifier", identity.tokenIdentifier)
)
.unique();
if (existingUser) {
await ctx.db.patch(existingUser._id, { updatedAt: Date.now() });
return existingUser._id;
}
return await ctx.db.insert("users", {
tokenIdentifier: identity.tokenIdentifier,
name: identity.name ?? "Anonymous",
email: identity.email ?? "",
pictureUrl: identity.pictureUrl,
role: "user",
createdAt: Date.now(),
});
},
});Access Control Patterns
Resource Ownership
export const deleteTask = mutation({
args: { taskId: v.id("tasks") },
handler: async (ctx, args) => {
const user = await getCurrentUser(ctx);
const task = await ctx.db.get(args.taskId);
if (!task) throw new Error("Task not found");
if (task.userId !== user._id) throw new Error("You can only delete your own tasks");
await ctx.db.delete(args.taskId);
},
});Team-Based Access
async function requireTeamAccess(
ctx: MutationCtx,
teamId: Id<"teams">
): Promise<{ user: Doc<"users">, membership: Doc<"teamMembers"> }> {
const user = await getCurrentUser(ctx);
const membership = await ctx.db
.query("teamMembers")
.withIndex("by_team_and_user", q =>
q.eq("teamId", teamId).eq("userId", user._id)
)
.unique();
if (!membership) throw new Error("You don't have access to this team");
return { user, membership };
}Checklist
- Chosen the correct auth provider before writing setup code
- Users table with
tokenIdentifierindex getCurrentUserhelper functionstoreUsermutation for first sign-in- Authentication check in all protected functions
- Authorization check for resource access
- Clear error messages ("Not authenticated", "Unauthorized")
- Client auth provider configured
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.

