dpconde

android-development

15
6
# Install this skill:
npx skills add dpconde/claude-android-skill

Or install specific skill: npx add-skill https://github.com/dpconde/claude-android-skill

# Description

Create production-quality Android applications following Google's official architecture guidance and NowInAndroid best practices. Use when building Android apps with Kotlin, Jetpack Compose, MVVM architecture, Hilt dependency injection, Room database, or multi-module projects. Triggers on requests to create Android projects, screens, ViewModels, repositories, feature modules, or when asked about Android architecture patterns.

# SKILL.md


name: android-development
description: Create production-quality Android applications following Google's official architecture guidance and NowInAndroid best practices. Use when building Android apps with Kotlin, Jetpack Compose, MVVM architecture, Hilt dependency injection, Room database, or multi-module projects. Triggers on requests to create Android projects, screens, ViewModels, repositories, feature modules, or when asked about Android architecture patterns.


Android Development

Build Android applications following Google's official architecture guidance, as demonstrated in the NowInAndroid reference app.

Quick Reference

Task Reference File
Project structure & modules modularization.md
Architecture layers (UI, Domain, Data) architecture.md
Jetpack Compose patterns compose-patterns.md
Gradle & build configuration gradle-setup.md
Testing approach testing.md

Workflow Decision Tree

Creating a new project?
β†’ Read modularization.md for project structure
β†’ Use templates in assets/templates/

Adding a new feature?
β†’ Create feature module with api and impl submodules
β†’ Follow patterns in architecture.md

Building UI screens?
β†’ Read compose-patterns.md
β†’ Create Screen + ViewModel + UiState

Setting up data layer?
β†’ Read data layer section in architecture.md
β†’ Create Repository + DataSource + DAO

Core Principles

  1. Offline-first: Local database is source of truth, sync with remote
  2. Unidirectional data flow: Events flow down, data flows up
  3. Reactive streams: Use Kotlin Flow for all data exposure
  4. Modular by feature: Each feature is self-contained with clear boundaries
  5. Testable by design: Use interfaces and test doubles, no mocking libraries

Architecture Layers

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              UI Layer                    β”‚
β”‚  (Compose Screens + ViewModels)          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚           Domain Layer                   β”‚
β”‚  (Use Cases - optional, for reuse)       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚            Data Layer                    β”‚
β”‚  (Repositories + DataSources)            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Module Types

app/                    # App module - navigation, scaffolding
feature/
  β”œβ”€β”€ featurename/
  β”‚   β”œβ”€β”€ api/          # Navigation keys (public)
  β”‚   └── impl/         # Screen, ViewModel, DI (internal)
core/
  β”œβ”€β”€ data/             # Repositories
  β”œβ”€β”€ database/         # Room DAOs, entities
  β”œβ”€β”€ network/          # Retrofit, API models
  β”œβ”€β”€ model/            # Domain models (pure Kotlin)
  β”œβ”€β”€ common/           # Shared utilities
  β”œβ”€β”€ ui/               # Reusable Compose components
  β”œβ”€β”€ designsystem/     # Theme, icons, base components
  β”œβ”€β”€ datastore/        # Preferences storage
  └── testing/          # Test utilities

Creating a New Feature

  1. Create feature:myfeature:api module with navigation key
  2. Create feature:myfeature:impl module with:
  3. MyFeatureScreen.kt - Composable UI
  4. MyFeatureViewModel.kt - State holder
  5. MyFeatureUiState.kt - Sealed interface for states
  6. MyFeatureNavigation.kt - Navigation setup
  7. MyFeatureModule.kt - Hilt DI module

Standard File Patterns

ViewModel Pattern

@HiltViewModel
class MyFeatureViewModel @Inject constructor(
    private val myRepository: MyRepository,
) : ViewModel() {

    val uiState: StateFlow<MyFeatureUiState> = myRepository
        .getData()
        .map { data -> MyFeatureUiState.Success(data) }
        .stateIn(
            scope = viewModelScope,
            started = SharingStarted.WhileSubscribed(5_000),
            initialValue = MyFeatureUiState.Loading,
        )

    fun onAction(action: MyFeatureAction) {
        when (action) {
            is MyFeatureAction.ItemClicked -> handleItemClick(action.id)
        }
    }
}

