Skip to content
Agent Orchestration
Skill

/mobile

移动开发。iOS、Android、SwiftUI、Jetpack Compose、React Native、Flutter、跨平台。当用户提到移动开发、iOS、Android、跨平台时路由到此。

BOOST
From plugin
ccg
5.9k47 skills19 commands
Install
$ npx -y skills add fengshao1227/ccg-workflow --skill mobile --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/mobile

Context preview

The summary Claude sees to decide when to auto-load this skill.

移动开发。iOS、Android、SwiftUI、Jetpack Compose、React Native、Flutter、跨平台。当用户提到移动开发、iOS、Android、跨平台时路由到此。

SKILL.md

mobile.SKILL.md
name: mobile
description: 移动开发。iOS、Android、SwiftUI、Jetpack Compose、React Native、Flutter、跨平台。当用户提到移动开发、iOS、Android、跨平台时路由到此。
license: MIT
user-invocable: false
disable-model-invocation: false

移动开发域 · Mobile Development

域概览

原生开发                    跨平台开发
├── iOS (SwiftUI/UIKit)     ├── React Native (JS/TS)
├── Android (Compose/Kotlin) └── Flutter (Dart)
└── 共通:MVVM / 网络层 / 持久化 / 测试

---

iOS 开发

SwiftUI 核心模式

  • View 组件:`struct MyView: View { var body: some View { ... } }`
  • State 管理:
  • `@State` — 本地状态
  • `@Binding` — 父子双向绑定
  • `@StateObject` — 拥有 ObservableObject
  • `@ObservedObject` — 引用 ObservableObject
  • `@EnvironmentObject` / `@Environment` — 全局注入
  • ObservableObject:`@Published` 属性自动触发 UI 更新
  • Custom ViewModifier:`struct CardModifier: ViewModifier` + `extension View { func cardStyle() }`
  • 生命周期:`.task { await ... }` / `.onAppear` / `.onDisappear`

UIKit 集成

  • UIViewControllerRepresentable:包装 UIViewController 到 SwiftUI
  • UIViewRepresentable:包装 UIView 到 SwiftUI
  • Coordinator 模式:处理 delegate 回调
  • Auto Layout:`NSLayoutConstraint.activate([...])` + `translatesAutoresizingMaskIntoConstraints = false`

Combine 响应式

  • Publisher:`URLSession.shared.dataTaskPublisher` → `map` → `decode` → `eraseToAnyPublisher`
  • 订阅:`.sink(receiveCompletion:receiveValue:)` + `.store(in: &cancellables)`
  • 常用 Operators:`debounce` / `removeDuplicates` / `combineLatest` / `flatMap`
  • Subject:`PassthroughSubject`(无初始值)/ `CurrentValueSubject`(有初始值)

iOS 架构

MVVM(推荐):

  • Model:`Codable` 数据结构
  • Repository:`protocol` + `async throws` 方法
  • ViewModel:`@MainActor class VM: ObservableObject` + `@Published` 属性
  • View:`@StateObject private var viewModel = VM()`

VIPER(复杂场景):

  • View ←→ Presenter ←→ Interactor → Entity
  • Router 处理导航

网络层

  • APIClient:泛型 `func get<T: Decodable>(_ path:) async throws -> T`
  • Token 管理:`request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")`
  • 错误处理:`enum APIError: Error { case invalidURL, invalidResponse, httpError(Int) }`

数据持久化

  • UserDefaults:`@propertyWrapper struct UserDefault<T>` 简化访问
  • Keychain:`SecItemAdd` / `SecItemCopyMatching` 存储敏感数据
  • Core Data:`NSPersistentContainer` + `NSManagedObjectContext`
  • SwiftData(iOS 17+):`@Model` 宏简化持久化

iOS Checklist

  • [ ] SwiftUI 优先,UIKit 按需集成
  • [ ] `@MainActor` 确保 UI 线程安全
  • [ ] async/await 替代回调
  • [ ] 依赖注入提升可测试性
  • [ ] LazyVStack/LazyHStack 优化大列表
  • [ ] 图片缓存(NSCache)减少内存压力
  • [ ] Keychain 存储敏感数据(非 UserDefaults)
  • [ ] 单元测试覆盖 ViewModel + Mock Repository

---

Android 开发

Jetpack Compose 核心模式

  • Composable:`@Composable fun MyScreen() { ... }`
  • State 管理:
  • `remember { mutableStateOf(value) }` — 本地状态
  • `rememberSaveable` — 跨配置变更保存
  • `derivedStateOf` — 派生状态避免重组
  • LazyColumn:`items(list, key = { it.id })` 提供稳定 key
  • Side Effects:
  • `LaunchedEffect(key)` — 启动协程
  • `DisposableEffect(key)` — 清理资源(onDispose)
  • `SideEffect` — 同步状态到外部
  • `snapshotFlow { state }` — 监听状态变化转 Flow
  • Navigation:`NavHost` + `composable(route)` + `navController.navigate()`
  • Custom Modifier:`fun Modifier.myModifier(): Modifier = composed { ... }`

