kotlin-patterns

Enforces idiomatic Kotlin coding patterns and best practices across codebases.

1|Updated Apr 7, 2026
One-click install
npx skills add https://github.com/riftzen-bit/gemini-setup --skill kotlin-patterns-riftzen-bit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-patterns
Source: https://github.com/riftzen-bit/gemini-setup/tree/main/skills/kotlin-patterns
Command: npx skills add https://github.com/riftzen-bit/gemini-setup --skill kotlin-patterns-riftzen-bit

SYSTEM DOCUMENTATION & REQUIREMENTS

## What problem does it solve? This skill codifies idiomatic Kotlin patterns and best practices to reduce bugs, improve readability, and ensure safe, maintainable code across projects by guiding decisions around null safety, immutability, coroutines, and DSLs.

## Core Features & Use Cases

  • Enforces null-safety patterns and safe-call/elvis usage to avoid runtime NPEs.
  • Promotes immutability, data classes, value classes, and copy-based updates for predictable state.
  • Guides structured concurrency with coroutines and Flow, plus DSL and Gradle Kotlin DSL conventions for consistent build and configuration code.
  • Useful during Kotlin code reviews, refactors, library design, and Gradle build configuration improvements.

### Quick Start Use this skill to analyze a Kotlin file and produce a concise refactor plan focused on null-safety, immutability, coroutine structure, and DSL/Gradle improvements.

Frequently Asked Questions about kotlin-patterns

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

FAQPage Schema
How do I enforce Kotlin null-safety patterns to avoid runtime NPEs?

Kotlin null-safety patterns enforce safe-call and elvis operator usage to avoid runtime NPEs. This approach guides refactors to replace unsafe casts with nullable type handling, ensuring predictable state and reducing crashes across your codebase.

What's the best way to structure Kotlin coroutines and Flow for concurrency?

Structured concurrency with Kotlin coroutines and Flow organizes asynchronous tasks using structured scopes. This pattern prevents memory leaks and ensures background jobs are properly cancelled when their parent scope completes.

How do I refactor Kotlin code to use data classes and immutability?

Refactoring Kotlin code for immutability uses data classes and value classes with copy-based updates for predictable state. This approach replaces mutable variables with read-only properties, ensuring safer concurrent access.

Can I use Kotlin DSL conventions for Gradle build configuration?

Kotlin DSL conventions apply directly to Gradle build configuration for consistent type-safe scripting. This approach replaces Groovy scripts with strongly typed Kotlin code, enabling better IDE auto-completion.

How do I design a Kotlin DSL builder for library design?

Designing a Kotlin DSL builder uses extension functions and receiver types to create fluent, readable APIs. This pattern is useful during library design, allowing consumers to configure complex object hierarchies concisely.

Does this Kotlin best practices approach work for server and client applications?

Idiomatic Kotlin best practices apply to both server and client applications, satisfying requirements for null-safety and structured concurrency. This versatility ensures safe, maintainable code across diverse Kotlin development workflows.