convex-setup-auth
Convexを使ったアプリにログイン機能やユーザー登録機能を追加し、ClerkやAuth0などの認証プロバイダーと連携、ユーザー情報テーブルの作成、役割に基づいたアクセス制御などを設定することで、アプリの認証機能を構築するSkill。
📜 元の英語説明(参考)
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."
🇯🇵 日本人クリエイター向け解説
Convexを使ったアプリにログイン機能やユーザー登録機能を追加し、ClerkやAuth0などの認証プロバイダーと連携、ユーザー情報テーブルの作成、役割に基づいたアクセス制御などを設定することで、アプリの認証機能を構築するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o convex-setup-auth.zip https://jpskill.com/download/19145.zip && unzip -o convex-setup-auth.zip && rm convex-setup-auth.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/19145.zip -OutFile "$d\convex-setup-auth.zip"; Expand-Archive "$d\convex-setup-auth.zip" -DestinationPath $d -Force; ri "$d\convex-setup-auth.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
convex-setup-auth.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
convex-setup-authフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 6
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[Skill 名] convex-setup-auth
Convex 認証設定
Convex でユーザー管理とアクセス制御を伴う安全な認証を実装します。
使用する場面
- 初めて認証を設定する場合
- ユーザー管理(users テーブル、ID マッピング)を実装する場合
- 認証ヘルパー関数を作成する場合
- 認証プロバイダー(Convex Auth、Clerk、WorkOS AuthKit、Auth0、カスタム JWT)を設定する場合
使用しない場面
- Convex 以外のバックエンドの認証
- Convex の実装を伴わない純粋な OAuth/OIDC ドキュメント
- 認証コードの近くでたまたま発生する無関係なバグのデバッグ
- 認証プロバイダーがすでに完全に設定されており、ユーザーが1行の修正のみを必要とする場合
最初のステップ: 認証プロバイダーの選択
Convex は複数の認証アプローチをサポートしています。プロバイダーを決めつけないでください。
セットアップコードを記述する前に:
- リポジトリで明らかでない限り、ユーザーにどの認証ソリューションを希望するか尋ねます。
- リポジトリがすでにプロバイダーを使用している場合、ユーザーが切り替えを希望しない限り、そのプロバイダーを継続します。
- ユーザーがプロバイダーを選択しておらず、リポジトリで明らかでない場合、続行する前に尋ねます。
一般的なオプション:
- Convex Auth - ユーザーが Convex で直接認証を処理したい場合の良いデフォルトです。
- Clerk - アプリがすでに Clerk を使用している場合、またはユーザーが Clerk のホスト型認証機能を希望する場合に使用します。
- WorkOS AuthKit - アプリがすでに WorkOS を使用している場合、またはユーザーが AuthKit を特に希望する場合に使用します。
- Auth0 - アプリがすでに Auth0 を使用している場合に使用します。
- カスタム JWT プロバイダー - 上記でカバーされていない既存の認証システムを統合する場合に使用します。
尋ねる前にリポジトリで手がかりを探します:
@clerk/*、@workos-inc/*、@auth0/*、または Convex Auth パッケージなどの依存関係convex/auth.config.ts、認証ミドルウェア、プロバイダーラッパー、またはログインコンポーネントなどの既存ファイル- プロバイダーを明確に指す環境変数
プロバイダーを選択した後
プロバイダーの公式ガイドと、対応するローカルリファレンスファイルを読みます。
- Convex Auth: 公式ドキュメント、次に
references/convex-auth.md - Clerk: 公式ドキュメント、次に
references/clerk.md - WorkOS AuthKit: 公式ドキュメント、次に
references/workos-authkit.md - Auth0: 公式ドキュメント、次に
references/auth0.md
ローカルリファレンスファイルには、具体的なワークフロー、期待されるファイルと環境変数、注意点、および検証チェックが含まれています。
これらの情報源を次の目的で使用します。
- パッケージのインストール
- クライアントプロバイダーの接続
- 環境変数
convex/auth.config.tsの設定- ログインおよびログアウト UI パターン
- React、Vite、または Next.js のフレームワーク固有のセットアップ
共有される認証動作については、公式の Convex ドキュメントを信頼できる情報源として使用します。
ctx.auth.getUserIdentity()のための関数での認証- オプションのアプリレベルのユーザー保存のためのConvex データベースへのユーザーの保存
- 一般的な認証と認可のガイダンスのための認証
- プロバイダーが Convex Auth の場合のConvex Auth 認可
プロバイダーの CLI や Convex Auth の内部はバージョン間で変更されるため、記憶している手順よりも公式ドキュメントを優先してください。記憶からセットアップを考案すると、古いパターンを使用するリスクがあります。
サードパーティプロバイダーの場合、アプリが実際に Convex にユーザー文書を必要とする場合にのみ、アプリレベルのユーザー保存を追加してください。すべてのアプリが users テーブルを必要とするわけではありません。
Convex Auth の場合、Convex Auth はユーザーレコードを内部で管理しているため、並行して users テーブルと storeUser フローを追加するのではなく、Convex Auth のドキュメントと組み込みの認証テーブルに従ってください。
プロバイダーの初期化コマンドを実行した後、生成されたファイルを確認し、プロバイダーリファレンスが指摘する初期化後の接続手順を完了してください。初期化コマンドが統合全体を完了することはめったにありません。
コアパターン: バックエンド関数の保護
最も一般的な認証タスクは、Convex 関数で ID をチェックすることです。
// Bad: クライアントが提供する userId を信頼する
export const getMyProfile = query({
args: { userId: v.id("users") },
handler: async (ctx, args) => {
return await ctx.db.get(args.userId);
},
});
// Good: サーバー側で ID を検証する
export const getMyProfile = query({
args: {},
handler: async (ctx) => {
const identity = await ctx.auth.getUserIdentity();
if (!identity) throw new Error("Not authenticated");
return await ctx.db
.query("users")
.withIndex("by_tokenIdentifier", (q) =>
q.eq("tokenIdentifier", identity.tokenIdentifier)
)
.unique();
},
});
ワークフロー
- ユーザーに尋ねるか、リポジトリから推測してプロバイダーを決定します。
- ユーザーに、ローカルのみのセットアップを希望するか、今すぐ本番環境対応のセットアップを希望するかを尋ねます。
- 対応するプロバイダーリファレンスファイルを読みます。
- 現在のセットアップの詳細については、公式プロバイダードキュメントに従います。
- 共有されるバックエンド認証動作、ユーザー保存、および認可パターンについては、公式の Convex ドキュメントに従います。
- ドキュメントとアプリの要件で必要とされる場合にのみ、アプリレベルのユーザー保存を追加します。
- アプリが必要とする場合にのみ、所有権、ロール、またはチームアクセスに関する認可チェックを追加します。
- ログイン状態、保護されたクエリ、環境変数、および要求された場合は本番環境設定を確認します。
フローがインタラクティブなプロバイダーまたはデプロイメントのセットアップでブロックされた場合、ユーザーに正確な人間によるステップを明示的に尋ね、ユーザーがそれを完了した後に続行します。 UI に面した認証フローについては、セットアップ完了後に実際のサインアップまたはサインインフローを検証することを提案します。 環境にブラウザ自動化ツールがある場合は、それらを使用できます。 ない場合は、ユーザーに短い手動検証チェックリストを提供します。
リファレンスファイル
プロバイダーリファレンス
references/convex-auth.mdreferences/clerk.mdreferences/workos-authkit.mdreferences/auth0.md
チェックリスト
(原文がここで切り詰められています)
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
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)
When Not to Use
- Auth for a non-Convex backend
- Pure OAuth/OIDC documentation without a Convex implementation
- Debugging unrelated bugs that happen to surface near auth code
- The auth provider is already fully configured and the user only needs a one-line fix
First Step: Choose the Auth Provider
Convex supports multiple authentication approaches. 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 a provider 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 or the user wants Clerk's hosted auth features
- WorkOS AuthKit - use when the app already uses WorkOS or the user wants AuthKit specifically
- Auth0 - use when the app already uses Auth0
- Custom JWT provider - use when integrating an existing auth system not covered above
Look for signals in the repo before asking:
- Dependencies such as
@clerk/*,@workos-inc/*,@auth0/*, or Convex Auth packages - Existing files such as
convex/auth.config.ts, auth middleware, provider wrappers, or login components - Environment variables that clearly point at a provider
After Choosing a Provider
Read the provider's official guide and the matching local reference file:
- Convex Auth: official docs, then
references/convex-auth.md - Clerk: official docs, then
references/clerk.md - WorkOS AuthKit: official docs, then
references/workos-authkit.md - Auth0: official docs, then
references/auth0.md
The local reference files contain the concrete workflow, expected files and env vars, gotchas, and validation checks.
Use those sources for:
- package installation
- client provider wiring
- environment variables
convex/auth.config.tssetup- login and logout UI patterns
- framework-specific setup for React, Vite, or Next.js
For shared auth behavior, use the official Convex docs as the source of truth:
- Auth in Functions for
ctx.auth.getUserIdentity() - Storing Users in the Convex Database for optional app-level user storage
- Authentication for general auth and authorization guidance
- Convex Auth Authorization when the provider is Convex Auth
Prefer official docs over recalled steps, because provider CLIs and Convex Auth internals change between versions. Inventing setup from memory risks outdated patterns.
For third-party providers, only add app-level user storage if the app actually needs user documents in Convex. Not every app needs a users table.
For Convex Auth, follow the Convex Auth docs and built-in auth tables rather than adding a parallel users table plus storeUser flow, because Convex Auth already manages user records internally.
After running provider initialization commands, verify generated files and complete the post-init wiring steps the provider reference calls out. Initialization commands rarely finish the entire integration.
Core Pattern: Protecting Backend Functions
The most common auth task is checking identity in Convex functions.
// Bad: trusting a client-provided userId
export const getMyProfile = query({
args: { userId: v.id("users") },
handler: async (ctx, args) => {
return await ctx.db.get(args.userId);
},
});
// Good: verifying identity server-side
export const getMyProfile = query({
args: {},
handler: async (ctx) => {
const identity = await ctx.auth.getUserIdentity();
if (!identity) throw new Error("Not authenticated");
return await ctx.db
.query("users")
.withIndex("by_tokenIdentifier", (q) =>
q.eq("tokenIdentifier", identity.tokenIdentifier)
)
.unique();
},
});
Workflow
- Determine the provider, either by asking the user or inferring from the repo
- Ask whether the user wants local-only setup or production-ready setup now
- Read the matching provider reference file
- Follow the official provider docs for current setup details
- Follow the official Convex docs for shared backend auth behavior, user storage, and authorization patterns
- Only add app-level user storage if the docs and app requirements call for it
- Add authorization checks for ownership, roles, or team access only where the app needs them
- Verify login state, protected queries, environment variables, and production configuration if requested
If the flow blocks on interactive provider or deployment setup, ask the user explicitly for the exact human step needed, then continue after they complete it. For UI-facing auth flows, offer to validate the real sign-up or sign-in flow after setup is done. If the environment has browser automation tools, you can use them. If it does not, give the user a short manual validation checklist instead.
Reference Files
Provider References
references/convex-auth.mdreferences/clerk.mdreferences/workos-authkit.mdreferences/auth0.md
Checklist
- [ ] Chosen the correct auth provider before writing setup code
- [ ] Read the relevant provider reference file
- [ ] Asked whether the user wants local-only setup or production-ready setup
- [ ] Used the official provider docs for provider-specific wiring
- [ ] Used the official Convex docs for shared auth behavior and authorization patterns
- [ ] Only added app-level user storage if the app actually needs it
- [ ] Did not invent a cross-provider
userstable orstoreUserflow for Convex Auth - [ ] Added authentication checks in protected backend functions
- [ ] Added authorization checks where the app actually needs them
- [ ] Clear error messages ("Not authenticated", "Unauthorized")
- [ ] Client auth provider configured for the chosen provider
- [ ] If requested, production auth setup is covered too
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (7,340 bytes)
- 📎 assets/icon.svg (394 bytes)
- 📎 references/auth0.md (7,440 bytes)
- 📎 references/clerk.md (6,283 bytes)
- 📎 references/convex-auth.md (8,286 bytes)
- 📎 references/workos-authkit.md (6,248 bytes)