ViewModel + StateFlow

  • StateFlow(推荐替代 LiveData):
  • `MutableStateFlow(UiState())` + `.asStateFlow()`
  • `_uiState.update { it.copy(isLoading = true) }`
  • Compose 中:`val uiState by viewModel.uiState.collectAsState()`
  • UiState data class:封装 loading / error / data

Kotlin Coroutines & Flow

  • 协程:`viewModelScope.launch { withContext(Dispatchers.IO) { ... } }`
  • 并发:`coroutineScope { val a = async { ... }; val b = async { ... } }`
  • Flow:`flow { emit(value) }` + `.flowOn(Dispatchers.IO)`
  • StateFlow:`.stateIn(scope, SharingStarted.WhileSubscribed(5000), initial)`
  • 搜索防抖:`searchQuery.debounce(300).filter { it.isNotEmpty() }.flatMapLatest { ... }`
  • Channel:`Channel<Event>(BUFFERED)` + `.receiveAsFlow()` 一次性事件

依赖注入 (Hilt)

  • `@HiltAndroidApp` Application + `@AndroidEntryPoint` Activity
  • `@Module @InstallIn(SingletonComponent::class)` 提供依赖
  • `@Provides @Singleton` 提供实例 / `@Binds` 绑定接口
  • ViewModel:`@HiltViewModel class VM @Inject constructor(repo)` + `hiltViewModel()`

Room 数据库

  • Entity:`@Entity(tableName)` + `@PrimaryKey` + `@ColumnInfo`
  • DAO:`@Query` / `@Insert(onConflict = REPLACE)` / `@Delete` + 返回 `Flow<List<T>>`
  • Database:`@Database(entities, version)` + `Room.databaseBuilder`

网络层 (Retrofit)

  • ApiService:`@GET` / `@POST` / `@Path` / `@Query` / `@Body` / `@Multipart`
  • Interceptor:AuthInterceptor 注入 Bearer Token
  • OkHttpClient:`addInterceptor` + `connectTimeout`

Android Checklist

  • [ ] Compose 优先,View 系统按需使用
  • [ ] StateFlow 替代 LiveData
  • [ ] Hilt 依赖注入
  • [ ] Room 本地持久化
  • [ ] `key` 参数优化 LazyColumn
  • [ ] `remember` / `derivedStateOf` 避免过度重组
  • [ ] Coil 图片加载 + 缓存策略
  • [ ] 单元测试覆盖 ViewModel(runTest + advanceUntilIdle)

---

跨平台开发

React Native vs Flutter

| 维度 | React Native | Flutter | |------|--------------|---------| | 语言 | TypeScript | Dart | | 渲染 | 原生组件(桥接) | 自绘引擎(Skia) | | 性能 | 接近原生 | 接近原生 | | 热重载 | Fast Refresh | Hot Reload | | 生态 | npm(成熟) | pub.dev(快速增长) | | UI 一致性 | 跟随系统 | 完全一致 | | 包体积 | ~7MB | ~15MB |

React Native 核心模式

  • 组件:函数组件 + Hooks(useState / useEffect / useCallback / useMemo)
  • 列表:`FlatList` + `keyExtractor` + `initialNumToRender` + `windowSize`
  • Navigation:`@react-navigation/native` + `createNativeStackNavigator`
  • 状态管理:Redux Toolkit(`createSlice` + `createAsyncThunk`)/ Zustand
  • 原生桥接:`NativeModules` 调用 iOS(Swift) / Android(Kotlin) 原生代码
  • 性能:`React.memo` / Hermes 引擎 / 新架构 JSI(无桥接序列化)

Flutter 核心模式

  • Widget:StatelessWidget / StatefulWidget + `setState`
  • 状态管理:
  • Provider:`ChangeNotifier` + `Consumer` / `context.watch`
  • Riverpod(推荐):`FutureProvider` / `StateNotifierProvider` + `ref.watch`
  • Navigation:go_router(`GoRoute` + `context.go/push/pop`)
  • 原生桥接:`MethodChannel` + Platform Channels(iOS Swift / Android Kotli
Read more
Ships withccg

多模型协作工作流引擎 — /ccg:go 一个命令,AI 自动分析意图、选择策略、编排 Codex + Gemini + Claude 协作执行

Get the whole plugin

Other skills on ccg.

verify-change
Skill

verify-change

变更校验关卡。分析代码变更,检测文档同步状态,评估变更影响范围。当用户提到变更检查、文档同步、代码审查、提交前检查、diff分析时使用。在设计级变更、重构完成时自动触发。

verify-module
Skill

verify-module

模块完整性校验关卡。扫描目录结构、检测缺失文档、验证代码与文档同步。当用户提到模块校验、文档检查、结构完整性、README检查、DESIGN检查时使用。在新建模块完成时自动触发。

verify-quality
Skill

verify-quality

代码质量校验关卡。检测复杂度、重复代码、命名规范、函数长度等质量指标。当用户提到代码质量、复杂度检查、代码异味、重构建议、lint检查、代码规范时使用。在复杂模块、重构完成时自动触发。

verify-security
Skill

verify-security

安全校验关卡。自动扫描代码安全漏洞,检测危险模式,确保安全决策有文档记录。当用户提到安全扫描、漏洞检测、安全审计、代码安全、OWASP、注入检测、敏感信息泄露时使用。在新建模块、安全相关变…