Skip to content
Back to skills

Kotlin

ASecurity

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

  • 14 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 7, 2026
developmentgojavakotlinapi

Works with

  • api

Security analysis

A100/100

Pro scans all 8 files and shows the line behind each finding

Scanned September 7, 2026

npx -y skills add modbender/skill-library-mcp --skill kotlin --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Kotlin?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Kotlin
[![Security: A β€” Skills Directory](https://www.skillsdirectory.com/api/skills/modbender-kotlin/badge)](https://www.skillsdirectory.com/skills/modbender-kotlin)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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
- 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

Files in this skill

  • SKILL.md2.4 KB
  • advanced.md1.9 KB
  • android.md1.6 KB
  • collections.md856 B
  • coroutines.md2 KB
  • idioms.md1.1 KB
  • interop.md866 B
  • nullsafety.md642 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…