kotlin
Makes your agent write clean and modern Kotlin code. It's excellent for Android development and backend applications.
What it does
This guide teaches how to write more efficient and clear Kotlin code by following best practices. It shows how to use language features to simplify common programming tasks.
When to use it
- ✓When learning to program in Kotlin.
- ✓When reviewing or improving existing Kotlin code.
- ✓When wanting to write more concise and readable code.
Example of what to ask your AI
“How can I make this Kotlin code cleaner using scope functions?”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
The guide compares 'bad' code examples with 'good' examples to illustrate best practices. It focuses on using Kotlin's built-in tools to avoid repetitive or complicated code.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add sickn33/agentic-awesome-skills --skill kotlinOr download just the file:
curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/super-code/kotlin/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
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
- Null Safety
- Functions & Lambdas
- Classes & Objects
- Coroutines & Flow
- Compose UI
- Anti-patterns specific to Kotlin
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
val name: String
if (user?.name != null) {
name = user.name
} else {
name = "Guest"
}
// ✅
val name = user?.name ?: "Guest"
// ❌ Double null check
if (response != null && response.body != null) {
process(response.body!!)
}
// ✅
response?.body?.let { process(it) }
// ❌ !! without guard
val value = nullable!!.doSomething()
// ✅ Make the non-null contract explicit at the boundary
val value = requireNotNull(nullable) { "nullable must be set before calling X" }.doSomething()
// Or return early:
val n = nullable ?: return
3. Functions & Lambdas {#functions}
// ❌ Single-expression function with unnecessary block body
fun double(x: Int): Int {
return x * 2
}
// ✅
fun double(x: Int) = x * 2
// ❌ Lambda capturing unused parameter
items.forEach { item -> doSomething() }
// ✅
items.forEach { doSomething() }
// ❌ Redundant with/apply nesting
val builder = Builder()
builder.setName("x")
builder.setAge(1)
val result = builder.build()
// ✅
val result = Builder().apply {
setName("x")
setAge(1)
}.build()
Prefer let, run, apply, also, with over repeated receiver references — but don't nest more than 2 levels deep.
4. Classes & Objects {#classes}
// ❌ Mutable class for immutable data
class Point {
var x: Int = 0
var y: Int = 0
}
// ✅
data class Point(val x: Int, val y: Int)
// ❌ Companion object just to hold a constant
class Foo {
companion object {
val TAG = "Foo"
}
}
// ✅ — top-level if only used in this file
private const val TAG = "Foo"
class Foo
// ❌ Enum with when that has to be updated in two places
enum class Status { ACTIVE, INACTIVE }
fun label(s: Status) = when(s) { Status.ACTIVE -> "Active"; Status.INACTIVE -> "Inactive" }
// ✅ — put display logic on the enum itself
enum class Status(val label: String) { ACTIVE("Active"), INACTIVE("Inactive") }
Sealed classes/interfaces over enum when variants carry different data.
5. Coroutines & Flow {#coroutines}
// ❌ Unnecessary async/await pair when result is used immediately
val result = async { fetchData() }.await()
// ✅
val result = fetchData() // just suspend fun, no async needed
// ❌ Collecting in a loop
while (true) {
val value = channel.receive()
process(value)
}
// ✅
channel.consumeEach { process(it) }
// or for Flow:
flow.collect { process(it) }
// ❌ StateFlow + manual emit boilerplate
private val _state = MutableStateFlow(initial)
val state: StateFlow<State> = _state
// ... in many places: _state.value = newValue
// ✅ — use update{} for atomic mutation
_state.update { it.copy(field = newValue) }
Don't launch coroutines in constructors or init blocks. Don't use GlobalScope.
6. Compose UI {#compose}
// ❌ Unnecessary remember for derived state that's cheap to compute
val displayName = remember { user.firstName + " " + user.lastName }
…
FAQ
What are 'scope functions'?
These are special Kotlin functions (like `let`, `run`, `apply`) that help execute code blocks on an object, making code more readable.
What is 'Null Safety'?
It's a Kotlin feature that helps prevent common errors caused by variables that should have a value but are empty (null). The guide shows how to handle this safely.
What are 'Coroutines'?
They are a way to handle time-consuming tasks (like fetching data from the internet) without freezing the application. The guide suggests efficient ways to use them.
Details
Original description by the author
Language-specific super-code guidelines for kotlin.
Popularity
- GitHub stars
- 48k
- Ranking position
- #4280
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
00-andruia-consultant
Helps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
sickn33/agentic-awesome-skills
007
Lets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
sickn33/agentic-awesome-skills
10-andruia-skill-smith
Helps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
sickn33/agentic-awesome-skills
20-andruia-niche-intelligence
Lets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
sickn33/agentic-awesome-skills
Similar skills
benchmark-optimization-loop
Has your agent improve something's speed in a measured way. It tests multiple versions and chooses the fastest one that still works correctly.
affaan-m/ECC
change-impact
Helps your agent analyze the impact of code changes before making them. It compares the planned vs. actual results afterward, covering paths, data, tests, and documentation. Useful for risky or system-wide changes.
affaan-m/ECC
click-path-audit
Lets your agent trace all user buttons and interactions to find bugs. It finds issues where functions seem to work alone but fail together. Useful when bugs persist even after debugging.
affaan-m/ECC