AGENT SKILL

android-architect

Coaches modern Android app architecture using Clean Architecture, MVVM, and Repository patterns. Use when creating new Android modules, features, ViewModels, repositories, data layers, navigation, dependency injection with Hilt, Jetpack Compose UI, offline-first sync, convention plugins, or structuring a multi-module Kotlin Android project. Covers Room, Retrofit, Proto DataStore, Coroutines Flow, WorkManager, and modularization with API/impl splits.

License 许可
Apache-2.0
最近更新
2026-10-31
Stars
★ 0
Forks
1

01 前言 Front Matter

name
android-architect
license
Apache-2.0
metadata
{ "author": "luis-suchobits", "version": "1.0", "based-on": "google/nowinandroid" }
description
Coaches modern Android app architecture using Clean Architecture, MVVM, and Repository patterns. Use when creating new Android modules, features, ViewModels, repositories, data layers, navigation, dependency injection with Hilt, Jetpack Compose UI, offline-first sync, convention plugins, or structuring a multi-module Kotlin Android project. Covers Room, Retrofit, Proto DataStore, Coroutines Flow, WorkManager, and modularization with API/impl splits.
compatibility
Requires Android Studio, Kotlin, Gradle with version catalogs

02 资源文件 8

03 SKILL.md 正文

Android Architect — Modern Android Architecture Guide

Patterns and templates for production-grade, multi-module Android apps with Kotlin and Jetpack Compose. All code examples use {Feature}, {Item}, {Target} as placeholders — substitute your actual names.

Architecture Overview

The architecture follows Clean Architecture with MVVM and the Repository pattern. Data flows unidirectionally:

Compose UI → ViewModel → UseCase (optional) → Repository → DataSource (DB / Network / DataStore)

Every layer depends only on the layer below it. The UI layer never touches data sources directly.

Module Structure

app/                  # Entry point, wires features together
core/                 # Shared libraries (no feature logic)
  ├── model/          # Plain data classes shared across layers
  ├── data/           # Repository interfaces + implementations
  ├── domain/         # Use cases (optional, for cross-repo logic)
  ├── database/       # Room entities, DAOs, type converters
  ├── network/        # Network data source interfaces + implementations
  ├── datastore/      # Proto DataStore preferences
  ├── designsystem/   # Material 3 theme, shared components
  ├── ui/             # Shared Compose utilities
  ├── navigation/     # Navigator, NavKey abstractions
  ├── common/         # Dispatcher qualifiers, extensions
  └── testing/        # Shared test doubles (fake repositories, rules)
feature/              # One module per screen/flow
  ├── {feature}/
  │   ├── api/        # Public NavKey + entry composable
  │   └── impl/       # ViewModel, screens, DI — private
  └── ...

Key rule: Feature modules depend on core, never on other features. The app module wires features together.

API / Impl Split

Each feature has two submodules:

  • api/ — Exports a NavKey data class and an entry composable. Other modules depend on this to navigate without coupling to internals.
  • impl/ — Contains the ViewModel, screens, and Hilt bindings. Only app includes impl modules.

UI Layer

For complete screen patterns with code templates, see screens reference.

Summary of the screen architecture:

  • Route/Screen split: {Feature}Route (stateful, owns ViewModel) wraps {Feature}Screen (stateless, preview-friendly).
  • Sealed UI state: {Feature}UiState with Loading, Error, Success variants.
  • Action sealed interface: {Feature}Action models all user interactions.
  • StateFlow with stateIn(SharingStarted.WhileSubscribed(5_000)).
  • Previews for every state variant.

Data Layer

Three-Tier Model Separation

Never reuse a single model class across layers:

Layer Naming Annotation Module
Network Network{Item} @Serializable (kotlinx) core:network
Database {Item}Entity @Entity (Room) core:database
Domain/UI {Item} None core:model

Write mapping extensions (asEntity(), asExternalModel()) next to each model.

Repository Pattern (Offline-First)

class OfflineFirst{Item}Repository @Inject constructor(
    private val dao: {Item}Dao,
    private val network: AppNetworkDataSource,
) : {Item}Repository {

    override fun get{Items}(): Flow<List<{Item}>> =
        dao.get{Items}().map { it.map({Item}Entity::asExternalModel) }
}
  • Expose Flow<T> from repositories for reactive updates.
  • Local database (Room) is the source of truth.
  • Network syncs into the database; UI observes the database.

For detailed data layer patterns, see data-models reference (coming soon).

Dependency Injection (Hilt)

