kotlin_skill
- Python
13
GitHub Stars
2
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill williamzujkowski/standards --skill kotlin- REFERENCE.md21.3 KB
- SKILL.md7.1 KB
Overview
This skill teaches battle-tested Kotlin coding standards focused on null safety, coroutines, and idiomatic patterns for JVM and Android projects. It provides compact reference patterns, implementation guidance, and tooling recommendations to start a project correctly and safely. Use it to enforce consistent, maintainable, and type-safe asynchronous code.
How this skill works
The skill inspects common Kotlin patterns and prescribes safe alternatives: nullable types, smart casts, scope functions, and delegation. It covers coroutine usage (suspend functions, builders, Flow/StateFlow), collection functional idioms, Java interoperability, and testing patterns. It also recommends linters and static-analysis tools to enforce rules across a codebase.
When to use it
- Starting a new JVM or Android project and want consistent Kotlin standards from day one
- Refactoring code to remove null-safety hazards and platform-type assumptions
- Designing async workflows with coroutines, Flow, or StateFlow
- Introducing functional collection transformations and lazy evaluation
- Setting up CI checks with detekt and ktlint for Kotlin code quality
Best practices
- Prefer nullable types and safe calls over the not-null assertion (!!)
- Favor immutable vals; use var only when mutation is required
- Use data classes for DTOs and sealed classes for restricted hierarchies
- Adopt structured concurrency: prefer coroutineScope/withContext over global scopes
- Use scope functions (let/apply/also/run/with) consistently for clarity
- Integrate detekt and ktlint to enforce style and catch issues early
Example use cases
- Implement a repository layer using suspend functions and withContext(Dispatchers.IO)
- Model UI state with sealed classes and expose it via StateFlow for Compose or LiveData
- Build concurrent API calls with async/await inside coroutineScope to aggregate results
- Create custom property delegates for SharedPreferences or observable properties
- Migrate Java interop code by making platform types explicit and adding @JvmStatic/@JvmOverloads where needed
FAQ
Avoid it; prefer smart casts, early returns, or explicit null handling. Use !! only when a null truly indicates a programming error and you want an immediate failure.
When to use Flow vs LiveData vs StateFlow?
Use Flow for cold asynchronous streams and transformations, StateFlow for hot state with a current value, and LiveData when you need lifecycle-aware observers in legacy Android components.
How do I test coroutine code reliably?
Use runTest or TestCoroutineDispatcher/TestScope helpers, MockK for mocking suspend functions, and Turbine for collecting and asserting Flow emissions.