agentleFS
liuyi0808liuyi0808/android-review/skills/architecture/SKILL.md

architecture

Skill17 starsChanged 9 months agoMITView on GitHub

Android application architecture standards using Clean Architecture, MVVM/MVI patterns, Hilt dependency injection, and modularization. Use when: designing app structure, creating ViewModel/Repository/UseCase classes, setting up Hilt DI modules, planning module boundaries, reviewing layer dependencies, implementing offline-first data patterns, defining error handling strategy, or starting a new Android feature module.

136 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use intelligent-routing, bash-linux and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • SKB3002Skill

    intelligent-routing

    Automatic agent selection and intelligent task routing. Analyzes user requests and automatically selects the best specialist agent(s) without requiring explicit user mentions.

    Also in 6 projects that use this

  • xenitV1Skill

    bash-linux

    Bash/Linux terminal patterns. Critical commands, piping, error handling, scripting. Use when working on macOS or Linux systems.

    Also in 8 projects that use this

  • xenitV1Skill

    red-team-tactics

    Red team tactics principles based on MITRE ATT&CK. Attack phases, detection evasion, reporting.

    Also in 8 projects that use this

  • SKB3002Skill

    nextjs-react-expert

    React and Next.js performance optimization from Vercel Engineering. Use when building React components, optimizing performance, eliminating waterfalls, reducing bundle size, reviewing code for performance issues, or implementing server/client-side optimizations.

    Also in 3 projects that use this

  • +8 more from xenitV1

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 2 are distinctive, and 6 are very specific to this project.

  • 0

    Common

    Most of the 118 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use Result<T> for operations that can fail.

    line 123
  2. Very specific:

    Use @Binds for interface→implementation bindings (more efficient than @Provides).

    line 133
  3. Very specific:

    Use correct @InstallIn scope (SingletonComponent, ViewModelComponent, ActivityComponent).

    line 134
  4. Very specific:

    NEVER inject Activity or Fragment into non-UI classes.

    line 135
  5. Very specific:

    Use @ApplicationContext when Context is needed in singletons.

    line 136
  6. Very specific:

    Use Result<T> for all fallible operations in domain/data layers.

    line 145
  7. Distinctive:

    NEVER silently swallow exceptions — always log or report.

    line 148
  8. Distinctive:

    Use sealed class hierarchy for typed error handling.

    line 149

“Common” is measured: kept by at least 6 in 10 of the 118 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Android Architecture Standards

Enforce Clean Architecture patterns with MVVM/MVI for Android Kotlin applications.

Architecture Review Process

Evaluate code against ALL layers. Output findings as:

[ARCH-XXXXX] severity: CRITICAL | HIGH | MEDIUM | LOW
  Finding: <architecture violation or improvement>
  Location: <file:line>
  Fix: <concrete refactoring guidance>

1. Layer Architecture

Three Layers (Mandatory)

┌─────────────────────────────────┐
│        Presentation Layer       │  UI, ViewModel, UiState
│         (app / feature)         │
├─────────────────────────────────┤
│          Domain Layer           │  UseCase, Domain Model, Repository Interface
│           (optional)            │
├─────────────────────────────────┤
│           Data Layer            │  Repository Impl, DataSource, DTO, API, DB
│       (data / network)          │
└─────────────────────────────────┘

Dependency Rule

Dependencies flow INWARD only:

  • Presentation → Domain → Data (allowed)
  • Data → Domain (NEVER)
  • Presentation → Data directly (AVOID, use Domain)

Package Structure

com.example.app/
├── di/                          # Hilt modules
│   ├── AppModule.kt
│   ├── NetworkModule.kt
│   └── DatabaseModule.kt
├── data/
│   ├── local/
│   │   ├── dao/                 # Room DAOs
│   │   ├── entity/              # Room entities
│   │   └── AppDatabase.kt
│   ├── remote/
│   │   ├── api/                 # Retrofit interfaces
│   │   ├── dto/                 # Data Transfer Objects
│   │   └── interceptor/
│   ├── mapper/                  # DTO ↔ Domain mappers
│   └── repository/              # Repository implementations
├── domain/
│   ├── model/                   # Domain models (pure Kotlin)
│   ├── repository/              # Repository interfaces
│   └── usecase/                 # Use cases
└── ui/                          # Presentation
    ├── navigation/
    ├── theme/
    ├── component/               # Reusable composables
    └── screen/
        ├── login/
        │   ├── LoginScreen.kt
        │   ├── LoginViewModel.kt
        │   └── LoginUiState.kt
        └── home/
            ├── HomeScreen.kt
            ├── HomeViewModel.kt
            └── HomeUiState.kt

