android-kotlin-core

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Android Kotlin Core

Android Kotlin Core

When To Use

适用场景

  • Use this skill when the request is about: kotlin cleanup in android app, convert verbose android java-style kotlin, sealed classes for ui state.
  • Primary outcome: Use Kotlin idioms safely in Android apps, including nullability, data classes, sealed types, extension functions, and collection pipelines.
  • Handoff skills when the scope expands:
  • android-state-management
  • android-testing-unit
  • 当请求涉及以下内容时使用该技能:Android应用中的Kotlin代码清理、转换冗长的Android Java风格Kotlin代码、为UI状态实现密封类。
  • 核心目标:在Android应用中安全使用Kotlin惯用写法,包括空安全、数据类、密封类型、扩展函数和集合流水线。
  • 范围扩大时需要移交的技能:
  • android-state-management
  • android-testing-unit

Workflow

工作流程

  1. Map the request to the current Android stack, module boundaries, and minimum supported API level.
  2. Inspect the existing implementation for implicit assumptions, duplicate helpers, and outdated patterns.
  3. Apply the smallest change that improves correctness, readability, and long-term maintainability.
  4. Validate the result against the relevant showcase app path and repo benchmarks.
  5. Hand off adjacent work to the next specialized skill only after the core foundation is stable.
  1. 将请求与当前Android技术栈、模块边界和最低支持API级别做匹配。
  2. 检查现有实现中的隐含假设、重复辅助工具和过时模式。
  3. 应用能提升正确性、可读性和长期可维护性的最小变更。
  4. 对照相关示例应用路径和仓库基准验证结果。
  5. 仅在核心基础稳定后,将相邻工作移交给下一个专用技能。

Guardrails

防护规则

  • Prefer official Android and Kotlin guidance over custom local conventions when they conflict.
  • Keep public APIs boring and explicit; avoid clever abstractions that hide Android lifecycle costs.
  • Do not mix architectural cleanup with product behavior changes unless the request explicitly needs both.
  • Document any compatibility constraints that will affect old modules or generated code.
  • 当官方Android和Kotlin指南与本地自定义规范冲突时,优先遵循官方指南。
  • 保持公共API平实明确;避免使用会掩盖Android生命周期成本的精巧抽象。
  • 不要将架构清理与产品行为变更混合处理,除非请求明确要求同时处理二者。
  • 记录所有会影响旧模块或生成代码的兼容性约束。

Anti-Patterns

反模式

  • Sprinkling helpers across modules without a clear ownership boundary.
  • Introducing framework-specific code into pure domain or data layers.
  • Refactoring every adjacent file when only one contract needed to change.
  • Leaving migration notes implied instead of writing them down.
  • 在各模块中随意散布辅助工具,没有明确的所有权边界。
  • 将框架特定代码引入纯领域层或数据层。
  • 仅需修改一个契约时就重构所有相邻文件。
  • 仅隐含迁移说明而不做书面记录。

Examples

示例

Happy path

正常场景

  • Scenario: Tighten domain and UI state models with sealed interfaces and immutable data.
  • Command:
    cd examples/orbittasks-compose && ./gradlew :app:testDebugUnitTest
  • 场景:使用密封接口和不可变数据收紧领域与UI状态模型。
  • 命令:
    cd examples/orbittasks-compose && ./gradlew :app:testDebugUnitTest

Edge case

边缘场景

  • Scenario: Guard nullable platform values crossing the XML activity boundary.
  • Command:
    cd examples/orbittasks-xml && ./gradlew :app:testDebugUnitTest
  • 场景:防护跨XML activity边界的可空平台值。
  • 命令:
    cd examples/orbittasks-xml && ./gradlew :app:testDebugUnitTest

Failure recovery

故障恢复

  • Scenario: Refactor broad helper objects into focused extensions without breaking call sites.
  • Command:
    python3 scripts/eval_triggers.py --skill android-kotlin-core
  • 场景:将宽泛的辅助对象重构为聚焦的扩展函数,同时不破坏调用点。
  • 命令:
    python3 scripts/eval_triggers.py --skill android-kotlin-core

Done Checklist

完成检查清单

  • The implementation path is explicit, minimal, and tied to the right Android surface.
  • Relevant example commands and benchmark prompts have been exercised or updated.
  • Handoffs to adjacent skills are documented when the request crosses boundaries.
  • Official references cover the chosen pattern and the main migration or troubleshooting path.
  • 实现路径明确、改动最小,且适配对应的Android表层。
  • 相关示例命令和基准提示已运行验证或更新。
  • 当请求跨边界时,已记录向相邻技能的移交说明。
  • 所选模式及主要迁移或故障排查路径有官方参考依据。

Official References

官方参考