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.
npx skills add piyushverma0/android-agent-skills --skill kotlin-patternsgit clone --depth 1 https://github.com/piyushverma0/android-agent-skillsWrote 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.
[](https://agentmods.dev/skills/piyushverma0/android-agent-skills/kotlin-patterns)<a href="https://agentmods.dev/skills/piyushverma0/android-agent-skills/kotlin-patterns"><img src="https://agentmods.dev/badge/skills/piyushverma0/android-agent-skills/kotlin-patterns/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.
<a href="https://agentmods.dev/skills/piyushverma0/android-agent-skills/kotlin-patterns"><img src="https://agentmods.dev/badge/skills/piyushverma0/android-agent-skills/kotlin-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00134 | $0.02433 |
| Opus 5 | $0.00067 | $0.01216 |
| Sonnet 5 | $0.00027 | $0.00487 |
| Haiku 4.5 | $0.00013 | $0.00243 |
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 10d 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.
How it starts
The opening of the file, as written. The whole thing — 301 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Kotlin Patterns for Android
12 rules for idiomatic, production-safe Kotlin on Android.
Rule 1: Coroutine scope — always use structured concurrency
// ✅ viewModelScope — auto-cancelled when ViewModel is cleared
class MyViewModel : ViewModel() {
fun load() {
viewModelScope.launch {
val result = fetchData() // suspend, cancellable
}
}
}
// ✅ lifecycleScope — tied to Activity/Fragment lifecycle
class MyActivity : ComponentActivity() {
override fun onStart() {
super.onStart()
lifecycleScope.launch {
viewModel.events.collect { handleEvent(it) }
}
}
}
// ❌ GlobalScope — not structured, leaks, not cancellable
GlobalScope.launch { fetchData() }
// ❌ CoroutineScope(Dispatchers.IO) without proper lifecycle binding
val scope = CoroutineScope(Dispatchers.IO)
scope.launch { fetchData() } // never cancelled
Rule 2: Dispatcher discipline — always switch off Main
// ✅ IO-bound work: switch to IO dispatcher
suspend fun fetchUser(id: String): User = withContext(Dispatchers.IO) {
api.getUser(id)
}
// ✅ CPU-intensive work: use Default dispatcher
suspend fun processLargeList(items: List<Item>): List<Result> = withContext(Dispatchers.Default) {
items.map { processItem(it) }
}
// ✅ Inject dispatcher for testability
class UserRepository @Inject constructor(
private val api: UserApi,
@IoDispatcher private val dispatcher: CoroutineDispatcher
) {
suspend fun getUser(id: String): User = withContext(dispatcher) {
api.getUser(id)
}
}
// ❌ Network call on Main thread — crashes with NetworkOnMainThreadException
suspend fun fetchUser(): User = api.getUser() // on Main, wrong
Rule 3: StateFlow — expose, never expose MutableStateFlow
// ✅ Mutable private, immutable public
private val _uiState = MutableStateFlow(HomeUiState.Loading)
val uiState: StateFlow<HomeUiState> = _uiState.asStateFlow()
// ✅ Update state correctly
_uiState.value = HomeUiState.Success(items) // from coroutine on Main
_uiState.update { current -> current.copy(isLoading = false) } // thread-safe update
// ❌ Exposing MutableStateFlow — external code can change state
val uiState = MutableStateFlow(HomeUiState.Loading) // anyone can set this
What ships with it
15 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.
- .gitkeep 0 B
- metadata.json 742 B
- references/flow-operators-reference.md 3.6 KB
- rules/collections.md 3.7 KB
- rules/coroutines-dispatchers.md 3.7 KB
- rules/coroutines-exception-handling.md 3.6 KB
- rules/coroutines-scope-selection.md 3.0 KB
- rules/data-classes.md 3.8 KB
- rules/delegation.md 3.4 KB
- rules/extension-functions.md 3.4 KB
- rules/flow-operators.md 4.2 KB
- rules/flow-stateflow-sharedflow.md 3.4 KB
- rules/null-safety.md 3.9 KB
- rules/scope-functions.md 2.6 KB
- rules/sealed-classes-result.md 3.8 KB
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.
- 10d ago First seen · 301 lines · 134 tokens per session scan A 764390ed5211
kotlin-patterns is a skill published in the GitHub repository piyushverma0/android-agent-skills (15 stars, last pushed 4mo ago), licensed MIT. It adds 134 tokens to every session and 2,433 once invoked, about $0.0007 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
kotlin-coroutines-expert
Expert patterns for Kotlin Coroutines and Flow, covering structured concurrency, error handling, and testing in this Android app.
android-jetpack-compose-expert
Expert guidance for building modern Android UIs with Jetpack Compose, covering state management, navigation, performance, and Material Design 3.
compose-animations
Use when writing or reviewing Jetpack Compose motion: visibility enter/exit, animating one property toward a target, color or size transitions, multiple properties from one state, switching composable content, or choosing between AnimatedVisibility, animateAsState, rememberTransition, AnimatedContent, and Crossfade.
compose-focus-navigation
Use when writing or reviewing Jetpack Compose UI for TV, keyboard, desktop, accessibility focus, D-pad navigation, FocusRequester, focusProperties, key events, or initial focus behavior.
ios-slim-bindings
Create iOS slim bindings for MAUI. USE FOR: slim iOS binding, Native Library Interop, Swift/Objective-C wrappers, XcodeGen project.yml, Podfile, CocoaPods static linking, BUILDLIBRARYFORDISTRIBUTION, XcodeProject MSBuild, @objc/[Export] selector crashes, async completion handlers. DO NOT USE FOR: Android bindings…
kmp-lsp
Kotlin/Java/Swift LSP server for code navigation in Android and iOS codebases. Use when navigating Kotlin, Java, or Swift source files: finding class definitions, listing symbols, jumping to implementations, finding all usages, checking type signatures, or switching workspace between projects. Triggers for: "find this…