Agent Skills
› chrisbanes/skills
› kotlin-api-design
kotlin-api-design
GitHub指导Kotlin API设计,涵盖函数归属、值类及多平台边界决策。
Trigger Scenarios
设计Kotlin函数归属
审查API结构
定义值类或数据类
处理多平台expect/actual
Install
npx skills add chrisbanes/skills --skill kotlin-api-design -g -y
SKILL.md
Frontmatter
{
"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
- Name the domain concept, its owning type or module, and the callers that need to depend on it.
- Choose function ownership before adding an extension, factory, helper, or service layer.
- When reviewing a public mapping over a sealed result, name every
caller-visible outcome. Flag a catch-all
elsethat hides a subtype and recommend explicit subtype branches so the contract stays exhaustive and preserves smart casts. - Represent a single-field domain concept with the smallest type that preserves its semantic and interop contract.
- Keep shared code semantic; put native SDK and platform details behind an interface or a narrowly justified expect/actual boundary.
- Read the focused reference for the selected decision below.
- 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 |
Primitive obsession, one-field domain type, @JvmInline value class, data class, interop, or Compose stability |
Value classes |
| Source sets, platform services, native SDKs, files, sensors, permissions, Compose Multiplatform interop, or expect/actual | Multiplatform boundaries |
Branching, guard-condition shape, sealed-result mapping, or a catch-all else |
Kotlin control flow |
Version History
-
2026.8.24
Current 2026-08-27 17:15
简化指令冗长度;增强评估覆盖度及Gradle工作流证据处理。
- 2026.8.5 2026-08-16 02:44


