Skip to content
Skills Library
Programming · Building & coding

java-kotlin

/java-kotlin

Use when writing modern Java (17+) or Kotlin on the JVM. Covers records, sealed interfaces, pattern matching, coroutines, null safety, and JVM performance and memory tuning. Trigger on "migrate this off java 8 style", "convert this to kotlin coroutines", "jvm keeps running out of memory", "gc pauses are killing latency". Do not use for Spring wiring, transactions, or JPA — see the spring-boot skill.

Licence
MIT
Last repository change
24.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 24.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Use when writing modern Java (17+) or Kotlin on the JVM. Covers records, sealed interfaces, pattern matching, coroutines, null safety, and JVM performance and memory tuning. Trigger on "migrate this off java 8 style", "convert this to kotlin coroutines", "jvm keeps running out of memory", "gc pauses are killing latency". Do not use for Spring wiring, transactions, or JPA — see the spring-boot skill.

Triggers from the description

migrate this off java 8 styleconvert this to kotlin coroutinesjvm keeps running out of memorygc pauses are killing latency
Original author description

Use when writing modern Java (17+) or Kotlin on the JVM. Covers records, sealed interfaces, pattern matching, coroutines, null safety, and JVM performance and memory tuning. Trigger on "migrate this off java 8 style", "convert this to kotlin coroutines", "jvm keeps running out of memory", "gc pauses are killing latency". Do not use for Spring wiring, transactions, or JPA — see the spring-boot skill.

How it works

  1. Purpose
  2. When to Use
  3. Capabilities
  4. Inputs
  5. Outputs
  6. Workflow
  7. Best Practices
  8. Examples
  9. Notes
Original SKILL.md headings · 87 lines, 525 words
SKILL.md preview
---
name: java-kotlin
description: Use when writing modern Java (17+) or Kotlin on the JVM. Covers records, sealed interfaces, pattern matching, coroutines, null safety, and JVM performance and memory tuning. Trigger on "migrate this off java 8 style", "convert this to kotlin coroutines", "jvm keeps running out of memory", "gc pauses are killing latency". Do not use for Spring wiring, transactions, or JPA — see the spring-boot skill.
metadata:
  category: languages
  version: 1.0.0
  tags: [java, kotlin, jvm, coroutines, records]
---

# Java and Kotlin

## Purpose

Write JVM code that uses the modern language surface — records, sealed types, pattern matching, coroutines — instead of the 2010-era idioms most JVM codebases are still carrying.

## When to Use

- Writing or reviewing Java 17+ or Kotlin.
- Migrating a codebase off Java 8 idioms.
- Designing domain models with records and sealed interfaces.
- Introducing coroutines to replace callback or thread-pool code.
- Diagnosing JVM memory, GC, or startup problems.

## Capabilities

- Java: records, sealed interfaces, pattern matching for `switch`, virtual threads, `Optional` discipline.
- Kotlin: coroutines, structured concurrency, flows, null safety, delegation, DSL builders.
- Java/Kotlin interop, including platform-type null hazards.
- Build configuration for Gradle (Kotlin DSL) and Maven.
- JVM tuning: heap sizing, GC selection, JFR profiling.

## Inputs

- Source module, build file, and target JVM version.
- Whether the code is a library (binary compatibility matters) or an application.

## Outputs

- Modern, immutable-by-default domain types.
- Concurrency that is structured and cancellable.
- Build configuration pinned to a specific toolchain.

## Workflow

1. **Model** — Domain values as records (Java) or data classes (Kotlin). Variants as sealed interfaces.
2. **Match exhaustively** — Use pattern-matching `switch` / `when` so a new variant becomes a compile error.
3. **Structure concurrency** — Virtual threads (Java 21+) or coroutine scopes tied to a lifecycle.
4. **Guard nulls at the interop line** — Every value crossing from Java into Kotlin is a platform type; annotate or validate it.
5. **Gate** — Compile with warnings as errors; run SpotBugs/detekt and the test suite.

## Best Practices

- Never return `null` from a public API. Return `Optional`, an empty collection, or a sealed "absent" variant.
- Records are for data, not for behavior with hidden state. Keep them free of mutable references.
- In Kotlin, `!!` is a defect marker. If you cannot remove it, the type is lying.
- Never launch a coroutine in `GlobalScope`. It has no cancellation owner.
- Prefer `runCatching` only in application boundaries; libraries throw typed exceptions.
- Pin the toolchain in the build file so the JVM version is not an environment variable.

## Examples

**Sealed model with exhaustive matching (Java 21):**

```java
sealed interface Payment permits Card, Transfer, Wallet {}

record Card(String last4, YearMonth expiry) implements Payment {}
record Transfer(String iban) implements Payment {}
record Wallet(String provider, String token) implements Payment {}

static String describe(Payment payment) {
    return switch (payment) {
        case Card c      -> "Card ending %s".formatted(c.last4());
        case Transfer t  -> "Transfer to %s".formatted(t.iban());
        case Wallet w    -> "%s wallet".formatted(w.provider());
    };
}
```

**Structured concurrency in Kotlin:**

```kotlin
suspend fun loadDashboard(userId: String): Dashboard = coroutineScope {
    val profile = async { userService.profile(userId) }
    val orders  = async { orderService.recent(userId, limit = 10) }
    Dashboard(profile.await(), orders.await())
}
```

## Notes

- Virtual threads (Java 21) remove most reasons to use a reactive framework for I/O-bound work. They do not help CPU-bound work.
- `coroutineScope` propagates cancellation to children and rethrows the first failure; `supervisorScope` isolates failures. Choose deliberately.
- Kotlin's `Flow` is cold. Collecting it twice runs the producer twice — a common source of duplicated API calls.

Versions

The database has no other skills named java-kotlin.

Database snapshot: 13.11.2026 · package version fc1952a9e9d8 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 85backend-jvm-language-review
    Use when reviewing Java/Kotlin source for language-idiom concerns — records, sealed types, immutability, var, Optional, exception design, Kotlin null safety, data classes, sealed classes, scope functions, coroutines. Triggers when Java/Kotlin source files are in scope and Spring…
  • 100kotlin
    Kotlin language fundamentals. Covers null safety, coroutines, flow, sealed classes, data classes, scope functions, and Kotlin 2.x features (K2 compiler, context parameters). Use for Kotlin/JVM, Kotlin/Native, Kotlin/JS work. USE WHEN: user mentions "Kotlin", "coroutines",…
  • 100sota-jvm
    State-of-the-art JVM engineering rules for Java and Kotlin that Claude applies when writing or auditing JVM code. Java LTS releases (virtual threads final since 21; structured concurrency still preview), modern Kotlin. Covers modern idioms (records, sealed types, pattern…
  • 90kotlin-patterns
    Idiomatic Kotlin patterns for JVM and Android: null-safety, sealed hierarchies, coroutines and structured concurrency, immutable data modeling, error handling, and Java interop. Use when writing or reviewing `.kt` code, porting Java into Kotlin, designing Android app…
  • 95lang-kotlin
    Use this skill when the user says 'Kotlin', 'coroutines', 'Flow', 'StateFlow', 'suspend function', 'structured concurrency', 'null safety Kotlin', 'data class', 'sealed interface', 'extension function', 'K2 compiler', 'KSP', 'Gradle Kotlin DSL', 'MockK', 'kotlinx.serialization'.…
  • 100kotlin
    Expert Kotlin assistance covering coroutines, Flow, null safety, extension functions, sealed classes/interfaces, and Kotlin Multiplatform. Use when developing Android applications, server-side Kotlin services with Ktor/Spring, or sharing cross-platform business logic.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.