clerk-android
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseClerk Android (Native)
Clerk Android(原生)
This skill implements Clerk in native Android projects by following current SDK and docs patterns.
clerk-android本技能遵循当前 SDK和文档模式,在原生Android项目中集成Clerk。
clerk-androidActivation Rules
激活规则
Activate this skill when either condition is true:
- The user explicitly asks for Android, Kotlin, Jetpack Compose, or native mobile Clerk implementation on Android.
- The project appears to be native Android (for example with Android plugins,
build.gradle(.kts),AndroidManifest.xml, Compose UI files).app/src/main/java
Do not activate this skill when either condition is true:
- The project is Expo.
- The project is React Native.
If Expo/React Native signals are present, route to the general setup skill instead.
满足以下任一条件时激活本技能:
- 用户明确询问在Android上使用Kotlin、Jetpack Compose或原生移动应用的Clerk实现方案。
- 项目为原生Android类型(例如包含带Android插件的、
build.gradle(.kts)、AndroidManifest.xml、Compose UI文件)。app/src/main/java
满足以下任一条件时请勿激活本技能:
- 项目为Expo类型。
- 项目为React Native类型。
如果检测到Expo/React Native相关特征,应转至通用设置技能处理。
Quick Start
快速开始
| Step | Action |
|---|---|
| 1 | Confirm project type is native Android and not Expo/React Native |
| 2 | Determine flow type ( |
| 3 | Ensure a real Clerk publishable key exists (or ask developer) |
| 4 | Ensure correct Clerk artifacts are installed for the selected flow |
| 5 | Read official Android quickstart and verify required setup (Native API, min SDK/Java, manifest, initialization) |
| 6 | Inspect |
| 7 | Implement flow by following only the selected reference checklist |
| 步骤 | 操作 |
|---|---|
| 1 | 确认项目类型为原生Android,而非Expo/React Native |
| 2 | 确定流程类型( |
| 3 | 确保存在有效的Clerk发布密钥(或向开发者索要) |
| 4 | 确保为所选流程安装了正确的Clerk组件 |
| 5 | 阅读官方Android快速入门指南,验证所需的设置(Native API、最低SDK/Java版本、清单文件、初始化配置) |
| 6 | 检查与所选流程相关的 |
| 7 | 仅遵循所选参考清单实现流程 |
Decision Tree
决策树
text
User asks for Clerk in Android/Kotlin
|
+-- Expo/React Native project detected?
| |
| +-- YES -> Do not use this skill
| |
| +-- NO -> Continue
|
+-- Existing auth UI detected?
| |
| +-- Prebuilt views detected -> Load references/prebuilt.md
| |
| +-- Custom flow detected -> Load references/custom.md
| |
| +-- New implementation -> Ask developer prebuilt/custom, then load matching reference
|
+-- Ensure publishable key and SDK initialization path
|
+-- Ensure correct Android artifacts are installed
|
+-- Verify quickstart prerequisites in project
|
+-- Implement using selected flow referencetext
用户询问Android/Kotlin中的Clerk集成
|
+-- 检测到Expo/React Native项目?
| |
| +-- 是 -> 不使用本技能
| |
| +-- 否 -> 继续
|
+-- 检测到现有认证UI?
| |
| +-- 检测到预构建视图 -> 加载references/prebuilt.md
| |
| +-- 检测到自定义流程 -> 加载references/custom.md
| |
| +-- 新实现 -> 询问开发者选择预构建/自定义流程,然后加载对应参考
|
+-- 确保发布密钥和SDK初始化路径正确
|
+-- 确保安装了正确的Android组件
|
+-- 验证项目中的快速入门前置条件
|
+-- 使用所选流程参考进行实现Flow References
流程参考
After flow type is known, load exactly one:
- Prebuilt flow: references/prebuilt.md
- Custom flow: references/custom.md
Do not blend the two references in a single implementation unless the developer explicitly asks for a hybrid approach.
确定流程类型后,仅加载以下其中一个参考:
- 预构建流程:references/prebuilt.md
- 自定义流程:references/custom.md
除非开发者明确要求混合方案,否则请勿在单次实现中混合使用两个参考的内容。
Interaction Contract
交互约定
Before any implementation edits, the agent must have both:
- flow choice: or
prebuiltcustom - a real Clerk publishable key
If either value is missing from the user request/context:
- ask the user for the missing value(s)
- pause and wait for the answer
- do not edit files or install dependencies yet
Only skip asking when the user has already explicitly provided the value in this conversation.
在进行任何实现编辑之前,代理必须同时确认:
- 流程选择:或
prebuiltcustom - 有效的Clerk发布密钥
如果用户请求/上下文缺少任一值:
- 向用户询问缺失的值
- 暂停操作等待回复
- 暂不编辑文件或安装依赖
仅当用户在本次对话中已明确提供对应值时,才可跳过询问步骤。
Source-Driven Templates
源码驱动模板
Do not hardcode implementation examples in this skill. Inspect current source/docs for the installed SDK version before implementing.
clerk-android| Use Case | Source of Truth |
|---|---|
SDK artifacts and dependency split ( | |
| SDK initialization and publishable key wiring | Android quickstart and |
| Prebuilt auth and profile behavior | |
| Custom auth sequencing and factor handling | |
| Capability/feature gating from instance settings | |
| Required Android setup checklist | Official Android quickstart ( |
请勿在本技能中硬编码实现示例。在实现前,请检查当前已安装SDK版本对应的源码/文档。
clerk-android| 使用场景 | 权威来源 |
|---|---|
SDK组件和依赖拆分( | |
| SDK初始化和发布密钥配置 | Android快速入门指南和 |
| 预构建认证和个人资料行为 | |
| 自定义认证流程和因子处理 | |
| 实例设置中的功能/特性管控 | |
| 必需的Android设置清单 | 官方Android快速入门指南( |
Execution Gates (Do Not Skip)
执行限制(请勿跳过)
- No implementation edits before prerequisites
- Do not edit project files until flow type is confirmed and a valid publishable key is available.
- Missing flow or key must trigger a question
- If flow choice is missing, explicitly ask: prebuilt views or custom flow.
- If publishable key is missing/placeholder/invalid, explicitly ask for a real key.
- Do not continue until both answers are provided.
- Publishable key wiring mode is mandatory
- By default, wire the developer-provided key directly in .
Clerk.initialize(...) - Do not introduce secret-management indirection unless explicitly requested.
- Artifact install policy is mandatory
- Prebuilt flow: use (includes API).
clerk-android-ui - Custom flow: use unless prebuilt components are explicitly requested.
clerk-android-api - If Clerk artifacts are missing, add the latest stable release available.
- Android quickstart compliance is mandatory
- Verify Native API is enabled for the Clerk app.
- Verify Android requirements from quickstart are implemented in project (minimum SDK and Java target, manifest internet permission, app-level Clerk initialization).
- Verify app waits for SDK initialization () before assuming auth-ready state.
Clerk.isInitialized
- Capability-driven behavior is mandatory
- Use Clerk runtime capability/settings state (for example enabled factors/social providers/MFA flags) to gate flow behavior.
- Do not hardcode factor assumptions that may conflict with dashboard configuration.
- Reference-file discipline is mandatory
- Once flow is selected, follow only that flow reference file for implementation and verification.
- Custom-flow structure parity is mandatory
- For flow, preserve multi-step auth progression and factor-specific handling (no single all-fields form by default).
custom - Keep UI, state orchestration, and Clerk API integration in separate modules.
- Prebuilt preference is mandatory when selected
- For flow, do not rebuild auth forms with custom API calls unless explicitly requested.
prebuilt - Use /
AuthViewas default building blocks.UserButton
- 前置条件未满足前请勿进行实现编辑
- 确认流程类型并获取有效发布密钥前,请勿编辑项目文件。
- 缺失流程或密钥必须触发询问
- 如果缺少流程选择,明确询问:使用预构建视图还是自定义流程。
- 如果发布密钥缺失/为占位符/无效,明确索要真实密钥。
- 必须获取两个问题的回复后才可继续。
- 必须配置发布密钥
- 默认情况下,直接在中配置开发者提供的密钥。
Clerk.initialize(...) - 除非明确要求,否则请勿引入密钥管理的间接方式。
- 必须遵循组件安装规则
- 预构建流程:使用(包含API)。
clerk-android-ui - 自定义流程:使用,除非明确要求使用预构建组件。
clerk-android-api - 如果缺少Clerk组件,添加可用的最新稳定版本。
- 必须符合Android快速入门指南要求
- 验证Clerk应用已启用Native API。
- 验证项目已实现快速入门指南中的Android要求(最低SDK和Java目标版本、清单文件中的网络权限、应用级Clerk初始化)。
- 验证应用在SDK初始化完成()后才进入认证就绪状态。
Clerk.isInitialized
- 必须基于功能特性驱动行为
- 使用Clerk运行时功能/设置状态(例如启用的因子/社交登录提供商/MFA标志)管控流程行为。
- 请勿硬编码可能与控制台配置冲突的认证因子假设。
- 必须遵循参考文件规范
- 选择流程后,仅遵循该流程的参考文件进行实现和验证。
- 自定义流程结构必须一致
- 对于流程,保留多步骤认证流程和特定因子处理逻辑(默认不使用单一包含所有字段的表单)。
custom - 将UI、状态编排和Clerk API集成放在独立模块中。
- 选择预构建流程后必须优先使用预构建组件
- 对于流程,除非明确要求,否则请勿使用自定义API调用重新构建认证表单。
prebuilt - 默认使用/
AuthView作为构建块。UserButton
Workflow
工作流程
- Detect native Android vs Expo/React Native.
- If flow type is not explicitly provided, ask user for or
prebuilt.custom - If publishable key is not explicitly provided, ask user for it.
- Wait for both answers before changing files.
- Load matching flow reference file.
- Ensure path and publishable key wiring are valid.
Clerk.initialize(...) - Ensure dependencies/artifacts match selected flow.
- Review Android quickstart requirements and apply missing setup in project.
- Implement using selected reference checklist.
- Verify using selected reference checklist plus shared gates.
- 检测项目是原生Android还是Expo/React Native。
- 如果未明确提供流程类型,询问用户选择或
prebuilt。custom - 如果未明确提供发布密钥,向用户索要。
- 获取两个回复后再修改文件。
- 加载匹配的流程参考文件。
- 确保路径和发布密钥配置有效。
Clerk.initialize(...) - 确保依赖/组件与所选流程匹配。
- 检查Android快速入门指南的要求,在项目中补全缺失的设置。
- 遵循所选参考清单进行实现。
- 使用所选参考清单和共享限制进行验证。
Common Pitfalls
常见陷阱
| Level | Issue | Prevention |
|---|---|---|
| CRITICAL | Not asking for missing flow choice before implementation | Ask for |
| CRITICAL | Not asking for missing publishable key before implementation | Ask for key and wait before edits |
| CRITICAL | Starting implementation before flow type is confirmed | Confirm flow first and load matching reference |
| CRITICAL | Skipping Android quickstart prerequisites | Verify and apply required setup from official Android quickstart |
| CRITICAL | Missing app-level | Initialize Clerk from |
| HIGH | Wrong artifact for chosen flow | Prebuilt: |
| HIGH | Rendering auth UI before SDK initialization completes | Gate UI with |
| HIGH | Hardcoding auth factors/social providers | Drive behavior from Clerk runtime capability fields |
| HIGH | Using this skill for Expo/React Native | Detect and route away before implementation |
| 级别 | 问题 | 预防措施 |
|---|---|---|
| 严重 | 实现前未询问缺失的流程选择 | 先询问 |
| 严重 | 实现前未询问缺失的发布密钥 | 索要密钥,等待回复后再编辑 |
| 严重 | 未确认流程类型就开始实现 | 先确认流程类型,再加载对应参考 |
| 严重 | 跳过Android快速入门前置条件 | 验证并应用官方Android快速入门指南中的必需设置 |
| 严重 | 缺少应用级 | 从 |
| 高 | 为所选流程安装了错误的组件 | 预构建流程:使用 |
| 高 | SDK初始化完成前渲染认证UI | 使用 |
| 高 | 硬编码认证因子/社交登录提供商 | 基于Clerk运行时功能字段驱动行为 |
| 高 | 将本技能用于Expo/React Native项目 | 检测到后转至其他技能处理,不进行实现 |
See Also
另请参阅
- for top-level Clerk routing
../clerk/SKILL.md - for cross-framework quickstart setup
../setup/SKILL.md https://github.com/clerk/clerk-androidhttps://clerk.com/docs/android/getting-started/quickstart
- 顶级Clerk路由
../clerk/SKILL.md - 跨框架快速入门设置
../setup/SKILL.md https://github.com/clerk/clerk-androidhttps://clerk.com/docs/android/getting-started/quickstart