clerk-swift

작성자: clerk

ClerkKit을 사용한 네이티브 Swift/iOS 인증으로, 사전 구축된 인증 흐름 또는 맞춤형 인증 흐름을 지원합니다. 프로젝트 요구 사항에 따라 사전 구축된 AuthView 컴포넌트 또는 완전히 맞춤화된 네이티브 흐름 중 두 가지 구현 모드를 지원합니다. 앱 구성에 유효한 Clerk 퍼블리시 키를 직접 연결해야 하며, 기본적으로 plist나 환경 파일 간접 참조를 사용하지 않습니다. 패키지 설치 후 Apple Sign In 지원 등 기능 가용성을 확인하기 위해 /v1/environment 호출이 필수입니다.

npx skills add https://github.com/clerk/skills --skill clerk-swift

Clerk Swift (Native iOS and macOS)

This skill builds Clerk authentication UI in native Swift projects: prebuilt ClerkKitUI views or custom flows on ClerkKit. Setup (SDK, capabilities, native registration, and Clerk initialization) comes first and has its own workflow.

Activation Rules

Activate this skill when either condition is true:

  • The user explicitly asks for Swift, SwiftUI, UIKit, or native iOS or macOS Clerk implementation.
  • The project appears to be native Swift (for example .xcodeproj, .xcworkspace, Package.swift, Swift targets).

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 of this one.

Set up Clerk first

If Clerk isn't set up yet (no clerk-ios package, no Clerk.configure call, or no Clerk application chosen), follow the iOS setup prompt before any UI work. It uses the Clerk CLI to choose a Clerk application, install the SDK, configure capabilities, register the native app, and hand off the remaining Swift integration. The CLI also supplies the publishable key, so don't ask the user to paste one.

If the CLI can't set up the project (for example, Xcode isn't available or the project isn't supported), follow the manual iOS quickstart instead.

If the user already asked for sign-in UI, such as a custom flow, continue here once setup's build check passes. Otherwise, return to this skill when the user wants sign-in UI added or changed.

What Do You Need?

TaskReference
Prebuilt AuthView / UserButton (fastest)references/prebuilt.md
Custom API-driven auth flows (full control)references/custom.md

Quick Start

StepAction
1Confirm the project is native Swift and not Expo/React Native
2If Clerk isn't set up, follow the iOS setup prompt first (see above)
3Determine the flow type (prebuilt or custom); ask if it's undecided, then load the matching reference
4Check the prerequisites the selected flow needs, such as a package product or capability, and make only the targeted changes that are missing
5Implement the flow by following the selected reference
6Build the target and report what remains unverified

Decision Tree

User asks for Clerk in Swift
    |
    +-- Expo/React Native project detected?
    |     |
    |     +-- YES -> Do not use this skill
    |     |
    |     +-- NO -> Continue
    |
    +-- Clerk set up in this project?
    |     |
    |     +-- NO -> Follow the iOS setup prompt (manual quickstart if the CLI can't)
    |     |
    |     +-- YES -> 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
    |
    +-- Make targeted prerequisite changes for the selected flow
    |
    +-- Implement using selected flow reference

Flow References

After flow type is known, load exactly one:

Do not blend the two references in a single implementation unless the developer explicitly asks for a hybrid approach.

Interaction Contract

Before UI implementation edits, the agent must have a flow choice: prebuilt or custom. If it's missing, ask the user and wait for the answer. Only skip asking when the user has already chosen in this conversation or the existing UI makes the choice clear.

Preserve Completed Setup

  • Keep the existing Clerk.configure call and how the app loads its publishable key, including plist, build-setting, or other custom key loading. Don't replace it with a hardcoded key.
  • Keep existing package requirements, capabilities, and entitlements. Add only what the selected flow needs and is missing.
  • To check Clerk and project setup without changing anything, run npx -y clerk@latest doctor. It reports SDK linkage, capabilities, native registration, and the Apple connection.

Source-Driven Implementation

Use the installed clerk-ios package source as the reference for UI behavior, especially for custom flows.

Use CaseSource of Truth in Installed Package
SDK products, platform support, and dependency constraintsPackage manifest and target product definitions for ClerkKit and ClerkKitUI
Auth flow sequencing and gatingClerkKitUI AuthView implementation and how it reads the injected Clerk instance's environment
Native Sign in with AppleApple sign-in behavior in the selected flow reference

Workflow

  1. Detect native Swift vs Expo/React Native.
  2. If Clerk isn't set up, follow the iOS setup prompt (or the manual quickstart when the CLI can't set up the project), then continue.
  3. If the flow type isn't known, ask for prebuilt or custom.
  4. Load the matching flow reference.
  5. Check that flow's prerequisites and make only the missing, targeted changes, preserving completed setup and custom key loading.
  6. Implement using the selected reference.
  7. Verify using the selected reference, then build the target.

