Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

mobile-kotlin

БесплатноБез исполняемых скриптовНе проверен

Writes idiomatic modern Kotlin for Android: Kotlin 2.x, null safety, sealed and value classes, structured coroutines with injected dispatchers, Flow and…

ahmadhussain0335от 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

  1. 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.
  2. Match the existing stack. Do not add a library the project does not use without saying so. Do not change minSdk, targetSdk or compileSdk without asking.
  3. Load the reference for the area being touched: Coroutines and Flow, Compose, Hilt and Room, Build and tooling, Platform changes, Testing.
  4. Model first: domain types, UI state, events, errors as sealed or data types. Then data layer, then ViewModel, then UI.
  5. Write the code following the Rules below. Keep functions small, private by default, and public API explicit about types.
  6. Add or update unit tests for new domain and data logic, and a Compose test for new interactive UI.
  7. Run the build, the tests and the linters (./gradlew detekt ktlintCheck testDebugUnitTest or the project's equivalents). Report failures honestly; do not declare done on a red build.
  8. 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)
  • checkNotNull for state invariants, requireNotNull for arguments. Java platform types are nullable.
  • lateinit only for framework-injected fields (@Inject lateinit var in 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
}
  • when over a sealed type has no else, so a new variant is a compile error, not a silent fallthrough.
  • Use val and read-only collection types in data classes. Change state with copy.
  • Guard conditions in when (stable since Kotlin 2.2) replace nested if inside 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
Полный SKILL.md на ClawHub

Установить 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), без исполняемых скриптов.

Похожие скиллы

Сравнить mobile-kotlin с