Custom Flow Reference (ClerkKit)
Use this file only when flow type is custom.
Purpose
Implement native iOS auth with ClerkKit primitives while keeping flow and layout very close to ClerkKitUI AuthView by default.
Source-Driven Requirements
Use installed package source from Xcode DerivedData:
~/Library/Developer/Xcode/DerivedData/.../SourcePackages/checkouts/clerk-ios
Source priority rules for custom flow:
- Primary source: installed
ClerkKitUIsource for auth UI behavior and gating parity. - Secondary source: installed
ClerkKitsource for core auth/network/config behavior. - Fallback only: example apps (local or GitHub) when behavior is unclear from library source.
For custom flows, treat ClerkKitUI AuthView as a strict parity target for:
- step progression/sequencing
- field visibility and hidden-state rules per step
- branching between factors/strategies
- screen structure and layout composition per step
- view hierarchy and section ordering per step
Required Patterns
- Package products
- If
clerk-iosis not installed, add it using the latest available release with an up-to-next-major package requirement. - Do not pin an exact package version unless the developer explicitly requests version pinning.
- Add
ClerkKitby default. - Add
ClerkKitUIonly if the developer explicitly asks for mixed prebuilt/custom composition.
- Quickstart prerequisite audit
- Find the iOS quickstart URL in the installed
clerk-iospackage README, append.md, then visit and read that markdown URL. - Build a checklist from the visited markdown quickstart and verify the current project completed all required setup.
- If required setup is missing, add it before finishing custom auth implementation.
- Always add any missing Associated Domains entries and any other capabilities required by the quickstart.
- Explicitly apply quickstart step
Add associated domain capability(https://clerk.com/docs/ios/getting-started/quickstart#add-associated-domain-capability); ensurewebcredentials:{YOUR_FRONTEND_API_URL}exists when missing.
- Environment inspection + normalization
- Inspect installed
ClerkKitUIsource first to identify whichEnvironmentfields and semantics drive flow behavior. - Build an agent-internal
Environmentfield map from that source inspection. - Make a direct HTTP call to
/v1/environmentonly after theEnvironmentfield map is defined. - Derive from the response using that
ClerkKitUI-aligned field map (agent-internal only):- normalized ClerkKitUI-style capability matrix
- required-field matrix
- Drive custom-flow implementation decisions from these matrices.
- Do not serialize or add these matrices as source artifacts in the app codebase.
- Combined-entry default
- Keep a combined sign-in-or-sign-up entry by default.
- Do not add a local sign-in/sign-up mode switcher unless explicitly requested.
- AuthView progression parity
- Follow
ClerkKitUIAuthViewprogression logic for advancing/regressing steps. - Show/hide inputs exactly according to the active step requirements instead of static form layouts.
- Keep factor/strategy branching aligned with how
AuthViewgates transitions. - Keep screen layout and component structure very close to
AuthViewdefaults unless the developer explicitly requests a different UX. - Keep view hierarchy and section ordering close to
AuthViewon each step; do not redesign the information architecture unless explicitly requested. - Break the custom flow into multiple step screens/states similar to
AuthView; do not try to gather all signup/signin requirements in one view. - If proposed custom layout materially deviates from
AuthView, stop and ask for explicit developer approval before implementing.
- Multi-file organization and separation of concerns
- Break custom auth flow into focused files/modules instead of one large screen file.
- Separate UI step views, flow/state orchestration, and Clerk/network integration responsibilities.
- Keep per-file responsibilities narrow and composable so new factors/steps can be added without rewriting a monolithic view.
- Capability-matrix-driven implementation
- Drive custom flow behavior from normalized ClerkKitUI-style capability mapping.
- Do not rely on one-off raw environment checks.
- Apply matrix outcomes to runtime flow logic only; do not add matrix models/constants/files to the project.
- Ensure custom logic uses the same environment-field gates and interpretations that
ClerkKitUIuses.
- Required-field coverage
- Implement all required fields from required-field matrix.
- Do not ship flow with missing required fields.
- Apple sign-in policy
- Implement Apple via native Clerk Apple path.
- If Apple capability is required for this app and missing, add it.
- Do not implement Apple through generic social-provider OAuth handling.
- Source parity
- Follow installed
ClerkKitUIandClerkKitsource patterns for sequencing, factor handling, and verification steps. - When unsure about custom-flow implementation details, sequencing, gating, or
Environmentusage/semantics, stop guessing and reference installedClerkKitUIimplementation behavior. - Resolve ambiguity by mirroring
ClerkKitUIbehavior unless the developer explicitly asks for a different approach.
Verification Checklist
- Quickstart prerequisites are complete
- Quickstart link was sourced from installed
clerk-iospackage README,.mdwas appended, and the markdown page was visited/read. - Required project setup from quickstart is present.
- Any missing quickstart-required Associated Domains/capabilities were added, not just reported.
- Quickstart
Add associated domain capabilitystep was applied, includingwebcredentials:{YOUR_FRONTEND_API_URL}.
- No unrequested mode switcher
- No local toggle/segmented control/tabs for sign-in vs sign-up unless explicitly requested.
- Environment call completed
- Installed
ClerkKitUIEnvironmentfield usage was inspected before calling/v1/environment. - Direct
/v1/environmentcall succeeded after field-map inspection.
- AuthView flow parity
- Step transitions follow
AuthViewprogression rules. - Inputs shown at each step match
AuthViewstep-level visibility behavior. - Step layouts and component grouping are materially close to
AuthView; do not introduce major layout redesign unless explicitly requested. - View hierarchy/section ordering remain close to
AuthViewacross steps unless explicitly requested otherwise. - Flow is split across multiple steps like
AuthView; required data is not collected in one monolithic screen. - When implementation ambiguity appears, final behavior matches installed
ClerkKitUIrather than an inferred/custom interpretation.
- Flow organization quality
- Custom flow code is split into multiple focused files/modules (not a single monolithic auth view file).
- UI, state/flow orchestration, and integration logic are separated with clear boundaries.
- Matrices created and used
- Capability matrix and required-field matrix exist and drive the implementation.
- Matrix artifacts are not written into project source files.
- Environment fields used for gating/requirements match the set and semantics used by installed
ClerkKitUI.
- Required fields covered
- Required-field matrix has full coverage in custom UI.
- Capability-map parity
- Feature availability and branching use normalized capability map.
- Apple path correctness
- Apple flow uses native path, not generic provider OAuth path.
- No unrequested prebuilt dependency
ClerkKitUIis not added unless explicitly needed.