Null-safety and closed types win !!. Language first; Android UI: jetpack-compose / android-development. Real async: kotlin-coroutines.
Tooling
- Kotlin 2.x / K2 in new code; respect
kotlinin Gradle/version catalog. kotlincwarnings handled in scope.kotlinOptions.jvmTargetaligned with the project's minSdk/JDK.- Style: ktlint / detekt if the repo already uses them.
Organization
src/main/kotlin/.../
domain/
data/ # se houver I/O
- Packages by domain.
internalfor module API. - Prefer files by public type; avoid
Utils.ktgiant. - Top-level functions only for pure and stable helpers.
Language
valdefault;varonly with a clear lifecycle.data classfor values;classfor identity.value classfor IDs.sealed class/sealed interfacefor states (Loading/Ready/Err).- Exhaustive
whenwithoutelseblind on sealed. - Extensions for APIs that the type should not know about; not to hide side effects.
inline/reifiedonly with real gain (not cosmetic).- Collections:
listOf,buildList; mutable only when the contract requires it.
@JvmInline
value class UserId(val value: String)
sealed interface LoadState<out T> {
data object Loading : LoadState<Nothing>
data class Ready<T>(val value: T) : LoadState<T>
data class Err(val reason: String) : LoadState<Nothing>
}
Null-safety
T?explicit. No!!except local invariant (Java platform type).?./?:/requireNotNullwith message.- Java annotations (
@Nullable) at JNI/SDK boundaries.
Functions and APIs
- Default args > explosive overloads.
- Named args in booleans (
notify = false). Result<T>or sealed error — one policy per boundary. Do not mixrunCatchingsilent with domain exceptions.typealiasonly when it clarifies; not to hidePair<String, String>.
JVM / Android Interop
@JvmName/@JvmStatic/@JvmOverloadsonly in the API called from Java.- Do not expose
Unitas a “magic void” in Java callbacks without documentation. - Coroutines on Android:
viewModelScope— details inkotlin-coroutines.
Anti-patterns
Any/!!cascadingobjectsingleton with global mutable state- Assume Compose/
@Composablein this skill apply/also/letunreadable nestedlateinitwithout init guarantee
Integration with other skills
- Coroutines/Flow:
kotlin-coroutines - Android app:
android-development - Compose:
jetpack-compose - Persistence:
android-room - JVM tests:
android-unit-testing
Completion criteria
- Honest null-safety; sealed for states
- APIs with clear defaults and named args
- No
!!unjustified - Formatted code; core tests if touched