kotlin-functions

Guides selection of Kotlin member, top-level, extension, factory, or service functions by semantic ownership.

1|Updated Jul 6, 2026
One-click install
npx skills add https://github.com/citytexi/team-yg-pesonal-agent --skill kotlin-functions-citytexi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: kotlin-functions
Source: https://github.com/citytexi/team-yg-pesonal-agent/tree/main/.claude/skills/kotlin-functions
Command: npx skills add https://github.com/citytexi/team-yg-pesonal-agent --skill kotlin-functions-citytexi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Kotlin codebases often accumulate misleading extension functions on String, primitives, collections, Flow, or third-party types, creating false ownership, domain pollution, and import collisions. This Skill provides a decision procedure for placing each function on its correct semantic owner. ## Core Features & Use Cases - Ownership-first decision procedure: Names the semantic owner before choosing syntax, rejecting misleading receivers early with a five-gate checklist. - Function form selection table: Maps meaning to form—member, top-level function, factory, injected service, or extension—based on policy, state, I/O, and dependency criteria. - Refactoring guidance: Covers moving implementations, updating callers and imports, and preserving or deprecating public entry points. - Use Case: When reviewing a PR containing fun String.toUserId(), apply the gates to reject the extension and refactor to UserId.parse(raw) on a value class companion object. ## Quick Start Ask the AI to review a Kotlin function placement, for example: should this date-formatting extension on Long be an extension, a top-level function, or a formatter service?

Frequently Asked Questions about kotlin-functions

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

FAQPage Schema
When should I use a Kotlin extension function vs a member function?▼

Use a member function for project-owned intrinsic behavior and an extension only when the operation is type-native, policy-free, valid for every receiver value, and materially clearer with receiver syntax. Extensions change call shape, not ownership.

How do I decide between a top-level function and an extension in Kotlin?▼

Choose a top-level function for cross-type, stateless operations. Reserve extensions for cases passing all ownership gates: narrow scope, no policy or I/O, validity for all receiver values, and no better project-owned owner.

Are extension functions on String or Long a bad practice in Kotlin?▼

Extensions on String, primitives, collections, Flow, or vendor types are rejected by default because they create false ownership and domain pollution. Operations like Long.toDisplayDate() belong in a formatter that owns time-zone and locale policy.

When should parsing logic live in a factory instead of an extension?▼

Construction and parsing belong to the target type, such as UserId.parse(raw) on a companion object, rather than String.toUserId(). The target type owns its construction semantics, keeping validation and creation in one place.

What are the risks of hiding policy inside Kotlin extension functions?▼

Extensions that hide clocks, locales, I/O, or dependencies obscure behavior and make testing harder. Behavior retaining policy, state, or dependencies belongs in an injected service or collaborator with explicit parameters.