π¦ ClawHub
Kotlin
by @ivangdavila
Build robust Android and multiplatform apps with Kotlin idioms, coroutines, and null safety.
TERMINAL
clawhub install kotlinπ About This Skill
name: Kotlin slug: kotlin version: 1.0.1 description: Build robust Android and multiplatform apps with Kotlin idioms, coroutines, and null safety. metadata: {"clawdbot":{"emoji":"π ","requires":{"bins":["kotlin"]},"os":["linux","darwin","win32"]}}
Quick Reference
| Topic | File |
|-------|------|
| Null safety operators and patterns | nullsafety.md |
| Coroutines, flows, structured concurrency | coroutines.md |
| Collections, sequences, data classes | collections.md |
| Scope functions, extensions, sealed classes | idioms.md |
| Java interop and common Kotlin mistakes | interop.md |
| Android lifecycle, Compose state | android.md |
| Delegation, inline, reified, multiplatform | advanced.md |
Critical Rules
Null Safety
!! asserts non-null β crashes on null, use only when you've already checked@Nullable/@NonNull annotationsreturn/throw for early exit β val name = user?.name ?: returnCoroutines
viewModelScope auto-cancels on ViewModel clear β don't use GlobalScope in AndroidsupervisorScope to isolateStateFlow needs initial value and never completes β SharedFlow for one-shot eventsDispatchers.IOCollections & Data Classes
first() throws on empty β use firstOrNull() for safe accessequals/hashCode β body properties ignoredmutableStateListOf for Compose β wrapping mutableListOf in state won't track changesScope Functions & Extensions
Android/Compose
repeatOnLifecycle(STARTED) for flow collection β launchWhenStarted is deprecatedremember survives recomposition only β use rememberSaveable for config changescollectAsStateWithLifecycle is the gold standard β lifecycle-aware + Compose stateJava Interop
== is structural equality in Kotlin β === for reference, opposite of Javafun interface@JvmStatic, @JvmOverloads, @JvmField for Java-friendly APIs