AGENT SKILL
mobile-android-kotlin
暂无简介
- License 许可
- MIT
- 最近更新
- 2026-11-06
- Stars
- ★ 8
- Forks
- 0
02 资源文件 1
- 参考文档evals.json688 B
03 SKILL.md 正文
mobile-android-kotlin
Idiomatic Kotlin, structured concurrency via scoped coroutines, lifecycle-aware flows.
What you do
Write Kotlin that respects Android lifecycles. Prefer Jetpack Compose for new UI; use the View system when interop, legacy screens, or custom drawing require it. Coroutines with proper scope (never GlobalScope) and Flow / StateFlow for reactive streams.
- Scope coroutines to
viewModelScope,lifecycleScope, orCoroutineScope(SupervisorJob() + dispatcher)— never leak. - Use
StateFlowfor UI state,SharedFlowfor events;LiveDataonly when Java interop demands. - Hold application context in singletons; never capture activity context in long-lived objects.
- Model UI state as a single immutable data class — one source of truth per screen.
- Use
Result/ sealed error types over exceptions for expected failures. - Handle configuration changes correctly — ViewModel survives rotation.
Output shape
Kotlin source plus build notes:
- Source — one file per logical unit; follow Kotlin coding conventions.
- Previews / tests —
@Previewfor Compose, instrumentation / unit tests for logic. - Gradle notes — dependencies added, minSdk / targetSdk impact, ProGuard / R8 rules.
- Manifest — any permissions, content providers, services added.
- Accessibility — TalkBack content descriptions, touch target sizes, contrast checks.
Anti-patterns
GlobalScope.launch— leaks coroutines beyond any lifecycle.- Misusing LiveData (
postValuein tight loops) or exposing mutable StateFlow. - Capturing activity context in a singleton or static field — guaranteed leak.
- Blocking the main thread with
runBlockingor synchronous network calls. !!non-null assertion on values that can legitimately be null.- Massive activities / fragments — extract ViewModels and repository layers.
Handoff
Return the Kotlin source paths and Gradle / manifest notes to the invoking mobile specialist. iOS parity chains into mobile-ios-swift; cross-platform into mobile-react-native. Performance work lives in mobile-performance-tuning. This skill does not dispatch.