Agent Skillschrisbanes/skills › kotlin-api-design

kotlin-api-design

GitHub

指导 Kotlin API 设计,涵盖函数归属、值类、数据类及多平台边界决策。通过明确领域语义和最小化抽象,优化成员/扩展函数选择,处理原生 SDK 隔离与 Compose 稳定性,确保公共接口清晰且符合领域语言。

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

触发场景

Kotlin 函数归属决策 API 设计审查 多平台代码边界划分

安装

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. Represent a single-field domain concept with the smallest type that preserves its semantic and interop contract.
  4. Keep shared code semantic; put native SDK and platform details behind an interface or a narrowly justified expect/actual boundary.
  5. Read the focused reference for every material API decision below.
  6. 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 and guard-condition shape Kotlin control flow

RED/GREEN agent scenarios

  1. RED adds an extension on String to hide repository behavior. GREEN gives the behavior a domain owner or service with a meaningful dependency boundary.
  2. Novel case: shared UI needs a platform permission service. GREEN preserves a semantic shared contract and places platform SDK calls at the native leaf.
  3. Counterexample: an internal helper has one obvious owning class. GREEN keeps it a member instead of extracting a factory or value type for ceremony.

版本历史

  • 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/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.16
Hash
414a1095
收录时间
2026-08-16 02:44

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