Help us improve
Share bugs, ideas, or general feedback.
From kotlinsense
Common Kotlin diagnostics from the language server and how to fix them. Use when the LSP reports Kotlin errors or warnings, or when diagnosing compilation failures in a Kotlin or Android project.
npx claudepluginhub sudarshanchaudhari/kotlinsense --plugin kotlinsenseHow this skill is triggered — by the user, by Claude, or both
Slash command
/kotlinsense:kotlin-diagnosticsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
```
Creates p5.js generative art with seeded randomness, noise fields, and interactive parameter exploration. Use for algorithmic art, flow fields, or particle systems.
Share bugs, ideas, or general feedback.
error: unresolved reference: 'FooClass'
Fixes:
import com.example.FooClassbuild.gradle.kts (implementation(...))./gradlew build if the class is generated (Room, Hilt, etc.)error: type mismatch: inferred type is String but Int was expected
Fixes:
str.toInt(), num.toString(), num.toLong()when for sealed class branches to satisfy exhaustivenesserror: only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver
Fixes (prefer in this order):
// 1. Safe call — returns null if receiver is null
nullableObj?.method()
// 2. Elvis operator — provide a default
nullableObj?.property ?: defaultValue
// 3. Let block — operate only when non-null
nullableObj?.let { obj ->
obj.method()
}
// 4. Non-null assertion — only if you're certain it can't be null
nullableObj!!.method() // crashes with NullPointerException if null
error: val cannot be reassigned
Fix: Change val to var if reassignment is needed. Prefer val (immutable) by default.
error: 'foo' hides member of supertype and needs 'override' modifier
Fix: Add the override keyword:
override fun foo() { ... }
override val bar: String = "value"
error: suspend function 'collect' should be called only from a coroutine or another suspend function
Fix: Call from a coroutine scope:
// In ViewModel
viewModelScope.launch {
repository.flow.collect { value -> ... }
}
// In Fragment/Activity
viewLifecycleOwner.lifecycleScope.launch {
viewModel.uiState.collect { state -> render(state) }
}
error: a 'return' expression required in a function with a block body
Fixes:
// Option 1: add explicit return
fun foo(): String {
return "value"
}
// Option 2: use expression body (preferred for simple functions)
fun foo(): String = "value"
warning: GlobalScope usage is strongly discouraged
Fix: Replace with structured concurrency:
// In ViewModel
viewModelScope.launch { ... }
// In Fragment/Activity
lifecycleScope.launch { ... }
// In a suspend function — use coroutineScope { } for fan-out
coroutineScope {
launch { ... }
launch { ... }
}
error: type mismatch: inferred type is View? but View was expected
Fix: Migrate to View Binding or Jetpack Compose. If using XML temporarily:
val button = findViewById<Button>(R.id.myButton) ?: return
Fix: Hoist state reads into restartable composables, or use remember:
val count by remember { mutableStateOf(0) }