kotlin-patterns

kotlin-patterns is a skill for Claude Code, Codex from userInner/SKILLS. It costs 55 tokens per session (4,714 once invoked), scanned A, a copy of kotlin-patterns, Apache-2.0.

A guide to common Kotlin patterns for readable and maintainable applications. It covers null safety, immutable data, sealed types, coroutines, extension functions, type-safe builders, and Gradle configuration.

In plain words
What is it for?
Use it when writing, reviewing, or refactoring Kotlin code, designing modules, or configuring a Gradle build with Kotlin syntax.
Why use it?
It helps developers avoid inconsistent Kotlin structures and common mistakes around nullable values, state changes, and concurrency.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when writing, reviewing, or refactoring Kotlin code, designing modules, or configuring a Gradle build with Kotlin syntax.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/userinner/skills/kotlin-patterns-affaan-m-ecc
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add userInner/SKILLS --skill kotlin-patterns-affaan-m-ecc
Clone the repo
git clone --depth 1 https://github.com/userInner/SKILLS

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for kotlin-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/userinner/skills/kotlin-patterns-affaan-m-ecc/github.svg)](https://agentmods.dev/skills/userinner/skills/kotlin-patterns-affaan-m-ecc)
Your own site
<a href="https://agentmods.dev/skills/userinner/skills/kotlin-patterns-affaan-m-ecc"><img src="https://agentmods.dev/badge/skills/userinner/skills/kotlin-patterns-affaan-m-ecc/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for kotlin-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/userinner/skills/kotlin-patterns-affaan-m-ecc"><img src="https://agentmods.dev/badge/skills/userinner/skills/kotlin-patterns-affaan-m-ecc.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 55 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,714 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 97% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00055 $0.04714
Opus 5 $0.00028 $0.02357
Sonnet 5 $0.00011 $0.00943
Haiku 4.5 $0.00006 $0.00471

Measured 6d ago against content hash e519234772a3, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

kotlin-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

97% identical to kotlin-patterns — 5 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

community-skills/engineering/kotlin-patterns--affaan-m-ecc/SKILL.md · 713 lines

How it starts

The opening of the file, as written. The whole thing — 713 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Kotlin Development Patterns

Idiomatic Kotlin patterns and best practices for building robust, efficient, and maintainable applications.

When to Use

  • Writing new Kotlin code
  • Reviewing Kotlin code
  • Refactoring existing Kotlin code
  • Designing Kotlin modules or libraries
  • Configuring Gradle Kotlin DSL builds

How It Works

This skill enforces idiomatic Kotlin conventions across seven key areas: null safety using the type system and safe-call operators, immutability via val and copy() on data classes, sealed classes and interfaces for exhaustive type hierarchies, structured concurrency with coroutines and Flow, extension functions for adding behaviour without inheritance, type-safe DSL builders using @DslMarker and lambda receivers, and Gradle Kotlin DSL for build configuration.

Examples

Null safety with Elvis operator:

fun getUserEmail(userId: String): String {
    val user = userRepository.findById(userId)
    return user?.email ?: "[email protected]"
}

Sealed class for exhaustive results:

sealed class Result<out T> {
    data class Success<T>(val data: T) : Result<T>()
    data class Failure(val error: AppError) : Result<Nothing>()
    data object Loading : Result<Nothing>()
}

Structured concurrency with async/await:

suspend fun fetchUserWithPosts(userId: String): UserProfile =
    coroutineScope {
        val user = async { userService.getUser(userId) }
        val posts = async { postService.getUserPosts(userId) }
        UserProfile(user = user.await(), posts = posts.await())
    }

Core Principles

1. Null Safety

Kotlin's type system distinguishes nullable and non-nullable types. Leverage it fully.

// Good: Use non-nullable types by default
fun getUser(id: String): User {
    return userRepository.findById(id)
        ?: throw UserNotFoundException("User $id not found")
}

// Good: Safe calls and Elvis operator
fun getUserEmail(userId: String): String {
    val user = userRepository.findById(userId)
    return user?.email ?: "[email protected]"
}

// Bad: Force-unwrapping nullable types
fun getUserEmail(userId: String): String {
    val user = userRepository.findById(userId)
    return user!!.email // Throws NPE if null
}

Read the full file on GitHub · 713 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 713 lines · 55 tokens per session scan A e519234772a3

Subscribe to this mod's changes

kotlin-patterns is a skill published in the GitHub repository userInner/SKILLS (3 stars, last pushed 2d ago), licensed Apache-2.0. It adds 55 tokens to every session and 4,714 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. It is 97% identical to kotlin-patterns, differing in 5 lines, and is treated as a copy.

Related

Other skills, from other repositories

android-native-dev

Android native application development and UI design guide. Covers Material Design 3, Kotlin/Compose development, project configuration, accessibility, and build troubleshooting. Read this before Android native application development.

bighardperson/computer-science-skills-collection · 41 tokens

kotlin-exposed-patterns

JetBrains Exposed ORM patterns including DSL queries, DAO pattern, transactions, HikariCP connection pooling, Flyway migrations, and repository pattern.

hashgraph-online/awesome-codex-plugins · 36 tokens

kotlin-ktor-patterns

Ktor server patterns including routing DSL, plugins, authentication, Koin DI, kotlinx.serialization, WebSockets, and testApplication testing.

hashgraph-online/awesome-codex-plugins · 34 tokens

null-safety

Use when annotating nullability in Spring Boot 3 / Spring Framework 6 code, integrating Kotlin, or adding static nullability checks without assuming Spring Framework 7 JSpecify defaults.

rrezartprebreza/spring-boot-skills · 41 tokens

swift-ci-scaffold

Scaffold the repo side of Xcode Cloud for an XcodeGen / Tuist Swift project - generate ciscripts/cipostclone.sh (regen + guarded CIBUILDNUMBER stamping), propose a unit-test-only CI scheme, print the exact App Store Connect workflow checklist, and optionally install an opt-in .githooks/pre-push gate. Shows diffs and…

charlesjones-dev/claude-code-plugins-dev · 82 tokens

swift-concurrency-review

Review Swift 6 strict-concurrency and SwiftUI code for idiom and build-breaking issues - non-Sendable across actor boundaries, @MainActor witness vs nonisolated protocol requirements, Combine/ObservableObject usage, force-unwraps, #Predicate macro limits, the 6.3.x Binding IRGen crash, missing #if os() guards, and…

charlesjones-dev/claude-code-plugins-dev · 94 tokens