agentleFS
prasad-vennamprasad-vennam/Awesome-Android-AI-Agent-Skills/skills/android-clean-architecture/SKILL.md

android-clean-architecture

Skill11 starsChanged 8 months agoMITView on GitHub

Use when designing the architecture, data layer, domain models, or business logic for Android apps.

10 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use everything-claude-code, perl-security 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.
  • InfopibeSkill

    everything-claude-code

    Also in 3 projects that use this

  • InfopibeSkill

    perl-security

    Comprehensive Perl security covering taint mode, input validation, safe process execution, DBI parameterized queries, web security (XSS/SQLi/CSRF), and perlcritic security policies.

    Also in 3 projects that use this

  • saxon-ySkill

    configure-ecc

    Interactive installer for Everything Claude Code — guides users through selecting and installing skills and rules to user-level or project-level directories, verifies paths, and optionally optimizes installed files.

    Also in 3 projects that use this

  • +9 more from Infopibe

The file

Show its rules and text

We split this skill into the rules it gives an agent

16 rules. 0 are common, 4 are distinctive, and 12 are very specific to this project.

  • 0

    Common

    Most of the 10 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 12

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Pattern: Always use Jetpack ViewModel.

    line 34
  2. Very specific:

    State: Use MutableStateFlow in ViewModel.

    line 35
  3. Distinctive:

    MVI/MVVM: Prefer State + Events + Effects for complex screens.

    line 36
  4. Very specific:

    Anti-Pattern (No Stubs): NEVER generate stubbed empty callbacks (e.g., onClicked = { /* Future implementation */ }) when scaffolding.

    line 37
  5. Distinctive:

    Navigation: Use Compose Navigation with Safe Args (Type-safe routing via Kotlinx Serialization) instead of manual screen swapping.

    line 38
  6. Very specific:

    Rule: NO Android dependencies (except maybe @Inject).

    line 42
  7. Very specific:

    CRITICAL ANTI-HALLUCINATION GUARD: NEVER assume or guess the properties of a data class (e.g., guessing a TodoItem has a dueDate).

    line 52
  8. Very specific:

    Room TypeConverters (CRITICAL): If your domain model contains non-primitive types (e.g., LocalDateTime, Enums, Custom Objects), you MUST …

    line 59
  9. Very specific:

    Rule: Create a class inheriting from Application and annotate it with @HiltAndroidApp.

    line 66
  10. Very specific:

    Use @HiltViewModel for ViewModels.

    line 76
  11. Very specific:

    Use @AndroidEntryPoint for Activities/Fragments (if any).

    line 77
  12. Very specific:

    Use @Inject constructor for Use Cases and Repositories.

    line 78
  13. Very specific:

    Create @Module and @InstallIn(SingletonComponent::class) for platform dependencies.

    line 79
  14. Very specific:

    Unit Tests: Place in test/. Use MockK for mocking interfaces.

    line 83
  15. Very specific:

    Test Coroutines: Use runTest and TestDispatcher.

    line 84
  16. Distinctive:

    Fakes vs Mocks: Prefer Fakes for complex Data sources and Mocks for simple verification.

    line 85

“Common” is measured: kept by at least 6 in 10 of the 10 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 Clean Architecture Excellence 🏗️

Standardized architectural patterns for scalable, testable, and maintainable Android applications.

⚡ When to Use

  • App Structure: Planning or refactoring the module/package layout.
  • Data Fetching: Implementing Retrofit or Room repositories.
  • Business Logic: Writing Use Cases or Interactors.
  • UI Architecture: Choosing between MVI, MVVM, or custom patterns.
  • State Management: Consuming data from Flow/StateFlow in ViewModels.

🏗️ The Three Pillars

1. Presentation Layer (UI & ViewModels)

  • Pattern: Always use Jetpack ViewModel.
  • State: Use MutableStateFlow in ViewModel. In Compose UI, ALWAYS collect using collectAsStateWithLifecycle() (requires androidx.lifecycle:lifecycle-runtime-compose). NEVER use collectAsState() as it wastes resources in the background.
  • MVI/MVVM: Prefer State + Events + Effects for complex screens.
  • Anti-Pattern (No Stubs): NEVER generate stubbed empty callbacks (e.g., onClicked = { /* Future implementation */ }) when scaffolding. If tasked to build a feature, ALWAYS implement the full event flow from UI to ViewModel to Repository.
  • Navigation: Use Compose Navigation with Safe Args (Type-safe routing via Kotlinx Serialization) instead of manual screen swapping.

2. Domain Layer (The Core)

  • Rule: NO Android dependencies (except maybe @Inject). Pure Kotlin.
  • Use Cases: Each Use Case should have a single responsibility.

    class GetUserUseCase @Inject constructor(private val repository: UserRepository) {
        operator fun invoke(id: String): Flow<User> = repository.getUser(id)
    }
  • Models: Pure Kotlin data classes (Domain-specific).
  • CRITICAL ANTI-HALLUCINATION GUARD: NEVER assume or guess the properties of a data class (e.g., guessing a TodoItem has a dueDate). You MUST explicitly read the data classes in domain/model/ before writing ViewModel or Repository mapping logic to prevent Unresolved reference or constructor errors.

3. Data Layer (Sources & Repositories)

  • Pattern: Repository as a single source of truth.
  • DTOs: Data Transfer Objects (e.g., Json objects from Retrofit). Always map DTOs to Domain Models before passing to the Domain Layer.
  • Sources: Remote (Retrofit/Ktor) and Local (Room/DataStore).
  • Room TypeConverters (CRITICAL): If your domain model contains non-primitive types (e.g., LocalDateTime, Enums, Custom Objects), you MUST create a @TypeConverter class and explicitly register it on the @Database class before compiling. Room cannot natively store them!

💉 Dependency Injection (Hilt)

Hilt is the standard DI library. Ensure the following foundational setup is ALWAYS present:

1. Mandatory Application Class

  • Rule: Create a class inheriting from Application and annotate it with @HiltAndroidApp.
    @HiltAndroidApp
    class BaseApplication : Application()

2. Manifest Registration

  • Rule: Register your application class in AndroidManifest.xml using android:name=".BaseApplication".

3. Usage Patterns

  • Use @HiltViewModel for ViewModels.
  • Use @AndroidEntryPoint for Activities/Fragments (if any).
  • Use @Inject constructor for Use Cases and Repositories.
  • Create @Module and @InstallIn(SingletonComponent::class) for platform dependencies.

🧪 Testing Strategy

  • Unit Tests: Place in test/. Use MockK for mocking interfaces.
  • Test Coroutines: Use runTest and TestDispatcher.
  • Fakes vs Mocks: Prefer Fakes for complex Data sources and Mocks for simple verification.

🚀 Modern Reactive Flows

  • StateFlow: For state that needs initial value and persistence.
  • SharedFlow: For one-off events (e.g., Navigation, Snackbar).
  • Error Handling: Use a Result wrapper or Resource object to encapsulate Success/Error states.

🔗 Related Resources

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.