Reference Guide — Load on Demand

Each reference file contains full code examples, patterns, and detailed checklists. Read the relevant file when reviewing that layer.

#Reference FileContentWhen to Load
1references/presentation.mdViewModel, UiState, Actions, Events, Screen ComposableReviewing presentation layer or ViewModel patterns
2references/domain.mdUseCase pattern, Domain Model, Repository InterfaceReviewing domain layer or use case design
3references/data.mdRepository Impl, Mapper, Offline-First patternReviewing data layer or repository implementation
4references/di.mdHilt Module Structure, scope rulesSetting up or reviewing dependency injection
5references/modularization.mdModule types, dependency graph, when to modularizePlanning module boundaries
6references/error-handling.mdError pattern, exception hierarchyDesigning error handling strategy

Rules Summary

Presentation Layer

  1. ViewModel NEVER references Context, Activity, or View.
  2. ViewModel exposes StateFlow (NOT LiveData for new code).
  3. UI state is a single immutable data class per screen.
  4. Actions from UI → ViewModel via sealed interface.
  5. One-time events via Channel.receiveAsFlow().
  6. Screen composable splits into: wired (with ViewModel) + stateless content.

Domain Layer

  1. Domain layer has ZERO Android dependencies (pure Kotlin).
  2. UseCase has single invoke operator (one operation per UseCase).
  3. Repository interfaces defined in domain, implemented in data.
  4. Domain models are independent of DTO/Entity (separate mapping).
  5. Use Result<T> for operations that can fail.

Data Layer

  1. Repository is the single source of truth.
  2. DTO (API response) ≠ Entity (Room) ≠ Domain Model. Map between them.
  3. Offline-first: Room as source of truth, network refreshes in background.
  4. API calls wrapped in runCatching — NEVER throw unhandled exceptions.
  5. DataSource abstraction: LocalDataSource + RemoteDataSource → Repository.

Dependency Injection (Hilt)

  1. Use @Binds for interface→implementation bindings (more efficient than @Provides).
  2. Use correct @InstallIn scope (SingletonComponent, ViewModelComponent, ActivityComponent).
  3. NEVER inject Activity or Fragment into non-UI classes.
  4. Use @ApplicationContext when Context is needed in singletons.

Modularization

  1. Feature modules NEVER depend on other feature modules.
  2. Feature modules depend on :core:domain and :core:ui only.
  3. :core:domain has ZERO Android dependencies.
  4. :app module is thin — only navigation and DI wiring.

Error Handling

  1. Use Result<T> for all fallible operations in domain/data layers.
  2. Map network exceptions to domain exceptions in Repository.
  3. Present user-friendly messages in ViewModel (NEVER raw exception messages).
  4. NEVER silently swallow exceptions — always log or report.
  5. Use sealed class hierarchy for typed error handling.

Checklists

Presentation

  • One ViewModel per screen
  • UiState is immutable data class
  • Actions modeled as sealed interface
  • Events via Channel (not StateFlow)
  • collectAsStateWithLifecycle used
  • No Android framework imports in ViewModel (except SavedStateHandle)
  • Screen split: wired container + stateless content

Domain

  • Domain models have no framework annotations
  • UseCase is single-purpose with invoke operator
  • Repository interface in domain package
  • No Android imports in domain layer
  • Result type for fallible operations

Data

  • DTO, Entity, Domain Model are separate classes
  • Mappers exist between all data types
  • Repository wraps API calls in runCatching
  • Room as single source of truth (offline-first)
  • No API/Room types leak to domain/presentation

Dependency Injection

  • @HiltAndroidApp on Application class
  • @AndroidEntryPoint on Activities/Fragments
  • @HiltViewModel on ViewModels
  • Interfaces bound with @Binds (not @Provides)
  • Correct scope for each dependency
  • No manual dependency creation outside DI

Modularization

  • No circular dependencies between modules
  • Feature modules don't depend on each other
  • Domain module has no Android dependencies
  • Build times acceptable (<2 min for incremental)
  • API boundaries defined between modules

Error Handling

  • Result type used for fallible operations
  • Exceptions mapped to domain types in Repository
  • User-friendly error messages in ViewModel
  • No raw exception messages shown to user
  • Global error handler for uncaught exceptions

For Compose UI patterns, see the compose-ui skill. For OWASP security audit, see the security-audit skill.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.