This specialized Claude skill provides automated, high-depth code reviews for Android Kotlin projects. It focuses on modern development standards including Jetpack Compose patterns, Coroutines structured concurrency, and Flow state management. By analyzing ViewModel structures and detecting memory leaks, it ensures Android applications are performant, scalable, and follow official Google best practices.
Use Cases
Jetpack Compose Optimization: Identifying anti-patterns such as object creation without 'remember', improper side-effects (LaunchedEffect), and missing keys in LazyColumns to prevent UI lag.
Asynchronous Logic Audit: Detecting 'GlobalScope' abuse, ensuring proper Dispatcher selection for IO/Main tasks, and verifying robust exception handling in Coroutines and Flow.
Architecture & State Management: Reviewing ViewModel implementations to enforce unidirectional data flow (UDF) and preventing memory leaks by flagging direct Context or View references.
Memory Leak & Performance Inspection: Scanning for uncancelled jobs, unreleased resources, and inner class references that could lead to Out-of-Memory (OOM) errors and application crashes.
"Which areas to review?"
Options:
- Full Android pattern check (recommended)
- Jetpack Compose UI patterns
- Coroutines/Flow usage
- ViewModel/State management
- Memory leaks/Performance
multiSelect: true
Detection Rules
Jetpack Compose Patterns
Check
Recommendation
Severity
Side-effect in Composable
Use LaunchedEffect/SideEffect
HIGH
Object creation without remember
Use remember { }
HIGH
Missing State hoisting
Hoist state to parent
MEDIUM
Missing derivedStateOf
Use for derived state
LOW
LazyColumn without key
Add key parameter
HIGH
// BAD: Object creation without remember
@Composable
fun MyScreen() {
val list = mutableListOf<String>() // New every recomposition
}
// GOOD: Use remember
@Composable
fun MyScreen() {
val list = remember { mutableListOf<String>() }
}
// BAD: Direct suspend call in Composable
@Composable
fun MyScreen(viewModel: MyViewModel) {
viewModel.loadData() // Side-effect!
}
// GOOD: Use LaunchedEffect
@Composable
fun MyScreen(viewModel: MyViewModel) {
LaunchedEffect(Unit) {
viewModel.loadData()
}
}
Coroutines Patterns
Check
Recommendation
Severity
GlobalScope usage
Use viewModelScope/lifecycleScope
CRITICAL
Missing Dispatcher
Specify Dispatchers.IO/Default
MEDIUM
Missing exception handling
try-catch or CoroutineExceptionHandler
HIGH
runBlocking abuse
Convert to suspend function
HIGH
// BAD: GlobalScope
GlobalScope.launch {
repository.fetchData()
}
// GOOD: viewModelScope
viewModelScope.launch {
repository.fetchData()
}
// BAD: Network on Main
viewModelScope.launch {
val result = api.getData() // NetworkOnMainThreadException
}
// GOOD: IO Dispatcher
viewModelScope.launch {
val result = withContext(Dispatchers.IO) {
api.getData()
}
}
Flow Patterns
Check
Recommendation
Severity
Direct collect in Composable
Use collectAsState
HIGH
SharedFlow without replay
Set appropriate replay value
MEDIUM
Nullable StateFlow initial
Provide meaningful initial value
MEDIUM
// BAD: Direct collect in Composable
@Composable
fun MyScreen(viewModel: MyViewModel) {
var data by remember { mutableStateOf<Data?>(null) }
LaunchedEffect(Unit) {
viewModel.dataFlow.collect { data = it }
}
}
// GOOD: collectAsState
@Composable
fun MyScreen(viewModel: MyViewModel) {
val data by viewModel.dataFlow.collectAsState()
}
// BAD: Nullable StateFlow initial
private val _state = MutableStateFlow<UiState?>(null)
// GOOD: Sealed class with clear initial state
private val _state = MutableStateFlow<UiState>(UiState.Loading)
ViewModel Patterns
Check
Issue
Severity
Direct Context reference
Memory leak risk
CRITICAL
View reference
Memory leak risk
CRITICAL
Missing SavedStateHandle
Process death handling
MEDIUM
Bidirectional data flow
Use UiState + Event pattern
MEDIUM
// BAD: Activity Context reference
class MyViewModel(private val context: Context) : ViewModel()
// GOOD: Application Context with Hilt
class MyViewModel(
@ApplicationContext private val context: Context
) : ViewModel()
// BAD: Bidirectional binding
class MyViewModel : ViewModel() {
var name = MutableLiveData<String>()
}
// GOOD: Unidirectional + sealed class
class MyViewModel : ViewModel() {
private val _uiState = MutableStateFlow(UiState())
val uiState: StateFlow<UiState> = _uiState.asStateFlow()
fun onNameChanged(name: String) {
_uiState.update { it.copy(name = name) }
}
}