kotlin
Kotlin programming for Android, coroutines, and JVM development. Use for .kt files.
Best use case
kotlin is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Kotlin programming for Android, coroutines, and JVM development. Use for .kt files.
Teams using kotlin should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/kotlin/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How kotlin Compares
| Feature / Agent | kotlin | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Kotlin programming for Android, coroutines, and JVM development. Use for .kt files.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Kotlin
Modern Kotlin development with coroutines, null safety, and idiomatic patterns.
## When to Use
- Working with `.kt` files
- Android app development
- JVM backend with Spring Boot/Ktor
- Multiplatform projects (KMP)
## Quick Start
```kotlin
data class User(
val id: String,
val name: String,
val email: String,
val createdAt: Instant = Clock.System.now()
)
suspend fun fetchUser(id: String): User? {
return apiService.getUser(id)
}
```
## Core Concepts
### Null Safety
```kotlin
// Nullable types
val name: String? = null
// Safe calls
val length = name?.length
// Elvis operator
val len = name?.length ?: 0
// Smart casts
if (name != null) {
println(name.length) // Smart cast to String
}
// Not-null assertion (use sparingly)
val len = name!!.length
```
### Data Classes & Sealed Classes
```kotlin
data class User(
val id: String,
val name: String,
val email: String
)
sealed class Result<out T> {
data class Success<T>(val data: T) : Result<T>()
data class Error(val message: String) : Result<Nothing>()
object Loading : Result<Nothing>()
}
// Exhaustive when
fun handleResult(result: Result<User>) = when (result) {
is Result.Success -> println(result.data)
is Result.Error -> println(result.message)
Result.Loading -> println("Loading...")
}
```
## Common Patterns
### Coroutines
```kotlin
// Suspend function
suspend fun fetchData(): List<Item> {
return withContext(Dispatchers.IO) {
api.fetchItems()
}
}
// Parallel execution
suspend fun loadDashboard(): Dashboard {
return coroutineScope {
val user = async { fetchUser() }
val orders = async { fetchOrders() }
Dashboard(user.await(), orders.await())
}
}
// Flow for streams
fun observeUsers(): Flow<List<User>> = flow {
while (true) {
emit(fetchUsers())
delay(5000)
}
}.flowOn(Dispatchers.IO)
```
### Extension Functions
```kotlin
fun String.isValidEmail(): Boolean {
return Regex("^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}\$").matches(this)
}
fun <T> List<T>.secondOrNull(): T? = getOrNull(1)
inline fun <T> Result<T>.onSuccess(action: (T) -> Unit): Result<T> {
if (this is Result.Success) action(data)
return this
}
```
## Best Practices
**Do**:
- Use data classes for DTOs
- Prefer immutability (`val` over `var`)
- Use sealed classes for state
- Use coroutines for async work
**Don't**:
- Use `!!` without null check
- Create utility classes (use extensions)
- Block main thread with `runBlocking`
- Ignore cancellation in coroutines
## Troubleshooting
| Error | Cause | Solution |
| ----------------------- | -------------------- | ------------------------- |
| `NullPointerException` | Force unwrap on null | Use safe call `?.` |
| `CancellationException` | Coroutine cancelled | Handle or propagate |
| `IllegalStateException` | Invalid state access | Check state before access |
## References
- [Kotlin Official Docs](https://kotlinlang.org/docs/)
- [Android Kotlin Guides](https://developer.android.com/kotlin)Related Skills
template
Expert [skill-name] assistance covering [feature 1], [feature 2], and [feature 3]. Use when [working with X], [debugging Y], or [implementing Z].
zsh
Zsh shell with oh-my-zsh. Use for terminal shell.
zed
Zed high-performance collaborative editor. Use for fast editing.
xcode
Xcode Apple development IDE with simulators. Use for iOS/macOS development.
webstorm
WebStorm JavaScript IDE with debugging. Use for web development.
webpack
Webpack module bundler with loaders and plugins. Use for bundling.
warp
Warp modern terminal with AI. Use for terminal work.
vscode
Visual Studio Code editor with extensions and debugging. Use for code editing.
vite
Vite fast build tool with HMR. Use for modern frontend builds.
visual-studio
Visual Studio IDE for Windows with debugging and profiling. Use for .NET development.
vim
Vim text editor with motions, macros, and plugins. Use for terminal editing.
turbopack
Turbopack Rust-powered bundler. Use for fast builds.