Agent Skillschrisbanes/skills › kotlin-api-design

kotlin-api-design

GitHub

提供Kotlin API设计指导,涵盖函数归属、值类、数据类及多平台边界设计。用于规范代码结构,确保领域语义清晰,优化跨平台交互与类型安全。

skills/kotlin-api-design/SKILL.md chrisbanes/skills

触发场景

设计或审查Kotlin函数归属 处理单字段领域类型或值类 定义Kotlin Multiplatform expect/actual声明 审查密封结果映射

安装

npx skills add chrisbanes/skills --skill kotlin-api-design -g -y
更多选项

不安装直接使用

npx skills use chrisbanes/skills@kotlin-api-design

指定 Agent (Claude Code)

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

安装 repo 全部 skill

npx skills add chrisbanes/skills --all -g -y

预览 repo 内 skill

npx skills add chrisbanes/skills --list

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

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

版本历史

  • 2026.8.24 当前 2026-08-27 17:15

    简化指令冗长度;增强评估覆盖度及Gradle工作流证据处理。

  • 2026.8.5 2026-08-16 02:44

同 Skill 集合

skills/compose-animations/SKILL.md
skills/compose-component-design/SKILL.md
skills/compose-focus-navigation/SKILL.md
skills/compose-modifier-and-layout-style/SKILL.md
skills/compose-performance/SKILL.md
skills/compose-recomposition-performance/SKILL.md
skills/compose-side-effects/SKILL.md
skills/compose-slot-api-pattern/SKILL.md
skills/compose-stability-diagnostics/SKILL.md
skills/compose-state-and-effects/SKILL.md
skills/compose-state-authoring/SKILL.md
skills/compose-state-deferred-reads/SKILL.md
skills/compose-state-hoisting/SKILL.md
skills/compose-state-holder-ui-split/SKILL.md
skills/compose-ui-testing-patterns/SKILL.md
skills/gradle-run/SKILL.md
skills/grounded-writing/SKILL.md
skills/implement-issue/SKILL.md
skills/implement-with-subagents/SKILL.md
skills/kotlin-concurrency-and-flow/SKILL.md
skills/kotlin-control-flow/SKILL.md
skills/kotlin-coroutines-structured-concurrency/SKILL.md
skills/kotlin-flow-state-event-modeling/SKILL.md
skills/kotlin-functions/SKILL.md
skills/kotlin-multiplatform-expect-actual/SKILL.md
skills/kotlin-types-value-class/SKILL.md
skills/run-github-project/SKILL.md
skills/shepherd/SKILL.md
skills/to-plan/SKILL.md
skills/using-chrisbanes-skills/SKILL.md

元信息

文件数
0
版本
2026.8.27
Hash
49bc11f0
收录时间
2026-08-16 02:44

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-30 16:43
浙ICP备14020137号-1 $访客地图$