用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/robertguss/james-event-horizon-app --skill source-command-convex-auth-setup命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | source-command-convex-auth-setup |
| description | Set up or extend authentication patterns in this Convex + Clerk project |
This project uses Clerk with Convex JWT validation. Use this guide when implementing auth flows, access control, or user management.
convex/auth.config.ts validates Clerk JWTs via
CLERK_JWT_ISSUER_DOMAINconvex/auth.ts exposes getCurrentUser from
ctx.auth.getUserIdentity()ClerkProvider + ConvexProviderWithClerk /
useAuth from @clerk/nextjsproxy.ts (clerkMiddleware) plus
auth.protect() in app/dashboard/layout.tsx<SignIn /> / <SignUp /> at /login and /signupPrefer ctx.auth.getUserIdentity() in Convex functions, or the shared query:
import { api } from "./_generated/api";
// Client
const user = useQuery(api.auth.getCurrentUser);
import { query } from "./_generated/server";
export const myQuery = query({
args: {},
returns: v.null(),
handler: async (ctx) => {
const identity = await ctx.auth.getUserIdentity();
if (!identity) {
throw new Error("Not authenticated");
}
// identity.subject, identity.email, identity.name, identity.pictureUrl
},
});
import {
customQuery,
customMutation,
} from "convex-helpers/server/customFunctions";
import { query, mutation } from "../_generated/server";
async function requireIdentity(ctx: { auth: { getUserIdentity: () => Promise<unknown> } }) {
const identity = await ctx.auth.getUserIdentity();
if (!identity) {
throw new Error("Not authenticated");
}
return identity;
}
export const authedQuery = customQuery(query, {
args: {},
input: async (ctx, args) => {
const identity = await requireIdentity(ctx);
return { ctx: { ...ctx, identity }, args };
},
});
export const authedMutation = customMutation(mutation, {
args: {},
input: async (ctx, args) => {
const identity = await requireIdentity(ctx);
return { ctx: { ...ctx, identity }, args };
},
});
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and CLERK_SECRET_KEY in .env.localbunx convex env set CLERK_JWT_ISSUER_DOMAIN <Frontend API URL>useConvexAuth() and a protected queryconvex/auth.ts and app/ConvexClientProvider.tsx before changing authctx.auth.getUserIdentity() (or api.auth.getCurrentUser) for identityNEXT_PUBLIC_CONVEX_SITE_URL for session auth