UiState Pattern

sealed interface MyFeatureUiState {
    data object Loading : MyFeatureUiState
    data class Success(val items: List<Item>) : MyFeatureUiState
    data class Error(val message: String) : MyFeatureUiState
}

Screen Pattern

@Composable
internal fun MyFeatureRoute(
    onNavigateToDetail: (String) -> Unit,
    viewModel: MyFeatureViewModel = hiltViewModel(),
) {
    val uiState by viewModel.uiState.collectAsStateWithLifecycle()
    MyFeatureScreen(
        uiState = uiState,
        onAction = viewModel::onAction,
        onNavigateToDetail = onNavigateToDetail,
    )
}

@Composable
internal fun MyFeatureScreen(
    uiState: MyFeatureUiState,
    onAction: (MyFeatureAction) -> Unit,
    onNavigateToDetail: (String) -> Unit,
) {
    when (uiState) {
        is MyFeatureUiState.Loading -> LoadingIndicator()
        is MyFeatureUiState.Success -> ContentList(uiState.items, onAction)
        is MyFeatureUiState.Error -> ErrorMessage(uiState.message)
    }
}

Repository Pattern

interface MyRepository {
    fun getData(): Flow<List<MyModel>>
    suspend fun updateItem(id: String, data: MyModel)
}

internal class OfflineFirstMyRepository @Inject constructor(
    private val localDataSource: MyDao,
    private val networkDataSource: MyNetworkApi,
) : MyRepository {

    override fun getData(): Flow<List<MyModel>> =
        localDataSource.getAll().map { entities ->
            entities.map { it.toModel() }
        }

    override suspend fun updateItem(id: String, data: MyModel) {
        localDataSource.upsert(data.toEntity())
    }
}

Key Dependencies

// Gradle version catalog (libs.versions.toml)
[versions]
kotlin = "1.9.x"
compose-bom = "2024.x.x"
hilt = "2.48"
room = "2.6.x"
coroutines = "1.7.x"

[libraries]
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }

Build Configuration

Use convention plugins in build-logic/ for consistent configuration:
- AndroidApplicationConventionPlugin - App modules
- AndroidLibraryConventionPlugin - Library modules
- AndroidFeatureConventionPlugin - Feature modules
- AndroidComposeConventionPlugin - Compose setup
- AndroidHiltConventionPlugin - Hilt setup

See gradle-setup.md for complete build configuration.

# README.md

[WIP] Android Development Skill for Claude Code

A production-ready skill that enables Claude Code to build Android applications following Google's official architecture guidance and best practices from the NowInAndroid reference app.

Overview

This skill provides Claude with comprehensive knowledge of modern Android development patterns, including:

  • Clean Architecture with UI, Domain, and Data layers
  • Jetpack Compose patterns and best practices
  • Multi-module project structure with convention plugins
  • Offline-first architecture with Room and reactive streams
  • Dependency injection with Hilt
  • Comprehensive testing strategies

Installation

  1. Clone this repository into your Claude Code skills directory:
    bash git clone https://github.com/dpconde/claude-android-skill.git

  2. Claude Code will automatically detect and load the skill when you work on Android projects.

Usage

The skill automatically activates when you request Android-related tasks. Simply ask Claude to:

  • "Create a new Android feature module for user settings"
  • "Build a Compose screen with MVVM pattern"
  • "Set up a Repository with offline-first architecture"
  • "Add navigation to my Android app"
  • "Configure multi-module Gradle setup"

Claude will follow the patterns and best practices defined in this skill.

Project Structure

claude-android-skill/
β”œβ”€β”€ SKILL.md                    # Main skill definition and quick reference
β”œβ”€β”€ references/                 # Detailed documentation
β”‚   β”œβ”€β”€ architecture.md         # UI, Domain, Data layers patterns
β”‚   β”œβ”€β”€ compose-patterns.md     # Jetpack Compose best practices
β”‚   β”œβ”€β”€ gradle-setup.md         # Build configuration & convention plugins
β”‚   β”œβ”€β”€ modularization.md       # Multi-module project structure
β”‚   └── testing.md              # Testing strategies and patterns
β”œβ”€β”€ assets/
β”‚   └── templates/              # Project templates
β”‚       β”œβ”€β”€ libs.versions.toml.template
β”‚       └── settings.gradle.kts.template
└── scripts/
    └── generate_feature.py     # Feature module generator script

