android-kotlin

Android development with Kotlin 2.x, Jetpack Compose, Clean Architecture, and performance. Use when working with .kt files, build.gradle.kts, AndroidManifest.xml, or Compose UI.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "android-kotlin" with this command: npx skills add maroffo/claude-forge/maroffo-claude-forge-android-kotlin

ABOUTME: Android/Kotlin - Compose, architecture, testing, performance

ABOUTME: Kotlin 2.x, Compose 1.7+, type-safe navigation, Baseline Profiles

Android/Kotlin

Commands

./gradlew assembleDebug|assembleRelease|test|connectedAndroidTest|lint|ktlintFormat
./gradlew :feature:home:build                    # Module-specific

See: _AST_GREP.md (sg patterns) | _PATTERNS.md | source-control


Architecture

Clean Architecture Structure

feature/
├── data/repository/, datasource/local/, datasource/remote/
├── domain/model/, repository/ (interface), usecase/
└── presentation/screen/, viewmodel/

Use Cases

Single responsibility, orchestration here (NOT in ViewModel).

class SignInUseCase(private val auth: AuthRepository, private val user: UserRepository) {
    suspend operator fun invoke(email: String, password: String): Result<User> {
        val result = auth.signIn(email, password).getOrElse { return Result.failure(it) }
        user.saveUserLocally(result)
        return Result.success(result)
    }
}

ViewModel Pattern

class FeedViewModel(private val getFeed: GetFeedUseCase) : ViewModel() {
    private val _uiState = MutableStateFlow<FeedUiState>(FeedUiState.Loading)
    val uiState = _uiState.asStateFlow()

    private val _sideEffects = Channel<FeedSideEffect>(Channel.BUFFERED)
    val sideEffects = _sideEffects.receiveAsFlow()

    fun loadFeed() = viewModelScope.launch {
        _uiState.value = FeedUiState.Loading
        getFeed().onSuccess { _uiState.value = FeedUiState.Success(it) }
                 .onFailure { _uiState.value = FeedUiState.Error(it.message) }
    }
}

sealed interface FeedUiState { /* Loading, Success, Error */ }
sealed interface FeedSideEffect { /* NavigateToDetail, ShowSnackbar */ }

Dependency Injection

AspectHiltKoin
TypeCompile-timeRuntime
Build timeSlowerFaster
Error detectionCompileRuntime
KMP supportNoYes
Best forLarge/enterpriseSmall-medium/KMP

Hilt: @HiltAndroidApp, @AndroidEntryPoint, @HiltViewModel, @Inject constructor Koin: module { }, single, factory, viewModelOf, koinViewModel()

See references/compose-patterns.md for setup examples.


Compose Essentials

State hoisting: Lift state to the caller, pass callbacks down.

@Composable
fun UserCard(user: User, onClick: () -> Unit, modifier: Modifier = Modifier) {
    Card(onClick = onClick, modifier = modifier) { /* content */ }
}

State management:

  • remember { mutableStateOf() }, lost on config change
  • rememberSaveable { mutableStateOf() }, survives config change
  • derivedStateOf, computed state

Side effects: LaunchedEffect(key), DisposableEffect

Type-safe navigation: @Serializable routes (2.8.0+)

See references/compose-patterns.md for detailed examples.


Code Review Checklists

Architecture

  • VMs don't chain use cases (orchestration in domain)
  • VMs don't call repositories directly
  • Use cases have single responsibility
  • State immutable (use copy())
  • Side effects use Channel/SharedFlow (not StateFlow)

Compose

  • State hoisted appropriately
  • remember vs rememberSaveable correct
  • Side effects use correct APIs
  • Stable types for parameters
  • key used in LazyColumn/LazyRow

Red Flags

CriticalHigh
Network/DB on main threadUse case chaining in VM
StateFlow for one-time eventsMutable state exposed from VM
Hardcoded strings in UIMissing key in LazyColumn
Missing error handlingcollectAsState vs collectAsStateWithLifecycle
R8 disabled in release

Quick Reference

Kotlin 2.x features: Guard conditions (2.1), context parameters (2.2), K2 compiler benefits → references/kotlin-features.md

Compose patterns: State, side effects, navigation, image loading → references/compose-patterns.md

Networking & Data: Retrofit, Ktor, Room, DataStore → references/data-layer.md

Testing: Compose UI tests, ViewModel tests, snapshot tests → references/testing-patterns.md

Performance: R8, Baseline Profiles, Compose optimization → references/performance.md


Resources

Official: android.com/kotlin | compose | architecture | type-safe nav | baseline profiles

Kotlin: 2.2 | 2.1.20 | 2.3

Libraries: Coil | Koin | Hilt | Retrofit | Ktor | Room

Testing: Compose testing | Paparazzi | Turbine

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

clickup

No summary provided by upstream source.

Repository SourceNeeds Review
General

newsletter-digest

No summary provided by upstream source.

Repository SourceNeeds Review
General

rails

No summary provided by upstream source.

Repository SourceNeeds Review