# kotlin-best-practices

A skill that pins down Kotlin conventions: null safety, Either instead of thrown exceptions, coroutines, and Exposed ORM patterns. Useful while writing or reviewing Kotlin.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · ★ 109
- Author: c0x12c
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/c0x12c/ai-toolkit/tree/HEAD/toolkit/skills/kotlin-best-practices/SKILL.md
- Updated: 2026-06-18
- HTML: https://affpapa.org/en/nevibecode/skills/kotlin-best-practices

## What it does

The skill spells out how Kotlin should look in a project. `!!` is out; use `?.`, `?:`, or a null check that lets the compiler smart cast. Managers hand back `Either<ClientException, T>` rather than throwing, and controllers pull the value out with `.throwOrValue()`. Enum values are never written as raw strings — call `EnumName.VALUE.value`.

Database work follows the same tone. Tables extend `UUIDTable`, not `Table`, and columns use `text()` instead of `varchar()`. Deletes are soft: update the `deletedAt` timestamp, and every query carries a `deletedAt.isNull()` filter. Reads hit `db.replica`, writes go to `db.primary`. When a change touches more than one table, it belongs in a single transaction block so everything commits or nothing does.

DTOs keep their own conversion: `companion object { fun from(entity) }` sits inside the Response DTO, and separate mapper files are not created. Each section points to `code-patterns.md` for the full examples, though that file is not part of the skill — you get the short rules only. The skill runs with `Read`, `Write`, `Edit`, `Glob`, and `Grep`.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add c0x12c/ai-toolkit --skill kotlin-best-practices -a claude-code
```

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

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add c0x12c/ai-toolkit --skill kotlin-best-practices -a codex
```

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

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add c0x12c/ai-toolkit --skill kotlin-best-practices -a cursor
```

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

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install c0x12c/ai-toolkit kotlin-best-practices
```

2. **Manually: put the files in place**
- File: `.github/skills/kotlin-best-practices/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add c0x12c/ai-toolkit --skill kotlin-best-practices -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/c0x12c/ai-toolkit --path toolkit/skills/kotlin-best-practices
```

### Windsurf (Devin Desktop)

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

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add c0x12c/ai-toolkit --skill kotlin-best-practices -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/c0x12c/ai-toolkit/tree/HEAD/toolkit/skills/kotlin-best-practices/SKILL.md

## When to use it
- write Kotlin without `!!` or thrown exceptions
- unwrap `Either` in a controller with `.throwOrValue()`
- soft delete rows instead of removing them
- split reads and writes across `db.replica` and `db.primary`
- keep entity conversion inside the Response DTO, not a mapper file

## Example prompts
- Write this Kotlin repository following the skill: a `UUIDTable`, with `deletedAt.isNull()` in every query
- Review this manager — it should return `Either` instead of throwing
- Add an update that writes to two tables in one transaction via `db.primary`

## Similar
- [migrate-to-shoehorn](https://affpapa.org/en/nevibecode/skills/migrate-to-shoehorn.md) — skill · 475388 installs
- [write-swift](https://affpapa.org/en/nevibecode/skills/write-swift.md) — skill · 119300 installs
- [megacave](https://affpapa.org/en/nevibecode/skills/megacave.md) — skill · 25400 installs
- [find-docs](https://affpapa.org/en/nevibecode/skills/find-docs.md) — skill · 9400 installs
- [typescript-advanced-types](https://affpapa.org/en/nevibecode/skills/typescript-advanced-types.md) — skill · 92169 installs
- [smart-explore](https://affpapa.org/en/nevibecode/skills/smart-explore.md) — skill · 7300 installs

From the same set: [c0x12c/ai-toolkit](https://affpapa.org/en/nevibecode/by/c0x12c/ai-toolkit.md) — 11 cards

---
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