Common Pitfalls

LevelIssuePrevention
CRITICALDoing setup by hand when Clerk isn't set upFollow the iOS setup prompt; it runs the Clerk CLI. Use the manual quickstart only when the CLI can't set up the project
CRITICALAsking the user to paste a publishable keyThe CLI provides it during setup; keep an existing app's own key loading
CRITICALReplacing custom key loading or existing setupKeep the existing Clerk.configure, packages, and capabilities; add only what's missing
CRITICALStarting UI implementation before the flow type is confirmedConfirm the flow first and load the matching reference
CRITICALCustom flow layout diverges from AuthView without explicit requestKeep custom screens materially close to AuthView structure and step composition by default
CRITICALCollapsing custom auth into a single all-fields screenFollow AuthView-style multi-step progression and step-specific field collection
CRITICALGuessing custom sequencing or gating when uncertainReference installed ClerkKitUI behavior and mirror it
HIGHHardcoding this instance's current settings into custom flow codeGate steps at runtime from the injected Clerk instance's environment, as AuthView does
HIGHUsing this skill for Expo/React NativeDetect and route away before implementation

See Also

  • iOS setup prompt for setting up Clerk with the Clerk CLI
  • clerk skill for top-level Clerk routing
  • clerk-setup skill for non-native or cross-framework setup
  • https://github.com/clerk/clerk-ios

clerk의 다른 스킬

clerk-testing
clerk
Clerk 인증 흐름을 위한 Playwright 및 Cypress E2E 테스트 유틸리티입니다. Playwright와 Cypress 프레임워크를 모두 지원하며, 각 프레임워크에 맞는 설정 패턴(Playwright의 globalSetup, Cypress의 커스텀 명령어)을 제공합니다. 테스트 환경을 초기화하고 봇 탐지를 우회하기 위해 clerkSetup()과 setupClerkTestingToken() 유틸리티를 제공합니다. 인증된 세션을 테스트 간에 재사용하여 테스트 실행 시간을 줄이는 storageState 지속성을 포함합니다. 테스트 API 키(pk_test_* ,...)가 필요합니다.
mosaic
clerk
Work on Mosaic UI: styling a component with slot recipes (`defineSlotRecipe` / `useRecipe` / slots / variants), or building a flow — authoring a state machine…
clerk-billing
clerk
구독 관리를 위한 Clerk Billing - Clerk의 PricingTable을 렌더링합니다.
clerk-nextjs-patterns
clerk
Clerk를 사용한 인증, 미들웨어, 서버 액션, 사용자 범위 캐싱을 위한 고급 Next.js 패턴. 서버 측 await auth()와 클라이언트 측 useAuth() 훅을 구분하며, 이 둘을 혼용하는 것은 흔한 치명적 실수입니다. 미들웨어 전략(퍼블릭 우선 vs 보호 우선), API 라우트 보호, 적절한 HTTP 상태 코드(401 vs 403)를 다룹니다. unstable_cache를 사용한 사용자 범위 캐싱 패턴과 승인되지 않은 변이로부터 서버 액션을 보호하는 방법을 포함합니다. Core 2 호환성을 제공합니다...
clerk-expo-patterns
clerk
Expo / React Native 패턴과 Clerk — SecureStore 토큰 캐시, OAuth
changesets
clerk
Create or refresh a `.changeset/<slug>.md` for the current branch, or report that none is required. Triggers on "/changesets create", "add a changeset",…
clerk-astro-patterns
clerk
Clerk을 사용한 Astro 패턴 — 미들웨어, SSR 페이지, 아일랜드 컴포넌트
clerk
clerk
clerk 바이너리는 Clerk의 백엔드 API 및 플랫폼 API에 대한 사전 인증된 게이트웨이이며, 프로젝트 수준 도구(인증, 링킹, 환경 변수 가져오기, 인스턴스 구성)를 포함합니다. 사용자가 Clerk 리소스와 관련된 질문을 하면, 직접 curl을 작성하는 대신 먼저 clerk을 사용하세요.