@Module
@InstallIn(SingletonComponent::class)
abstract class DataModule {
    @Binds
    abstract fun binds{Item}Repository(impl: OfflineFirst{Item}Repository): {Item}Repository
}
  • @Binds for interface→implementation. @Provides only for complex construction.
  • Dispatcher qualifiers: @Dispatcher(IO), @Dispatcher(Default).
  • Feature impl modules auto-apply Hilt via convention plugin.

Convention Plugins

Use a build-logic/ included build to share Gradle config:

Plugin Purpose
AndroidLibraryConventionPlugin Library defaults + resource prefixing
AndroidFeatureImplConventionPlugin Auto-applies Hilt, lifecycle, navigation deps
AndroidFeatureApiConventionPlugin Thin public interface module
AndroidLibraryComposeConventionPlugin Compose compiler config
AndroidRoomConventionPlugin Room schema setup
HiltConventionPlugin Hilt KSP setup

Use a Gradle version catalog (libs.versions.toml) for all dependency versions.

Testing

  • Fakes over mocks: Create test doubles in core:testing using MutableSharedFlow(replay=1).
  • MainDispatcherRule: Swaps Dispatchers.Main with a test dispatcher.
  • ViewModel tests: Construct with fakes, use runTest + advanceUntilIdle().
  • Database tests: Room in-memory database in instrumentation tests.
  • UI tests: Screenshot testing via Roborazzi; testTag modifiers for element selection.

Reference Guides

Detailed templates and code examples for each layer:

  • Screens & Compose UI — Route/Screen split, UI state, actions, previews
  • ViewModels — StateFlow, combine, events, use cases
  • Repositories — Offline-first, sync, network monitor
  • Data Models — Three-tier models, mapping, Room DAOs, FTS
  • Hilt DI — Modules, qualifiers, scopes, flavor bindings
  • Navigation — NavKey, EntryProvider, Navigator, deep links
  • Convention Plugins — Build logic, plugin templates, version catalog
  • Testing — Fakes, ViewModel tests, DAO tests, screenshot tests

04 同仓库更多 Skills

Darshan8610
Darshan8610/Dynamic-Island

security-review

Security code review for vulnerabilities. Use when asked to "security review", "find vulnerabilities", "check for security issues", "audit security", "OWASP review", or review code for injection, XSS, authentication, authorization, cryptography issues. Provides systematic review with confidence-based reporting.

★ 0
Darshan8610
Darshan8610/Dynamic-Island

security-model

Define, review, or update SECURITY_MODEL.md files that tell security review tools a repository's threat model, trust boundaries, invariants, reportable finding classes, and exclusions. Use when asked to "write a security model", "threat model this repo for scanners", "define security review scope", "what counts as a vulnerability here", "update SECURITY_MODEL.md", "why did the scanner flag or miss this", or to check whether existing security guidance still matches the code. Not for running a security review or editing the SECURITY.md disclosure policy.

★ 0
Darshan8610
Darshan8610/Dynamic-Island

mobile-harness

Portable Android and iOS device-control harness for agents. Use when an agent needs to control or automate Android/iOS devices — tap, swipe, screenshot, app control — locally (ADB/Portal/Simulator) or on Mobilerun cloud devices.

★ 0
Darshan8610
Darshan8610/Dynamic-Island

compose-agent

Helps AI coding assistants write modern Jetpack Compose: correct state, side effects, performance-aware modifiers, Navigation 3, Paging 3 in Compose, coroutines on lifecycle, animations, UI tests, focus/keyboard navigation, Compose Multiplatform boundaries, idiomatic Kotlin, and well-shaped composable APIs. Targets the mistakes LLMs actually make in Compose code. Use when reading, writing, or reviewing Compose projects.

★ 0
Darshan8610
Darshan8610/Dynamic-Island

material-design-3-ui

Design, redesign, review, or implement user interfaces using Google Material Design 3 (M3), Material You, and optional Material 3 Expressive principles. Use for UI/UX screens, app flows, design systems, component selection, theming, responsive/adaptive layouts, accessibility audits, Figma-ready specifications, or developer handoff where Material Design 3 is required.

★ 0
Darshan8610
Darshan8610/Dynamic-Island

web-design-guidelines

Web platform design and accessibility guidelines. Use when building web interfaces, auditing accessibility, implementing responsive layouts, or reviewing web UI code. Triggers on tasks involving HTML, CSS, web components, WCAG compliance, responsive design, or web performance.

★ 0