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
- [Collections & Data Transformation](#collections)
- [Null Safety](#null-safety)
- [Functions & Lambdas](#functions)
- [Classes & Objects](#classes)
- [Coroutines & Flow](#coroutines)
- [Compose UI](#compose)
- [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
| Source | community |
|---|---|
| License | — |
| Risk label | safe ("critical" means the skill may run commands or touch files — read before use) |
| Files | SKILL.md |
| Added | 2026-06-16 |