Core Principles

This skill teaches Claude to follow these key Android development principles:

  1. Offline-first: Local database as source of truth, synchronized with remote data
  2. Unidirectional data flow: Events flow down, data flows up (UDF pattern)
  3. Reactive streams: Use Kotlin Flow for all data exposure
  4. Modular by feature: Each feature is self-contained with clear API boundaries
  5. Testable by design: Use interfaces and test doubles, avoid mocking frameworks

Reference Documentation

Quick Navigation

Topic File Description
Architecture architecture.md MVVM pattern, layers, repositories, use cases
Compose UI compose-patterns.md Screens, state hoisting, side effects, theming
Build Setup gradle-setup.md Convention plugins, version catalogs, configuration
Modularization modularization.md Module types, dependencies, feature structure
Testing testing.md Unit tests, UI tests, test doubles, strategies

Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              UI Layer                    β”‚
β”‚  (Compose Screens + ViewModels)          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚           Domain Layer                   β”‚
β”‚  (Use Cases - optional, for reuse)       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚            Data Layer                    β”‚
β”‚  (Repositories + DataSources)            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Module Types

app/                    # Application module
feature/
  β”œβ”€β”€ featurename/
  β”‚   β”œβ”€β”€ api/          # Public navigation contracts
  β”‚   └── impl/         # Internal implementation
core/
  β”œβ”€β”€ data/             # Repositories
  β”œβ”€β”€ database/         # Room DAOs & entities
  β”œβ”€β”€ network/          # Retrofit & API models
  β”œβ”€β”€ model/            # Domain models
  β”œβ”€β”€ ui/               # Reusable components
  β”œβ”€β”€ designsystem/     # Theme & design tokens
  └── testing/          # Test utilities

Features

Code Generation

The skill includes a Python script to generate feature modules:

python scripts/generate_feature.py settings \
  --package com.example.app \
  --path /path/to/project

This creates a complete feature module with:
- API module with navigation definitions
- Implementation module with Screen, ViewModel, UiState
- Gradle build files with proper dependencies
- Hilt dependency injection setup

Templates

Pre-configured templates for common Android project files:
- libs.versions.toml.template - Gradle version catalog
- settings.gradle.kts.template - Project settings

Standard Patterns

ViewModel Pattern

@HiltViewModel
class MyFeatureViewModel @Inject constructor(
    private val repository: MyRepository,
) : ViewModel() {
    val uiState: StateFlow<MyFeatureUiState> = repository
        .getData()
        .map { MyFeatureUiState.Success(it) }
        .stateIn(
            scope = viewModelScope,
            started = SharingStarted.WhileSubscribed(5_000),
            initialValue = MyFeatureUiState.Loading,
        )
}

Screen Pattern

@Composable
internal fun MyFeatureRoute(
    viewModel: MyFeatureViewModel = hiltViewModel(),
) {
    val uiState by viewModel.uiState.collectAsStateWithLifecycle()
    MyFeatureScreen(uiState = uiState)
}

Repository Pattern

interface MyRepository {
    fun getData(): Flow<List<MyModel>>
}

internal class OfflineFirstMyRepository @Inject constructor(
    private val dao: MyDao,
    private val api: MyNetworkApi,
) : MyRepository {
    override fun getData(): Flow<List<MyModel>> =
        dao.getAll().map { it.toModel() }
}

Technology Stack

This skill configures projects with:

  • Language: Kotlin
  • UI: Jetpack Compose
  • Architecture: MVVM with UDF
  • DI: Hilt
  • Database: Room
  • Network: Retrofit + Kotlinx Serialization
  • Async: Kotlin Coroutines + Flow
  • Testing: JUnit, Turbine, Compose Testing
  • Build: Gradle with Convention Plugins

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Based on patterns and practices from:
- NowInAndroid by Google
- Android Architecture Guidelines
- Jetpack Compose Best Practices

Resources

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.