Agent skill · software engineering · affaan-m
android-clean-architecture
适用于Android和Kotlin多平台项目的Clean Architecture模式——模块结构、依赖规则、用例、仓库以及数据层模式。
Why this skill is useful
Provides specific architectural patterns and implementation details for Clean Architecture in Android/Kotlin that the AI wouldn't reliably generate on its own.
What it needs
Requires hilt, koin, kotlin, ktor, room, sqldelight installed locally. About 3k tokens when loaded. Last updated 2026-08-06. 238,342 stars on the source repository.
What this skill does
Android 整洁架构 适用于 Android 和 KMP 项目的整洁架构模式。涵盖模块边界、依赖反转、UseCase/Repository 模式,以及使用 Room、SQLDelight 和 Ktor 的数据层设计。 何时启用 构建 Android 或 KMP 项目模块结构 实现 UseCases、Repositories 或 DataSources 设计各层(领域层、数据层、表示层)之间的数据流 使用 Koin 或 Hilt 设置依赖注入 在分层架构中使用 Room、SQLDelight 或 Ktor 模块结构 推荐布局 依赖规则 关键:domain 绝不能依赖 data、presentation 或任何框架。它仅包含纯 Kotlin 代码。 领域层 UseCase 模式 每个 UseCase 代表一个业务操作。使用 operator fun invoke 以获得简洁的调用点: 领域模型 领域模型是普通的 Kotlin 数据类——没有框架注解: 仓库接口 在领域层定义,在数据层实现: 数据层 仓库实现 协调本地和远程数据源: 映射器模式 将映射器作为扩展函数放在数据模型附近: Room 数据库 (Android) SQLDelight (KMP) Ktor 网络客户端 (KMP) 依赖注入 Koin (适用于 KMP) Hilt (仅限 Android) 错误处理 Result/Try 模式 使用 Result<T> 或自定义密封类型进行错误传播: 约定插件 (Gradle) 对于 KMP 项目,使用约定插件以减少构建文件重复: 在模块中应用: 应避免的反模式 在 domain 中导入 Android 框架类——保持其为纯 Kotlin 向 UI 层暴露数据库实体或 DTO——始终映射到领域模型 将业务逻辑放在 ViewModels 中——提取到 UseCases 使用 GlobalScope 或非结构化协程——使用 viewModelScope 或结构化并发 臃肿的仓库实现——拆分为专注的 DataSources 循环模块依赖——如果 A 依赖 B,则 B 绝不能依赖 A 参考 查看技能:compose-multiplatform-patterns 了解 UI 模式。 查看技能:kotlin-coroutines-flows 了解异步模式。
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills affaan-m/android-clean-architecture--3a9a63