Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
ahmed3elshaer avatar

Android Patterns

  • 22 installs
  • 60 repo stars
  • Updated June 14, 2026
  • ahmed3elshaer/everything-claude-code-mobile

android-patterns is a Claude Code skill covering core Android development patterns in Kotlin, including coroutines and functional idioms.

About

android-patterns is a Claude Code skill covering core Android development patterns in Kotlin. It documents Kotlin idioms for immutability, null safety, scope functions, and extensions, plus lifecycle patterns using ViewModel and StateFlow collected with lifecycle awareness. It also shows functional patterns like the Result type, higher-order retry functions, and sealed UiState classes for building modern Android apps.

  • Core Android development patterns for Kotlin with coroutines
  • Kotlin idioms: immutability, null safety, scope functions, extensions
  • Lifecycle-aware ViewModel/StateFlow and functional Result/sealed-class patterns

Android Patterns by the numbers

  • 22 all-time installs (skills.sh)
  • Ranked #711 of 1,039 Mobile Development skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
At a glance

android-patterns capabilities & compatibility

Capabilities
android development · kotlin patterns · coroutines · viewmodel state
Use cases
frontend
Pricing
Free
From the docs

What android-patterns says it does

Core Android development patterns for Kotlin, including coroutines, lifecycle management, and functional programming idioms.
SKILL.md
Kotlin is concise. Embrace its idioms for cleaner, safer code.
SKILL.md
npx skills add https://github.com/ahmed3elshaer/everything-claude-code-mobile --skill android-patterns

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs22
repo stars60
Last updatedJune 14, 2026
Repositoryahmed3elshaer/everything-claude-code-mobile

What it does

Write idiomatic modern Android code in Kotlin using coroutines, ViewModel/StateFlow, and functional patterns.

Who is it for?

Writing idiomatic Kotlin Android code with ViewModel/StateFlow and functional Result patterns.

Skip if: iOS or cross-platform code; it is Kotlin and Android specific.

When should I use this skill?

Writing or reviewing Android Kotlin code that uses coroutines, ViewModels, or functional idioms.

What you get

Idiomatic Kotlin Android code using coroutines, lifecycle-aware StateFlow, and functional error handling.

  • Idiomatic Kotlin Android code

Files

SKILL.mdMarkdownGitHub ↗

Android Development Patterns

Modern Android patterns with Kotlin, coroutines, and functional programming.

Kotlin Idioms

Immutability

// ✅ Prefer val over var
val name: String = "John"

// ✅ Immutable collections
val items: List<Item> = listOf(item1, item2)

// ✅ Data class with copy
data class User(val id: String, val name: String)
val updatedUser = user.copy(name = "Jane")

Null Safety

// ✅ Safe call
val length = name?.length

// ✅ Elvis operator
val name = nullableName ?: "Unknown"

// ✅ let for null checks
nullableUser?.let { user ->
    processUser(user)
}

// ✅ Early return with null check
fun processUser(user: User?) {
    user ?: return
    // user is smart-cast to non-null
}

Scope Functions

// let - Transform and return
val result = nullable?.let { transform(it) }

// run - Configure and return result
val result = service.run {
    configure()
    execute()
}

// with - Operate on object
with(binding) {
    title.text = "Title"
    subtitle.text = "Subtitle"
}

// apply - Configure and return self
val user = User().apply {
    name = "John"
    email = "john@example.com"
}

// also - Side effects, return self
val user = User().also {
    logger.log("Created user: ${it.id}")
}

Extensions

// ✅ Extension functions
fun String.isValidEmail(): Boolean {
    return android.util.Patterns.EMAIL_ADDRESS.matcher(this).matches()
}

// ✅ Extension properties
val Context.screenWidth: Int
    get() = resources.displayMetrics.widthPixels

// Usage
if (email.isValidEmail()) { ... }
val width = context.screenWidth

Lifecycle Patterns

ViewModel

class HomeViewModel(
    private val repository: HomeRepository,
    savedStateHandle: SavedStateHandle
) : ViewModel() {

    private val _state = MutableStateFlow(HomeState())
    val state: StateFlow<HomeState> = _state.asStateFlow()
    
    init {
        loadData()
    }
    
    private fun loadData() {
        viewModelScope.launch {
            _state.update { it.copy(isLoading = true) }
            
            repository.getItems()
                .onSuccess { items -> _state.update { it.copy(items = items, isLoading = false) } }
                .onFailure { error -> _state.update { it.copy(error = error.message, isLoading = false) } }
        }
    }
}

Lifecycle-aware Collection

@Composable
fun HomeScreen(viewModel: HomeViewModel = koinViewModel()) {
    val state by viewModel.state.collectAsStateWithLifecycle()
    
    HomeContent(state = state)
}

Functional Patterns

Result Type

// ✅ Use Result for operations that can fail
suspend fun fetchUser(id: String): Result<User> = runCatching {
    api.getUser(id).toDomain()
}

// ✅ Chain operations
repository.fetchUser(id)
    .map { it.profile }
    .mapCatching { decryptProfile(it) }
    .onSuccess { displayProfile(it) }
    .onFailure { showError(it) }

Higher-Order Functions

// ✅ Pass functions as parameters
fun <T> retry(
    times: Int,
    block: suspend () -> T
): T {
    repeat(times - 1) {
        try { return block() }
        catch (e: Exception) { delay(1000) }
    }
    return block() // Last attempt
}

// Usage
val result = retry(3) { api.fetchData() }

Sealed Classes

sealed interface UiState<out T> {
    data object Loading : UiState<Nothing>
    data class Success<T>(val data: T) : UiState<T>
    data class Error(val message: String) : UiState<Nothing>
}

// Exhaustive when
when (state) {
    is UiState.Loading -> LoadingIndicator()
    is UiState.Success -> Content(state.data)
    is UiState.Error -> ErrorMessage(state.message)
}

Resource Management

Context Extensions

fun Context.dp(value: Int): Int = 
    (value * resources.displayMetrics.density).toInt()

fun Context.showToast(message: String) {
    Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
}

String Resources

// strings.xml
<string name="welcome_message">Welcome, %1$s!</string>

// Usage
stringResource(R.string.welcome_message, userName)

---

Remember: Kotlin is concise. Embrace its idioms for cleaner, safer code.

Related skills

FAQ

What does android-patterns cover?

Kotlin idioms, lifecycle patterns with ViewModel and StateFlow, and functional patterns like Result and sealed UiState classes.

Is it Compose-oriented?

It shows lifecycle-aware collection with collectAsStateWithLifecycle in Compose alongside general Kotlin idioms.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.