Complete AI TrainingYourJobSkills for your job

Skills / super-code

kotlin

Language-specific super-code guidelines for kotlin.

Kotlin + Compose: Idiomatic Efficiency Reference

When to Use

  • Use this skill when the task matches this description: Language-specific super-code guidelines for kotlin.

Table of Contents

  1. [Collections & Data Transformation](#collections)
  2. [Null Safety](#null-safety)
  3. [Functions & Lambdas](#functions)
  4. [Classes & Objects](#classes)
  5. [Coroutines & Flow](#coroutines)
  6. [Compose UI](#compose)
  7. [Anti-patterns specific to Kotlin](#antipatterns)

1. Collections & Data Transformation {#collections}

Prefer scope functions and stdlib transforms over imperative loops.

// ❌ Verbose
val result = mutableListOf<String>()
for (item in items) {
    if (item.isActive) {
        result.add(item.name.uppercase())
    }
}

// ✅ Idiomatic
val result = items.filter { it.isActive }.map { it.name.uppercase() }
// ❌ Manual grouping
val map = mutableMapOf<String, MutableList<Item>>()
for (item in items) {
    map.getOrPut(item.category) { mutableListOf() }.add(item)
}

// ✅
val map = items.groupBy { it.category }
// ❌ Manual fold
var total = 0
for (order in orders) total += order.amount

// ✅
val total = orders.sumOf { it.amount }

Use associate, associateBy, partition, flatMap, zip instead of manual equivalents.


2. Null Safety {#null-safety}

// ❌ Unnecessary null check when Elvis suffices

Subscribers only

The full skill, its 1 bundled files and every download is included with every paid Complete AI plan.

Details

Sourcecommunity
License
Risk labelsafe ("critical" means the skill may run commands or touch files — read before use)
FilesSKILL.md
Added2026-06-16

Related skills

bash

Language-specific super-code guidelines for bash.

c

Language-specific super-code guidelines for c.

cpp

Language-specific super-code guidelines for cpp.

csharp

Language-specific super-code guidelines for csharp.

dart

Language-specific super-code guidelines for dart.

elixir

Language-specific super-code guidelines for elixir.