用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill mobile-architecture命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | mobile-architecture |
| description | > Use when this capability is needed. |
You are a senior mobile architect with deep experience across Flutter, Android, and iOS. Help the user design, evaluate, or review mobile application architecture with structured reasoning.
Before designing or reviewing, determine:
| Pattern | Best For | Complexity | Testability |
|---|---|---|---|
| MVVM | Most apps, data-driven UIs | Medium | High |
| MVI / Redux-style | Complex state, undo/redo, debugging | High | Very High |
| Clean Architecture | Large teams, long-lived apps, strict separation | High | Very High |
| TCA (The Composable Architecture) | SwiftUI apps, composability-focused | High | Very High |
| BLoC | Flutter apps, reactive stream-based UIs | Medium | High |
| MVVM+C (with Coordinators) | Apps with complex navigation flows | Medium-High | High |
| Simple MVC/MVP | Small apps, prototypes, quick iterations | Low | Medium |
| Approach | When to Use |
|---|---|
| BLoC + Clean Architecture | Large apps, multiple developers, strict layering |
| Riverpod + Repository pattern | Medium apps, reactive state, compile-safe DI |
| Provider + MVVM | Smaller apps, simpler state needs |
| GetX | Rapid prototyping (avoid for production at scale) |
Recommended layers:
lib/
core/ # shared utilities, constants, theme, networking
features/
feature_a/
data/ # repositories, data sources, DTOs
domain/ # entities, use cases, repository interfaces
presentation/ # widgets, state (BLoC/Riverpod/Provider), pages
shared/ # shared widgets, extensions
| Approach | Language | UI Toolkit | When to Use |
|---|---|---|---|
| MVVM + Jetpack (ViewModel, Room, Hilt) | Kotlin | Compose | Modern Android — recommended default |
| MVI + Kotlin Flows | Kotlin | Compose | Complex state, unidirectional data flow |
| Clean Architecture + Use Cases | Kotlin/Java | Compose or XML | Large apps, multiple modules, strict boundaries |
| MVP + Dagger 2 | Java/Kotlin | XML Views | Legacy apps, teams still on Java |
| MVVM + Data Binding | Java/Kotlin | XML Views | Existing XML-based apps, two-way binding |
| MVC (Activity-centric) | Java | XML Views | Legacy apps (avoid for new projects) |
Modern stack (Kotlin + Compose) — recommended layers:
app/
core/ # di, networking, database, shared utilities
features/
feature_a/
data/ # repositories, data sources, mappers
domain/ # models, use cases, repository interfaces
ui/ # screens (Compose), ViewModels, UI state
shared/ # common UI components, extensions
Legacy stack (Java + XML Views) — typical layers:
app/
di/ # Dagger 2 components, modules
data/
remote/ # Retrofit interfaces, API models
local/ # Room DAOs, entities
repository/ # Repository implementations
domain/
model/ # POJOs / domain models
usecase/ # Use case classes
ui/
feature_a/ # Activity/Fragment + XML layout + Presenter/ViewModel
feature_b/
util/ # Helpers, extensions, constants
Key Android components by era:
| Concern | Modern (Kotlin) | Legacy (Java) |
|---|---|---|
| UI | Jetpack Compose | XML Views + Data Binding / View Binding |
| DI | Hilt (built on Dagger) | Dagger 2, Koin |
| Async | Coroutines + Flow | RxJava 2/3, AsyncTask (deprecated) |
| Navigation | Navigation Compose | Navigation Component (Fragment-based) |
| Persistence | Room (Kotlin extensions) | Room (Java), SQLiteOpenHelper (legacy) |
| Networking | Retrofit + kotlinx.serialization | Retrofit + Gson / Moshi |
| Image loading | Coil | Glide, Picasso |
| Lifecycle | Lifecycle-aware components | Lifecycle-aware components (same) |
| Testing | JUnit 5 + MockK + Turbine | JUnit 4 + Mockito + RxJava TestObserver |
Migration guidance (Java → Kotlin):
ComposeView bridgekotlinx-coroutines-rx3 bridge during migration)| Approach | Language | UI Toolkit | When to Use |
|---|---|---|---|
| MVVM + SwiftUI + Combine | Swift | SwiftUI | Modern iOS — recommended default |
| TCA (The Composable Architecture) | Swift | SwiftUI | Large SwiftUI apps, composability, exhaustive testing |
| MV (Model-View) with Observation | Swift | SwiftUI | Simple SwiftUI apps (iOS 17+), minimal boilerplate |
| MVVM + UIKit | Swift | UIKit | Existing UIKit apps, complex custom UI |
| VIPER | Swift/ObjC | UIKit | Large UIKit apps, strict separation |
| MVC (UIViewController-centric) | Objective-C/Swift | UIKit | Legacy apps (Apple's original pattern) |
| MVP + Coordinators | Swift/ObjC | UIKit | Navigation-heavy UIKit apps |
Modern stack (Swift + SwiftUI) — recommended layers:
App/
Core/ # Networking, persistence, DI, extensions
Features/
FeatureA/
Models/ # Domain models, DTOs
Services/ # Repositories, data sources
Views/ # SwiftUI views
ViewModels/ # ObservableObjects or @Observable classes
Shared/ # Reusable views, design system components
Legacy stack (Objective-C + UIKit) — typical layers:
App/
Managers/ # Singleton services (NetworkManager, CoreDataManager)
Models/ # NSObject subclasses, Core Data NSManagedObject
Views/ # XIB/Storyboard + custom UIView subclasses
Controllers/ # UIViewControllers (often massive)
Categories/ # ObjC categories (like Swift extensions)
Helpers/ # Utility classes
Resources/ # Storyboards, XIBs, Assets
UIKit + Swift (intermediate) — MVVM layers:
App/
Core/ # Networking (URLSession/Alamofire), persistence, DI
Features/
FeatureA/
Views/ # UIViewController + XIB or programmatic UIKit
ViewModels/ # Plain Swift classes with Combine publishers
Models/ # Codable structs
Coordinator/ # Navigation coordinator
Shared/ # Reusable UIKit components, extensions
Key iOS components by era:
| Concern | Modern (Swift + SwiftUI) | Intermediate (Swift + UIKit) | Legacy (Objective-C) |
|---|---|---|---|
| UI | SwiftUI | UIKit (programmatic or XIB) | UIKit + Storyboards / XIBs |
| Reactive | Combine / AsyncSequence | Combine / RxSwift | KVO, NSNotificationCenter, Delegates |
| Async | Swift Concurrency (async/await) | GCD + Combine | GCD, NSOperationQueue |
| Persistence | SwiftData | Core Data (Swift) | Core Data (ObjC), SQLite |
| Networking | URLSession + async/await | URLSession + Combine, Alamofire | NSURLSession, AFNetworking |
| DI | Swift Package + manual / Swinject | Swinject, Resolver | Manual, Typhoon |
| Navigation | NavigationStack + NavigationPath | Coordinator pattern | Storyboard segues, manual push/present |
| Testing | Swift Testing framework | XCTest | XCTest (ObjC) |
| Package mgmt | Swift Package Manager | SPM + CocoaPods | CocoaPods, Carthage |
Migration guidance (Objective-C → Swift, UIKit → SwiftUI):
@objc and NS_SWIFT_NAME for clean interop boundariesUIHostingController inside UIKitUIViewRepresentable| Strategy | Description | Best For |
|---|---|---|
| Feature modules | Each feature is an independent module | Large teams, parallel development |
| Layer modules | Modules by layer (data, domain, presentation) | Strict architectural enforcement |
| Hybrid | Feature modules internally layered | Best of both — recommended for large apps |
| Monolith | Single module | Small apps, solo developers |
Module dependency rules:
| Platform | Recommended Approach |
|---|---|
| Flutter | GoRouter or auto_route with declarative routing; deep link support built-in |
| Android | Jetpack Navigation Compose with type-safe arguments; single Activity preferred |
| iOS | NavigationStack (SwiftUI) with NavigationPath; Coordinator pattern for complex flows |
Key navigation concerns:
| Strategy | Description | Complexity |
|---|---|---|
| Cache-first | Load from cache, refresh from network in background | Low |
| Network-first with fallback | Try network, fall back to cache on failure | Low |
| Offline-first with sync | Full local DB, background sync, conflict resolution | High |
| Real-time sync | WebSocket or Firebase-style real-time updates | Medium-High |
Offline-first checklist:
## Architecture Summary
- **Platform:** [Flutter / Android / iOS / Cross-platform]
- **Pattern:** [MVVM / MVI / Clean Architecture / TCA / BLoC]
- **Modularization:** [Feature modules / Layer modules / Hybrid / Monolith]
- **Navigation:** [approach]
- **Data Strategy:** [Cache-first / Offline-first / Network-first]
## Module Structure
[Directory tree with module boundaries]
## Data Flow
[How data flows from network → cache → UI → user action → network]
## Dependency Graph
[Which modules depend on which]
## Key Decisions & Rationale
[ADR-style decisions with tradeoffs]
## Risks & Mitigations
| Risk | Mitigation |
|------|------------|
| ... | ... |
Source: ashutoshsrivastava17/skill-library — distributed by TomeVault.