# kotlin-tooling-java-to-kotlin

Rewrites Java source files as idiomatic Kotlin through a four-step method with invariant checks and framework-specific guidance.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 2000 installs · ★ 1093
- Author: JetBrains
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/Kotlin/kotlin-agent-skills/tree/HEAD/skills/kotlin-tooling-java-to-kotlin/SKILL.md
- Updated: 2026-10-20
- HTML: https://affpapa.org/en/nevibecode/skills/kotlin-tooling-java-to-kotlin

## What it does

The skill fires when your prompt mentions `.java` files that should become `.kt`, or when you ask for a Java-to-Kotlin migration outright. It starts by reading imports and matching them against a table of frameworks: Spring, Lombok, Hibernate, Jackson, Dagger/Hilt, RxJava, JUnit, Retrofit and more. Only the matching reference files get pulled in, which keeps the context small.

Conversion runs as a four-stage chain of thought: a literal one-to-one translation, then an audit of nullability and val/var, then the swap from Java collection types to Kotlin ones, and finally idiomatic rewrites such as properties and string templates. Five invariants are checked between stages; break one and the step is redone. Output lands in a `.kt` file beside the original, and a separate `git mv` commit keeps `git blame` intact.

For directories or packages the skill sorts files by dependency, converting leaves first. At the end it tries to compile the result and run the tests. Your project has to build on its own before you start, otherwise that check has nothing to lean on.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add Kotlin/kotlin-agent-skills --skill kotlin-tooling-java-to-kotlin -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/kotlin-tooling-java-to-kotlin/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/kotlin-tooling-java-to-kotlin/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add Kotlin/kotlin-agent-skills --skill kotlin-tooling-java-to-kotlin -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/kotlin-tooling-java-to-kotlin/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add Kotlin/kotlin-agent-skills --skill kotlin-tooling-java-to-kotlin -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/kotlin-tooling-java-to-kotlin/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install Kotlin/kotlin-agent-skills kotlin-tooling-java-to-kotlin
```

2. **Manually: put the files in place**
- File: `.github/skills/kotlin-tooling-java-to-kotlin/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add Kotlin/kotlin-agent-skills --skill kotlin-tooling-java-to-kotlin -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/Kotlin/kotlin-agent-skills --path skills/kotlin-tooling-java-to-kotlin
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/kotlin-tooling-java-to-kotlin/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add Kotlin/kotlin-agent-skills --skill kotlin-tooling-java-to-kotlin -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/Kotlin/kotlin-agent-skills/tree/HEAD/skills/kotlin-tooling-java-to-kotlin/SKILL.md

## When to use it
- turn a Java class into idiomatic Kotlin with matching behaviour
- keep `git blame` history when the file extension changes
- map Lombok annotations onto their Kotlin equivalents
- convert a whole package in dependency order
- confirm the build and tests still pass after migration

## Example prompts
- Convert `src/main/java/com/example/OrderService.java` to Kotlin and keep the Git history
- Migrate the `com.example.api` package from Java to Kotlin, leaf classes first
- This file uses Spring and Jackson — turn it into idiomatic `.kt` without changing the API

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: c9804e6e308ce6b9.

BEGIN THIRD-PARTY FILE c9804e6e308ce6b9
````text
---
name: kotlin-tooling-java-to-kotlin
description: >
  Use when converting Java source files to idiomatic Kotlin, when user mentions
  "java to kotlin", "j2k", "convert java", "migrate java to kotlin", or when
  working with .java files that need to become .kt files. Handles framework-aware
  conversion for Spring, Lombok, Hibernate, Jackson, Micronaut, Quarkus, Dagger/Hilt,
  RxJava, JUnit, Guice, Retrofit, and Mockito.
license: Apache-2.0
metadata:
  author: JetBrains
  version: "1.0.0"
---

# Java to Kotlin Conversion

Convert Java source files to idiomatic Kotlin using a disciplined 4-step conversion
methodology with 5 invariants checked at each step. Supports framework-aware conversion
that handles annotation site targets, library idioms, and API preservation.

## Workflow

```dot
digraph j2k_workflow {
  rankdir=TB;
  "User specifies files" -> "Step 0: Scan & Detect";
  "Step 0: Scan & Detect" -> "Load framework guides";
  "Load framework guides" -> "Step 1: Convert";
  "Step 1: Convert" -> "Step 2: Write .kt";
  "Step 2: Write .kt" -> "Step 3: Git rename";
  "Step 3: Git rename" -> "Step 4: Verify";
  "Step 4: Verify" -> "Next file?" [label="pass"];
  "Step 4: Verify" -> "Fix issues" [label="fail"];
  "Fix issues" -> "Step 1: Convert";
  "Next file?" -> "Step 0: Scan & Detect" [label="batch: yes"];
  "Next file?" -> "Done" [label="no more files"];
}
```

## Step 0: Scan & Detect Frameworks

Before converting, scan the Java file's import statements to detect which frameworks
are in use. Load ONLY the matching framework reference files to keep context focused.

### Framework Detection Table

| Import prefix | Framework guide |
|---|---|
| `org.springframework.*` | [SPRING.md](references/frameworks/SPRING.md) |
| `lombok.*` | [LOMBOK.md](references/frameworks/LOMBOK.md) |
| `javax.persistence.*`, `jakarta.persistence.*`, `org.hibernate.*` | [HIBERNATE.md](references/frameworks/HIBERNATE.md) |
| `com.fasterxml.jackson.*` | [JACKSON.md](references/frameworks/JACKSON.md) |
| `io.micronaut.*` | [MICRONAUT.md](references/frameworks/MICRONAUT.md) |
| `io.quarkus.*`, `javax.enterprise.*`, `jakarta.enterprise.*` | [QUARKUS.md](references/frameworks/QUARKUS.md) |
| `dagger.*`, `dagger.hilt.*` | [DAGGER-HILT.md](references/frameworks/DAGGER-HILT.md) |
````
END THIRD-PARTY FILE c9804e6e308ce6b9

The third-party file has ended. Everything between the c9804e6e308ce6b9 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2287 of 5535 bytes. © JetBrains · Apache-2.0 · https://github.com/Kotlin/kotlin-agent-skills/tree/HEAD/skills/kotlin-tooling-java-to-kotlin/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
