kotlin-fundamentals

majiayu000's avatarfrom majiayu000

Kotlin language fundamentals - syntax, null safety, data classes, extensions

5stars🔀1forks📁View on GitHub🕐Updated Jan 11, 2026

When & Why to Use This Skill

This Claude skill provides a comprehensive guide to Kotlin programming fundamentals, enabling developers to master essential syntax, null safety, and idiomatic patterns. It offers production-ready code examples and troubleshooting strategies to accelerate the learning curve for Android and JVM development, ensuring best practices in modern software engineering.

Use Cases

  • Mastering Null Safety: Learn to effectively use safe calls, the Elvis operator, and validation patterns to eliminate NullPointerExceptions in production code.
  • Implementing Robust Data Models: Quickly generate and understand Kotlin data classes with custom validation logic to reduce boilerplate and improve code maintainability.
  • Optimizing Code with Scope Functions: Determine the best use cases for 'let', 'apply', 'run', and 'also' to write cleaner, more idiomatic Kotlin transformations.
  • Debugging Type Systems: Resolve common issues related to smart casts and platform types when interoperating between Kotlin and Java.
namekotlin-fundamentals
descriptionKotlin language fundamentals - syntax, null safety, data classes, extensions
version"1.0.0"
sasmp_version"1.3.0"
bonded_agent01-kotlin-fundamentals
bond_typePRIMARY_BOND
timeout_ms30000
max_attempts3
backoffexponential
initial_delay_ms1000
- namekotlin_version
typestring
validation"^(syntax|null_safety|data_classes|extensions|collections|idioms)$"
default"2.0"
levelinfo
events[skill_invoked, topic_loaded, error_occurred]

Kotlin Fundamentals Skill

Master Kotlin programming fundamentals with production-ready patterns.

Topics Covered

Null Safety

// Safe call + Elvis
val name = user?.name ?: "Anonymous"

// requireNotNull for validation
requireNotNull(user) { "User required" }

Data Classes

data class User(val id: Long, val name: String) {
    init { require(name.isNotBlank()) }
}

Scope Functions

Function Context Returns Use Case
let it Lambda result Null-safe transforms
apply this Same object Object configuration
run this Lambda result Object scope + result
also it Same object Side effects

Troubleshooting

Issue Resolution
NPE despite null check Check platform types from Java
Smart cast fails Use local variable or let

Usage

Skill("kotlin-fundamentals")