mobile-kotlin
БесплатноБез исполняемых скриптовНе проверенWrites idiomatic modern Kotlin for Android: Kotlin 2.x, null safety, sealed and value classes, structured coroutines with injected dispatchers, Flow and…
от ahmadhussain0335258 установок в других каталогахОб этом скилле
Kotlin for Android
Write Kotlin the way a senior Android engineer would in a current codebase: null-safe, immutable by default, structured concurrency everywhere, Compose that skips work it does not need to do, and a build that is reproducible from the version catalog. Prefer the boring, documented API over a clever one.
When to use
- Writing new Kotlin code in an Android app: ViewModels, use cases, repositories, composables, DAOs, workers.
- Refactoring Java, callback or RxJava code to coroutines and Flow.
- Migrating XML screens to Jetpack Compose, kapt to KSP, Groovy Gradle to Kotlin DSL.
- Fixing recomposition, lifecycle, coroutine-leak or nullability bugs.
- Updating code for a new
targetSdk(edge-to-edge, predictive back, foreground service rules).
Not for: architecture choice (use mobile-mvvm, mobile-mvi), a security audit (use mobile-security),
legacy Java maintenance (use mobile-java), or reviewing someone else's diff (use mobile-code-review).
Workflow
- Read the project before writing code.
gradle/libs.versions.toml: Kotlin, AGP, Compose BOM, coroutines, Hilt, Room versions.- Module
build.gradle.kts:minSdk,targetSdk,compileSdk, KSP or kapt, Compose enabled. - Existing conventions: package layout, base classes, dispatcher qualifiers, error types, test style.
- Match the existing stack. Do not add a library the project does not use without saying so.
Do not change
minSdk,targetSdkorcompileSdkwithout asking. - Load the reference for the area being touched: Coroutines and Flow, Compose, Hilt and Room, Build and tooling, Platform changes, Testing.
- Model first: domain types, UI state, events, errors as sealed or data types. Then data layer, then ViewModel, then UI.
- Write the code following the Rules below. Keep functions small,
privateby default, and public API explicit about types. - Add or update unit tests for new domain and data logic, and a Compose test for new interactive UI.
- Run the build, the tests and the linters (
./gradlew detekt ktlintCheck testDebugUnitTestor the project's equivalents). Report failures honestly; do not declare done on a red build. - Summarize what changed, any new dependency, and any manifest, permission or SDK impact.
Baseline stack
| Area | Default | Avoid in new code |
|---|---|---|
| Language | Kotlin 2.x, K2 compiler | Kotlin 1.x language versions, synthetic view imports |
| UI | Jetpack Compose + Material 3 | New XML layouts, findViewById |
| State | StateFlow + immutable data class |
LiveData in new ViewModels, mutable public state |
| Async | Coroutines + Flow | AsyncTask, raw threads, new RxJava |
| DI | Hilt with constructor injection | Manual singletons, service locators |
| Persistence | Room (suspend + Flow), DataStore | SharedPreferences for new code |
| Serialization | kotlinx.serialization | Reflection-based parsers without keep rules |
| Codegen | KSP | kapt where a KSP processor exists |
| Build | Kotlin DSL + libs.versions.toml |
Hardcoded versions in module files |
Rules
1. No !!. Fail with a message or handle the null
// BAD: NullPointerException with no context
val id = savedStateHandle.get<String>("id")!!
// GOOD: invariant violation explains itself
val id = requireNotNull(savedStateHandle.get<String>("id")) { "id nav argument missing" }
// GOOD: absence is a normal case
val name = user?.displayName ?: context.getString(R.string.anonymous)
checkNotNullfor state invariants,requireNotNullfor arguments. Java platform types are nullable.lateinitonly for framework-injected fields (@Inject lateinit varin an entry point), never for data.
2. State is immutable; variants are sealed
// BAD: mutable fields, impossible states (loading and error at once)
class ProfileState { var loading = false; var error: String? = null; var user: User? = null }
// GOOD
sealed interface ProfileUiState {
data object Loading : ProfileUiState
data class Content(val user: User, val isRefreshing: Boolean = false) : ProfileUiState
data class Error(val reason: UiError) : ProfileUiState
}
whenover a sealed type has noelse, so a new variant is a compile error, not a silent fallthrough.- Use
valand read-only collection types in data classes. Change state withcopy. - Guard conditions in
when(stable since Kotlin 2.2) replace nestedifinside a branch:is ProfileUiState.Content if it.isRefreshing -> ....
3. Typed IDs use value classes
// BAD: easy to swap arguments, compiler cannot help
fun assign(deviceId: String, userId: String)
assign(user.id, device.id) // compiles, wrong
// GOOD: zero-cost wrapper on the JVM
@JvmInline value class DeviceId(val value: String)
@JvmInline value class UserId(val valu
Установить mobile-kotlin в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл mobile-kotlin?
Writes idiomatic modern Kotlin for Android: Kotlin 2.x, null safety, sealed and value classes, structured coroutines with injected dispatchers, Flow and StateFlow, Jetpack Compose state and stability, Hilt, Room, KSP, Gradle version catalogs, R8 and tests with MockK and Turbine, plus Android 15 and 16 changes. Use when writing or refactoring Kotlin ViewModels, composables, repositories, DAOs, DI modules or build.gradle.kts files.
Как установить скилл mobile-kotlin?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл mobile-kotlin запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic