kotlin-best-practices
БесплатноБез исполняемых скриптовНе проверенCore Kotlin patterns for scope functions, backing properties, and read-only collection interfaces. Use for let/apply/run/also/with choices or encapsulating…
от HoangNguyen0403★ 598 звёзд на GitHubОб этом скилле
Kotlin Best Practices
Priority: P1 (HIGH)
Implementation Guidelines
- Scope Functions:
apply: Object configuration (returns object).also: Side effects / validation / logging (returns object).let: Null checks (?.let) or mapping (returns result).run: Object configuration and mapping (returns result).with: Grouping multiple method calls on object (returns result).- Backing Properties: Use
_state(private mutable, e.g.,private val _state = MutableStateFlow(initial)) exposed asval state = _state.asStateFlow()(public read-only). Pattern:_propprivate,proppublic. On Kotlin 2.4+ an explicit backing field (val state: StateFlow<…> field = MutableStateFlow(…)) is a stable alternative — see Kotlin 2.4 features. Keep the_propidiom for olderlanguageVersions. - Collections: Expose
List/Map(read-only) publicly; keepMutableListinternal. - Error Handling: Use
runCatchingfor simple, non-suspending recovery over try/catch. In coroutines it also catchesCancellationException— rethrow it before mapping a failure (see kotlin-coroutines). - Visibility: Default to
privateorinternal. Minimizepublicsurface area. - Top-Level: Prefer top-level functions/constants over implementation-less
objectsingletons.
Anti-Patterns
- No Deep Scope Nesting: Limit let/apply nesting to 2 levels; deeper destroys readability.
- No Public var: Use private set or backing properties for encapsulation.
- No Global Mutable State: Avoid mutable top-level variables.
References
- Backing Property & Scope Function Examples
- Kotlin 2.4 Gated Features — load only for 2.4+ projects
Установить kotlin-best-practices в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл kotlin-best-practices?
Core Kotlin patterns for scope functions, backing properties, and read-only collection interfaces. Use for let/apply/run/also/with choices or encapsulating mutable state; defer general language constructs, extension functions, coroutines/runCatching, Android/Room recipes, and testing/tooling setup.
Как установить скилл kotlin-best-practices?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл kotlin-best-practices запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic