Agent Skillschrisbanes/skills › kotlin-api-design

kotlin-api-design

GitHub

提供 Kotlin API 设计指导,涵盖函数所有权、值类、多平台边界及重构场景,旨在优化代码结构与领域语义表达。

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

Trigger Scenarios

设计或审查 Kotlin 函数归属与扩展函数 定义单字段领域类型或数据类 处理 Kotlin Multiplatform expect/actual 声明

Install

npx skills add chrisbanes/skills --skill kotlin-api-design -g -y
More Options

Use without installing

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.

Version History

  • 2026.8.5 Current 2026-08-16 02:44

Same Skill Collection

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/implement-issue/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

Metadata

Files
0
Version
2026.8.5
Hash
414a1095
Indexed
2026-08-16 02:44

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-16 21:55
浙ICP备14020137号-1 $mapa de visitantes$