Skip to main content
skill CX Codex

kotlin-api-design — Claude Code skill: where Kotlin code belongs

Walks you through function ownership, value classes and expect/actual boundaries in Kotlin. Useful when shaping a public API or a KMP module.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add chrisbanes/skills --skill kotlin-api-design -a claude-code
Open on GitHub

What kotlin-api-design does

The skill runs API design as a short procedure. You start by naming the domain concept, the type or module that owns it, and the callers that will depend on it. Then you pick the owner of a function — member, top-level, extension, factory or service layer. Reject a candidate and the skill asks you to name the owner callers should use instead.

Types come next. A single-field domain concept gets the smallest type that keeps its meaning and interop contract: @JvmInline value class, a data class, or a plain class. When reviewing a mapping over a sealed result, it wants every caller-visible outcome spelled out and flags a catch-all else that hides a subtype, because explicit branches keep the contract exhaustive and preserve smart casts.

Shared code stays semantic; native SDKs, files, sensors and permissions move behind an interface or a narrow expect/actual boundary. Each topic has its own reference file, and a signal table points to the right one. Branching and guard-condition shape are handed off to the neighbouring kotlin-control-flow skill.

What it helps with

  • decide who owns a function before a stray helper appears
  • swap a primitive for a value class without breaking interop
  • make a sealed-result mapping exhaustive
  • push a native SDK behind an expect/actual boundary
  • drop convenience abstractions with no clear owner from the public API

Example prompts for the agent

  • Review this Kotlin public API: where should each function live and why
  • Check this sealed-result mapping for an else that hides a subtype
  • Should this single-field domain type be a value class instead of a String?

How to install kotlin-api-design

1Skills CLI (Vercel)

npx skills add chrisbanes/skills --skill kotlin-api-design -a claude-code

2Manually: put the files in place

~/.claude/skills/kotlin-api-design/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/kotlin-api-design/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about kotlin-api-design

How do I install kotlin-api-design in Claude?

Run npx skills add chrisbanes/skills --skill kotlin-api-design -a claude-code. The skill lands in ~/.claude/skills/kotlin-api-design/SKILL.md.

What does kotlin-api-design do?

It guides Kotlin API design and review: function ownership, the type for a single-field concept, and platform boundaries. It also checks that sealed-result mappings stay exhaustive.

Which platforms can run it?

Besides Claude, there are installs for Codex, Cursor, GitHub Copilot, Gemini CLI and OpenCode. GitHub Copilot uses a different command: gh skill install chrisbanes/skills kotlin-api-design.

Source text

SKILL.md · Apache-2.0
---
name: kotlin-api-design
description: Use when designing or reviewing Kotlin function ownership, member or extension functions, factories, single-field domain types, value classes, data classes, Kotlin Multiplatform expect/actual declarations, or platform service boundaries.
---

# Kotlin API design

## Core principle

Place behavior, types, and platform seams where their meaning is clearest to
callers; use the smallest public abstraction that preserves domain language and
platform independence.

## Procedure

1. Name the domain concept, its owning type or module, and the callers that
   need to depend on it.
2. Choose function ownership before adding an extension, factory, helper, or
   service layer. When rejecting one, name the owner callers should use instead.
3. When reviewing a public mapping over a sealed result, name every
   caller-visible outcome. Flag a catch-all `else` that hides a subtype and
   recommend explicit subtype branches so the contract stays exhaustive and
   preserves smart casts.
4. Represent a single-field domain concept with the smallest type that preserves
   its semantic and interop contract.
5. Keep shared code semantic; put native SDK and platform details behind an
   interface or a narrowly justified expect/actual boundary.
6. Read the focused reference for the selected decision below.
7. Finish when the public surface states domain intent, platform details remain
   at leaves, and callers do not depend on convenience abstractions with no
   clear owner.

## Topic router

| Signal | Read |
|---|---|
| Member vs top-level, extension, factory, service, or receiver choice | [Function ownership](references/functions.md) |
| Primitive obsession, one-field domain type, `@JvmInline value class`, data class, interop, or Compose stability | [Value classes](references/value-classes.md) |
| Source sets, platform services, native SDKs, files, sensors, permissions, Compose Multiplatform interop, or expect/actual | [Multiplatform boundaries](references/multiplatform-boundaries.md) |
| Branching, guard-condition shape, sealed-result mapping, or a catch-all `else` | [Kotlin control flow](../kotlin-control-flow/SKILL.md) |

© chrisbanes · Apache-2.0 · chrisbanes/skills

Similar skills

All skills for Programming languages →

From the same set18

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor