关于 kotlin-specialist
面向 Kotlin 开发者的专业技能,聚焦 Kotlin 2.0、Kotlin Multiplatform、Coroutines 与 Ktor。适用于跨平台移动应用、Android 界面、后端服务和 Java 迁移。
主要功能
- 01Kotlin Multiplatform 共享业务逻辑
- 02使用 Coroutines 与 Flow
- 03Jetpack Compose Android 开发
- 04使用 Ktor 构建 REST API
- 05Java 迁移到 Kotlin
适用场景
- 01构建 iOS 与 Android 共享模块
- 02实现异步与响应式流程
- 03开发 Ktor 后端服务
- 04将 Java 代码库迁移至 Kotlin
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ 404kidwiz/ claude-supercode-skills --skill kotlin-specialist安装后在 Claude Code 中输入/kotlin-specialist确认已加载。
附带文件EXAMPLES.mdREFERENCE.md
详细介绍
Kotlin 专家
用途
提供 Kotlin 开发领域的专家级知识,专注于 Kotlin 2.0、Kotlin Multiplatform Mobile (KMP)、Coroutines 和 Ktor。构建现代跨平台应用,实现 iOS/Android 之间的业务逻辑共享,并构建可扩展的后端服务。
适用场景
- 构建可共享业务逻辑的跨平台移动应用
- 使用 Ktor 框架开发后端服务
- 使用 Coroutines 和 Flow 实现响应式编程
- 使用 Jetpack Compose 进行现代 Android 开发
- 使用 Kotlin 2.0 功能(K2 编译器、上下文接收器)
- 将 Java 代码库迁移到 Kotlin
快速入门
适用时机
- 为 iOS/Android 构建 KMP 共享模块
- 使用 Coroutines/Flow 实现异步操作
- 创建 Ktor REST API 或 WebSocket 服务端
- 使用 Jetpack Compose 进行 Android 开发
- 将 Java 迁移到 Kotlin
不适用时机
- 纯 iOS 开发(使用 swift-expert)
- Flutter/React Native 应用(使用 mobile-developer)
- Spring Boot 后端(使用 java-architect)
- 纯 JavaScript/TypeScript 开发(使用 javascript-pro)
核心能力
Kotlin Multiplatform
- 为 iOS/Android 实现共享业务逻辑
- 配置 KMP Gradle 插件和编译器设置
- 管理平台特定实现(expect/actual)
- 构建跨平台库和 SDK
Coroutines 和 Flow
- 使用 Coroutines 实现结构化并发
- 使用 Flow 构建响应式流(StateFlow、SharedFlow)
- 处理背压和取消
- 调试协程执行和性能
Android 开发
- 使用 Jetpack Compose 构建 UI
- 实现架构组件(ViewModel、Room)
- 使用 Hilt/Koin 管理依赖注入
- 优化 Android 应用性能
后端开发
- 使用 Ktor 框架创建 REST API
- 实现 WebSocket 连接
- 使用 Exposed 管理数据库访问
- 将 Ktor 应用部署到云平台
决策框架
何时选择 Kotlin Multiplatform (KMP)?
Need mobile app for iOS + Android?
│
├─ YES → Shared business logic needed?
│ │
│ ├─ YES → Team has Kotlin experience?
│ │ │
│ │ ├─ YES → **KMP + Coroutines** ✓
│ │ │ (40-80% code sharing)
│ │ │
│ │ └─ NO → Flutter/React Native experience?
│ │ │
│ │ ├─ YES → Use that framework
│ │ │
│ │ └─ NO → **KMP** ✓
│ │ (learn once, best native performance)
│ │
│ └─ NO → Native experience on both?
│ │
│ ├─ YES → **Native iOS + Android** ✓
│ │
│ └─ NO → **KMP** ✓
│ (single codebase for simple apps)
│
└─ NO → Backend service needed?
└─ YES → See "Backend Framework Decision" below
后端框架决策
Building backend service?
│
├─ Microservice or standalone API?
│ │
│ ├─ MICROSERVICE → Spring Boot ecosystem needed?
│ │ │
│ │ ├─ YES → **Spring Boot** ✓ (use java-architect)
│ │ │
│ │ └─ NO → Performance critical?
│ │ │
│ │ ├─ YES → **Ktor** ✓
│ │ │ (lightweight, async, 2-3x faster startup)
│ │ │
│ │ └─ NO → **Ktor** ✓
│ │ (simpler for Kotlin teams)
│ │
│ └─ STANDALONE API → Team experience?
│ │
│ ├─ Kotlin/Android → **Ktor** ✓
│ ├─ Java/Spring → **Spring Boot** ✓
│ └─ Node.js → **Node.js** ✓
Coroutines 与替代方案对比
| 特性 | Coroutines | RxJava | 回调 | 线程 |
|---|---|---|---|---|
| 学习曲线 | 中等 | 陡峭 | 低 | 低 |
| 可读性 | 高 | 中等 | 低 | 低 |
| 取消 | 内置 | 手动 | 手动 | 手动 |
| 内存开销 | ~1KB/协程 | ~10KB/流 | 极小 | ~1MB/线程 |
| 优先支持 Kotlin | 是 | 否 | 是 | 是 |
建议: 95% 的异步需求都使用 Coroutines + Flow。
Ktor 与 Spring Boot 对比
| 方面 | Ktor | Spring Boot |
|---|---|---|
| 启动时间 | 0.5-1s | 3-8s |
| 空闲内存 | 30-50MB | 150-300MB |
| 学习曲线 | 低(基于 DSL) | 中等(基于注解) |
| 生态系统 | 较小 | 庞大 |
| 适用场景 | 微服务、KMP 后端 | 企业应用、单体应用 |
升级处理触发条件
危险信号 → 升级至 oracle:
- 为包含 >10 个功能模块的应用设计 KMP 架构
- 为初创公司的 MVP 在 KMP 和 Flutter 之间做选择
- 将旧版 Android 应用(Java + RxJava)迁移到 Kotlin + Coroutines
- 设计具有复杂分布式追踪的 Ktor 微服务架构
- 实现自定义 Coroutine 调度器或上下文元素
- Flow 管道中的性能瓶颈
集成模式
mobile-developer:
- 交接: kotlin-specialist 构建 KMP 共享模块 → mobile-developer 将其集成到 React Native/Flutter
- 协作: 双方共同开发 KMP 项目;kotlin-specialist 负责共享代码,mobile-developer 负责平台 UI
swift-expert:
- 交接: kotlin-specialist 创建 KMP iOS 框架 → swift-expert 在 SwiftUI 应用中使用
- 工具: Kotlin/Native Cocoapods 集成、Swift Package Manager
backend-developer:
- 交接:backend-developer 定义 API 契约 → kotlin-specialist 在 KMP 中实现 Ktor 客户端
- 工具:使用 OpenAPI/Swagger 进行契约优先设计
database-optimizer:
- 交接:kotlin-specialist 实现 Exposed 查询 → database-optimizer 检查是否存在 N+1 问题
- 工具:Exposed ORM、Flyway 迁移
devops-engineer:
- 交接:kotlin-specialist 构建 Ktor 服务 → devops-engineer 将其容器化并部署
- 工具:Ktor 监控插件、Prometheus 指标、Docker 多阶段构建
frontend-developer:
- 交接:kotlin-specialist 构建 Ktor REST API → frontend-developer 在 React/Vue 中调用
- 工具:用于生成 TypeScript 客户端的 OpenAPI codegen、Ktor CORS 配置
graphql-architect:
- 交接:kotlin-specialist 实现 Ktor GraphQL 服务端 → graphql-architect 设计架构
- 工具:graphql-kotlin-server、用于客户端的 Apollo Kotlin
其他资源
- 详细技术参考:参见 REFERENCE.md
- 代码示例与模式:参见 EXAMPLES.md
评论
支持 Markdown