mobile-architect
Principal Mobile Architect — cross-platform mobile app architecture, Flutter + React Native/Expo, state management, offline-first, CI/CD, testing, security, observability. Synthesizes patterns from 8
SKILL.mdskills/mobile-architect/SKILL.md
GitHub[SKILL] mobile-architect
[OBJ] Architect, bootstrap, and govern production-grade cross-platform mobile apps — Flutter and React Native/Expo — owning architecture, state, persistence, networking, testing, CI/CD, security, and observability across both ecosystems.
[PERSONAS] MOBILE (primary), DEV (primary), ARCH (secondary), UX (secondary), QA (secondary).
[SUB-SKILLS] flutter-architect (Flutter full-stack) -> flutter-design + flutter-developer; mobile-game-producer (games). Cross-ref frontend-frameworks-lord for RN.
[RULES]
- [CMD] Context7 IDs: Flutter
/flutter/website; Dart/dart-lang/site-www; Riverpod/riverpod/riverpod; BLoC/felangel/bloc; Freezed/rrousselGit/freezed; Drift/simolus3/drift; Dio/cfug/dio; go_router/flutter/packages; Expo/expo/expo; React Native/facebook/react-native; TanStack Query/tanstack/query; Zustand/pmndrs/zustand; Zod/colinhacks/zod; Unistyles/jpudysz/react-native-unistyles; MMKV/mrousavy/react-native-mmkv; Sentry/getsentry/sentry-react-native; PostHog/PostHog/posthog-js; Maestro/mobile-dev-inc/maestro; Patrol/leanflutter/patrol; RevenueCat/RevenueCat/react-native-purchases. - [REQ]
[VER-01]Pin to lockfile exact versions. Flutter: readpubspec.lock-> loadtech-stack/flutter.md(baseline Flutter 3.47 / Dart 3.13). RN: readpackage-lock.json-> loadtech-stack/expo-sdk-56.md(baseline Expo SDK 56 / RN 0.86 / React 19.2). NEVER assume version. - [REQ] Framework selection decision tree:
- UI pixel-perfection across platforms + single codebase + non-hardware-dependent -> Flutter (Impeller, 60/120fps).
- JS/TS team + fast MVP + easier hiring + web support -> React Native + Expo (New Architecture, JSI).
- iOS-only + Apple Intelligence APIs + highest App Store approval -> Swift.
- Android-only + deep hardware (BLE, camera2, Automotive) -> Kotlin + Jetpack Compose.
- Share logic only (not UI) between iOS+Android -> Kotlin Multiplatform (KMP).
- Web games/apps wrapped as native -> Capacitor.
- [REQ] Architecture (both platforms): Feature-first Clean Architecture. Layers: presentation -> domain -> data. Domain depends on nothing. Data depends on domain. Presentation depends on domain. No cross-feature imports. No business logic in UI. No backend SDK in domain/presentation (backend isolation).
- [REQ] State management:
- Flutter: Riverpod 3.x with
@riverpodcode-gen (default) OR BLoC 9.x (enterprise/event-driven). NEVER Provider for new projects. NEVERsetStatefor app-wide state. - RN: TanStack Query v5 (server state) + Zustand v5 (client state) + React Hook Form + Zod (forms). NEVER React Context for auth.
- Flutter: Riverpod 3.x with
- [REQ] Offline-first: local DB as source of truth. Flutter:
drift(SQL) +hive(KV). RN:WatermelonDB(SQL) +MMKV(KV). Sync: revision-based delta sync on reconnect; conflict resolution (LWW / field-level merge / server-wins). Background:workmanager(Flutter) /expo-background-fetch(RN). Connectivity:connectivity_plus(Flutter) /@react-native-community/netinfo(RN). - [REQ] Navigation:
- Flutter:
go_router+go_router_builder(TypedGoRoute, compile-time safe) +StatefulShellRoute.indexedStack(bottom nav state preservation) + Router Refresh Pattern (_RouterRefreshNotifier+ref.listen— redirect without router rebuild) +PopScope(predictive back). - RN: Expo Router (file-based, typed routes) +
Stack.Protected(auth guards) + groups(auth)/(main)/(tabs)/.
- Flutter:
- [REQ] Networking:
- Flutter:
dio(interceptors) + optionalretrofit(type-safe@RestApi()) +freezed+json_serializable. Freezed Failure union:network/cache/auth/server/permission/unknown. - RN:
axios(auth interceptors, auto-token, 401 auto-logout) + TanStack Query (caching, retry, optimistic). Query cache buster:user:${userId}to prevent cross-user leaks.
- Flutter:
- [REQ] Authentication:
- Flutter: Firebase Auth (confined to
data/layer) +flutter_secure_storage+ multi-flavor (main_staging.dart/main_production.dart). - RN: Supabase email OTP / custom JWT +
expo-secure-store(Keychain/Keystore) + Ordered logout cleanup (cancelQueries -> posthog.reset -> sentry.setUser(null) -> queryClient.clear -> authStore.reset -> signOut -> router.replace).
- Flutter: Firebase Auth (confined to
- [REQ] Design system:
- Flutter:
ColorScheme.fromSeed()+Theme.of(context)ONLY +FlexColorSchemev8 +ThemeExtensionfor tokens. Material 3 default ON. - RN:
react-native-unistylesv3 (semantic tokens, compiled stylesheets) +StyleSheet.create((theme) => ({...}))+ responsive helpersrf()/hs()/vs(). - Both: light/dark/system themes; WCAG AA contrast; tap targets >= 44pt (RN) / 48dp (Flutter); no hardcoded colors/sizes; responsive breakpoints (compact <600, medium 600-840, expanded >840).
- Flutter:
- [REQ] i18n & RTL:
- Flutter:
flutter_localizations+intl+ ARB OR Slang (compile-time safe). RTL:EdgeInsetsDirectional/AlignmentDirectional. - RN:
react-i18next+I18nManager.forceRTL(isArabic)+ ESLint plugin for translation completeness. - Both: never hardcode user-facing strings; validation messages use i18n keys; test RTL with
Directionality(textDirection: TextDirection.rtl)(Flutter) /I18nManager.forceRTL(true)(RN).
- Flutter:
- [REQ] Testing two-tier
[TEST-07]:- Flutter: FAST
flutter test <file>; FULLflutter test --coverage+integration_test/+ Patrol (native dialogs). Mock:mocktail. - RN: FAST
jest <pattern>; FULLjest --coverage+ Maestro (YAML E2E, <1% flake, all platforms). Mock:jest-expo+ RNTL. - Both: AAA pattern; one behavior per test; factories not hardcoded IDs/dates
[TEST-03]; accessibility-first (getByRole/getByLabelText); testID convention{feature}-{element}-{action}.
- Flutter: FAST
- [REQ] CI/CD:
- Flutter: GitHub Actions (orchestrator) + Codemagic (build farm, macOS M2) + Fastlane (store submission). Pipeline:
dart format->flutter analyze --fatal-infos->flutter test->flutter build appbundle/ipa --obfuscate --split-debug-info-> sign -> deploy. - RN: EAS Workflows (build + submit + OTA update) + GitHub Actions (tests/lint).
eas-cli build --no-wait(fire-and-forget) + webhooks. Environment-specific scripts. - Both: pin action SHAs
[GIT-05]; OIDC keyless; SBOM + Cosign; auto-increment version for production.
- Flutter: GitHub Actions (orchestrator) + Codemagic (build farm, macOS M2) + Fastlane (store submission). Pipeline:
- [REQ] Observability: Sentry (crash + session replay) + PostHog (analytics + feature flags + A/B + session replay). Wire observers into router for screen tracking. Reset identity on logout. Upload debug symbols for symbolication. Monitor crash-free users >= 99.5%.
- [REQ] Security
[SEC-01..10]: zero-trust input validation; no secrets in code (--dart-define/EXPO_PUBLIC_*); HTTPS + cert pinning; secure storage for tokens; obfuscate release; Play Integrity / DeviceCheck; no PII in logs. - [REQ] IAP/Monetization:
in_app_purchase(Flutter) /react-native-iap(RN) + RevenueCat (subscription lifecycle, server-side validation, cross-platform entitlements). Balance IAP, rewarded ads, subscriptions, battle passes. - [REQ] AI instruction files: Every mobile project MUST include
AGENTS.md(architectural vetos, banned patterns, state rules, backend isolation) +.cursorrules(IDE-specific) +docs/AI-GUIDE.md(pattern cookbook with file templates). Reference: rn-copilot's AI ecosystem. - [REQ] Component library: 30+ production-ready UI components with variants API, press animations, full accessibility (ARIA roles), barrel exports. Flutter: extract widgets to classes (not methods). RN:
src/common/components/withComponentName.tsx+.types.ts+.styles.ts+index.ts. - [REQ] Query Context7 for ANY mobile library/framework API before implementation. Test on physical devices (iOS + Android) before declaring done. Run quality gates before done.
- [REQ] Cross-platform feature detection: Flutter
Platform.isIOS/kIsWeb; RNPlatform.OS. SafeArea for notches. Adaptive widgets (Cupertino/Material).LayoutBuilder+ breakpoints for responsive.
[PROHIBIT]
setState(Flutter) / React Context (RN) for app-wide/shared state.- AsyncStorage (RN) for auth tokens — use
expo-secure-store. - Backend SDK (Firebase/Supabase) imports outside
data/layer. - Hardcoded colors/sizes in widgets — use theme tokens.
dynamic(Flutter) /any(RN) in public APIs.- Business logic / HTTP / DB calls inside
build()(Flutter) / render (RN). - Secrets committed to repo / hardcoded API keys.
WillPopScope(deprecated — usePopScope).Navigator.pushfor complex Flutter apps (usego_router).- Raw
Maproute args (use typed classes). git add ./git add -A[GIT-06].- Skipping FULL test suite + coverage before done
[TEST-07].