Kotlin

Build robust Android and multiplatform apps with Kotlin idioms, coroutines, and null safety.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "Kotlin" with this command: npx skills add ivangdavila/kotlin

Quick Reference

TopicFile
Null safety operators and patternsnullsafety.md
Coroutines, flows, structured concurrencycoroutines.md
Collections, sequences, data classescollections.md
Scope functions, extensions, sealed classesidioms.md
Java interop and common Kotlin mistakesinterop.md
Android lifecycle, Compose stateandroid.md
Delegation, inline, reified, multiplatformadvanced.md

Critical Rules

Null Safety

  • !! asserts non-null — crashes on null, use only when you've already checked
  • Platform types from Java are risky — add null checks or use @Nullable/@NonNull annotations
  • Elvis with return/throw for early exit — val name = user?.name ?: return

Coroutines

  • viewModelScope auto-cancels on ViewModel clear — don't use GlobalScope in Android
  • Structured concurrency: child coroutine failure cancels parent — use supervisorScope to isolate
  • StateFlow needs initial value and never completes — SharedFlow for one-shot events
  • Inject dispatchers for testability — don't hardcode Dispatchers.IO

Collections & Data Classes

  • first() throws on empty — use firstOrNull() for safe access
  • Only constructor properties in equals/hashCode — body properties ignored
  • mutableStateListOf for Compose — wrapping mutableListOf in state won't track changes

Scope Functions & Extensions

  • Don't nest scope functions — readability drops fast, extract to named functions
  • Extensions are resolved statically — not polymorphic, receiver type matters at compile time

Android/Compose

  • repeatOnLifecycle(STARTED) for flow collection — launchWhenStarted is deprecated
  • remember survives recomposition only — use rememberSaveable for config changes
  • collectAsStateWithLifecycle is the gold standard — lifecycle-aware + Compose state

Java Interop

  • == is structural equality in Kotlin — === for reference, opposite of Java
  • SAM conversion only for Java interfaces — Kotlin interfaces need explicit fun interface
  • @JvmStatic, @JvmOverloads, @JvmField for Java-friendly APIs

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

baidu-search

Comprehensive search API integration for Baidu Qianfan Web Search. Use when Claude needs to perform web searches using Baidu Qianfan's enterprise search API....

Registry SourceRecently Updated
General

Self Memory Manager

管理 Claude 的记忆和工作流程优化。包括:(1) Context 使用管理 (2) 重要信息存档 (3) 定时总结 (4) 工作文件夹维护 用于:context 超过 80%、重要信息需要记录、每日总结、清理旧 session

Registry SourceRecently Updated
General

Seedance Video

Generate AI videos using ByteDance Seedance. Use when the user wants to: (1) generate videos from text prompts, (2) generate videos from images (first frame,...

Registry SourceRecently Updated