android-data-layer

Implements Android data layers with Repository pattern, Room database, and offline-first synchronization.

1|Updated Jun 1, 2026
One-click install
npx skills add https://github.com/chmonya-inc/dnd-manager --skill android-data-layer-chmonya-inc
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: android-data-layer
Source: https://github.com/chmonya-inc/dnd-manager/tree/main/.agents/skills/android-data-layer
Command: npx skills add https://github.com/chmonya-inc/dnd-manager --skill android-data-layer-chmonya-inc

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building an Android data layer that correctly coordinates local Room storage with remote APIs is error-prone: developers often leak DTOs and network exceptions into ViewModels, choose wrong DAO return types, or skip offline-first guarantees. This Skill provides proven patterns and anti-patterns for structuring repositories, Room databases, and synchronization logic. ## Core Features & Use Cases - Repository Pattern Guidance: Establishes the repository as the single source of truth, with proper error boundaries that map IOException and HttpException into domain-level DataError types. - Room Database Setup: Covers entities, DAOs with correct Flow vs suspend return types, database classes with schema export, and Hilt singleton provisioning. - Offline-First Strategies: Implements stale-while-revalidate reads and the outbox pattern with WorkManager for writes that survive process death. - Use Case: When adding a news feed feature to an Android app, use this Skill to scaffold the repository, Room DAO, DTO-to-domain mapping, and a WorkManager sync worker that keeps the UI updated from the local database. ## Quick Start Implement an offline-first data layer for my articles feature with a Room database, a repository that maps network DTOs to domain models, and a WorkManager sync worker.

Frequently Asked Questions about android-data-layer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement the Repository pattern in Android with Room?▼

Create a repository that exposes a Flow from the Room DAO as the single source of truth and a suspend refresh function that fetches from the API and upserts into the database. Map DTOs to entities before writing and entities to domain models before returning to ViewModels.

Should Room DAO methods return Flow or suspend functions?▼

Return Flow for queries the UI observes continuously, since Room re-emits whenever the table changes. Use suspend functions for one-shot reads and all mutations like inserts, updates, and deletes.

How do I implement offline-first sync in Android?▼

Use stale-while-revalidate for reads: show local database data immediately while triggering a network refresh in parallel. For writes, apply the outbox pattern by saving changes locally first and syncing with a WorkManager job that survives process death.

Should ViewModels handle IOException and HttpException from Retrofit?▼

No, the repository should act as the error boundary by catching IOException and HttpException and converting them into domain error types like a sealed DataError class. This keeps network implementation details out of the ViewModel layer.

What naming convention should I use for Room entity classes?▼

Common conventions are the Entity suffix (e.g., ArticleEntity) following Room tradition, or a Cached prefix (e.g., CachedArticle) to abstract the storage mechanism. Match any existing project convention, otherwise default to the Entity suffix.