/android-engineering-skills:android-patternsfrom Android Engineering Skills
Defines Android implementation patterns: Unidirectional Data Flow, ViewModel design, Flow composition, repository pattern, UseCases, and Compose UI patterns. Use when implementing ViewModels, state models, repositories, or reviewing reactive state management.
Ships in Android Engineering Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use this skill to implement Android features with explicit state, reactive flows, and testable logic.
Use a single direction of data movement.
User action -> ViewModel -> state update -> UI render -> optional event
Rules:
SharedFlow.Prefer this structure:
UiAction -> onAction() -> internal state -> derived state -> UiState -> Composable
Use explicit state types instead of boolean flags when possible.
Use a sealed interface for high-level screen lifecycle state.
@Immutable
internal sealed interface FeatureScreenUiState {
data object Loading : FeatureScreenUiState
data class Loaded(val data: FeatureUiState) : FeatureScreenUiState
data object Error : FeatureScreenUiState
}
Use a data class for the rendered content.
@Immutable
internal data class FeatureUiState(
val title: String,
val subtitle: String,
val items: List<ItemUiState>,
)
Use a sealed interface for user intents.
@Immutable
internal sealed interface FeatureUiAction {
data object Retry : FeatureUiAction
data class QueryChanged(val value: String) : FeatureUiAction
}
Use a sealed interface for one-time side effects.
internal sealed interface FeatureUiEvent {
data class ShowError(val message: String) : FeatureUiEvent
data object NavigateBack : FeatureUiEvent
}
Rules:
ViewModels should coordinate, not calculate everything.
Responsibilities:
StateFlowViewModels should not:
Recommended shape:
@HiltViewModel
internal class FeatureViewModel @Inject constructor(
private val observeItemsUseCase: ObserveItemsUseCase,
private val mapper: FeatureUiStateMapper,
) : ViewModel() {
private val _internalState = MutableStateFlow<FeatureInput?>(null)
private val _uiEvents = MutableSharedFlow<FeatureUiEvent>()
val uiEvents: SharedFlow<FeatureUiEvent> = _uiEvents.asSharedFlow()
val uiState: StateFlow<FeatureScreenUiState> =
someFlow
.map { result -> result.fold(...) }
.stateIn(
scope = viewModelScope,
started = SharingStarted.WhileSubscribed(5_000),
initialValue = FeatureScreenUiState.Loading,
)
fun onAction(action: FeatureUiAction) {
when (action) {
FeatureUiAction.Retry -> retry()
is FeatureUiAction.QueryChanged -> updateQuery(action.value)
}
}
}
Rules:
stateIn for StateFlow exposure.SharingStarted.WhileSubscribed(...) for UI-bound streams.onAction(action) as the single entry point for user input.Use Flow operators to compose asynchronous work.
combineUse when output depends on multiple latest values.
combine(firstFlow, secondFlow) { first, second ->
...
}
flatMapLatestUse when a new upstream value should cancel previous work.
queryFlow.flatMapLatest { query ->
repository.search(query)
}
mapUse for pure transformations.
flow.map { value -> transform(value) }
scanUse when the next value depends on the previous one.
flow.scan(initialValue) { previous, current ->
...
}
distinctUntilChangedUse to prevent unnecessary recomputation and re-rendering.
shareIn and stateInUse to share upstream work and keep the latest state available.
Rules:
mapLatest or flatMapLatest when newer input should cancel older work.Use explicit domain errors when possible.
Prefer:
sealed interface FeatureError {
data object Network : FeatureError
data object Unauthorized : FeatureError
data object Unknown : FeatureError
}
Rules:
Result<T> for operations that may fail.Recommended patterns:
Error screen state or explicit error stateRepositories should expose domain models and flows, not transport models.
Prefer:
Flow<Result<List<Model>>>Flow<Result<Model>>ResultAvoid:
Repository responsibilities may include:
Keep mapping explicit and dedicated to mapper classes.
Use cases represent application actions.
Naming:
FetchItemsUseCaseObserveItemsUseCaseSubmitFormUseCaseRules:
fun [verb](...). For example, fetchItemsUseCase.fetch() or observeItemsUseCase.observe()Use a screen composable to connect to the ViewModel, and a stateless content composable for rendering.
@Composable
internal fun FeatureScreen(viewModel: FeatureViewModel) {
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
FeatureContent(
uiState = uiState,
onAction = viewModel::onAction,
)
}
Rules:
Collect events in LaunchedEffect from the screen layer.
Keep purely visual or temporary state in Compose when it does not belong in the ViewModel.
Examples:
Hoist state to the nearest composable that needs to share it.
Always provide stable keys in lazy lists when item identity exists.
Use a local TextFieldValue only when the UI must preserve cursor position or selection.
Use a visual transformation only for display formatting. Keep the raw input value separate.
Keep mapping and calculations out of composables.
Use dedicated classes for:
Rules:
Do not mix these concerns in one place unless the feature is extremely small.
Check the code against these questions:
Refactor when:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
android-patterns, udf, viewmodel, compose, state-management, reactive-flows
3 skills in this plugin
/android-architectureDefines project structure, package layout, layer boundaries, naming conventions, and dependency injection setup for Android projects. Use this skill whenever creating a new Android project, adding a new feature module, scaffolding a new screen or flow, setting up DI bindings, naming any class or file, or deciding which layer a piece of code belongs in. Also use it when reviewing or refactoring existing code to ensure it follows the established architecture./android-testingDefines testing standards for Android projects, including JUnit 5, Turbine, Mockito or MockK, descriptive backtick test names, parameterized tests, and flow testing patterns. Use this skill when creating, reviewing, or refactoring unit tests for ViewModels, use cases, mappers, calculators, repositories, or other pure Kotlin Android components.npx claudepluginhub lennonpetrick/android-engineering-skills --plugin android-engineering-skills2 plugins ship this exact skill · first indexed Oct 17, 2026
Other plugins' skills for the same job