kotlin-patterns

Enforce idiomatic Kotlin patterns for null-safety, immutability, and coroutines.

1|Updated Mar 18, 2026
One-click install
npx skills add https://github.com/xxih/ai-harness-zh --skill kotlin-patterns-xxih
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-patterns
Source: https://github.com/xxih/ai-harness-zh/tree/main/references/translations/everything-claude-code/docs/zh-CN/skills/kotlin-patterns
Command: npx skills add https://github.com/xxih/ai-harness-zh --skill kotlin-patterns-xxih

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Enforces idiomatic Kotlin conventions and practical best practices to reduce bugs, improve readability, and make Kotlin codebases more maintainable and consistent.

Core Features & Use Cases

  • Guidance on null-safety and safe access patterns to avoid runtime null errors.
  • Recommendations for immutability, data classes, sealed hierarchies, and value wrappers to model domain data correctly.
  • Patterns for structured concurrency with coroutines and Flow, extension functions, delegates, and building type-safe DSLs, plus advice for Gradle Kotlin DSL configuration and project setup.
  • Use case: review or refactor a Kotlin module to remove unsafe null handling, replace mutable state with immutable patterns, and apply structured concurrency for asynchronous operations.

Quick Start

Ask the assistant to review a Kotlin file for null-safety, immutability, coroutine usage, and DSL or Gradle Kotlin DSL best practices and provide prioritized refactor suggestions.

Frequently Asked Questions about kotlin-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor Kotlin code to fix unsafe null handling and improve immutability?

Refactor Kotlin code by applying safe access patterns, replacing mutable state with immutable data classes, and using sealed hierarchies to model domain data correctly and avoid runtime null errors.

What is the best way to implement structured concurrency with Kotlin coroutines and Flow?

Structured concurrency with Kotlin coroutines and Flow is implemented by applying specific patterns for asynchronous operations, ensuring coroutines are scoped properly to prevent leaks and manage lifecycle correctly.

How do I build type-safe DSLs in Kotlin using DSL markers and extension functions?

Build type-safe DSLs in Kotlin by utilizing DSL markers to prevent scope leakage, combining extension functions and delegates to create fluent, structured configuration interfaces that enforce compile-time safety.

Can I use Kotlin sealed classes and value wrappers to model domain data correctly?

Use Kotlin sealed classes and value wrappers to model domain data correctly by representing restricted hierarchies, enforcing immutability, and ensuring exhaustive when-expressions compile-time safety.

Does Gradle Kotlin DSL configuration require specific idiomatic patterns for project setup?

Gradle Kotlin DSL configuration requires idiomatic patterns to standardize project setup, leveraging Kotlin's type-safety and extension functions to create maintainable, programmable build scripts.

Why should I use Kotlin delegates and extension functions during a module refactor?

Use Kotlin delegates and extension functions during module refactoring to standardize code patterns, reduce boilerplate, and add behavior to existing classes without inheritance, improving maintainability and readability.