repository-room

Implement Room-backed repositories with Flow streams and Hilt bindings.

Updated Dec 4, 2025
One-click install
npx skills add https://github.com/thinhtt264/Snaplet-App --skill repository-room
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: repository-room
Source: https://github.com/thinhtt264/Snaplet-App/tree/main/.cursor/skills/repository-room
Command: npx skills add https://github.com/thinhtt264/Snaplet-App --skill repository-room

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a robust pattern for implementing a repository layer backed by Room DAO, enforcing a clear Interface + Implementation separation and proper observable streams with Flow, while avoiding remote API concerns.

Core Features & Use Cases

  • Interface + Implementation: Define XxxRepository with a Flow-based observable and suspend one-shot operations, paired with XxxRepositoryImpl.
  • Room + DAO integration: Directly use DAO methods inside suspend calls; expose Flow from DAO for reactive streams.
  • Guided architecture: Includes Hilt binding pattern and a strict rule set to prevent safeApiCall usage for Room.
  • Use Case: When building an Android app with local persistence, you can rely on the repository-room skeleton to ensure consistent architecture and testability.

Quick Start

Create XxxRepository interface and XxxRepositoryImpl that delegate to XxxDao, wire via RepositoryModule.

Frequently Asked Questions about repository-room

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

FAQPage Schema
How do I implement a Room repository with Flow in Kotlin for local persistence?▼

To implement a Room repository with Flow, define a repository interface exposing Flow for observable reads and suspend functions for writes, then create an implementation class that delegates directly to DAO methods.

Why should I avoid safeApiCall when using Room DAO in an Android repository?▼

You should avoid safeApiCall for Room because local database transactions do not require network-style error wrapping; Room queries inherently handle local persistence safely, making safeApiCall redundant for DAO operations.

What's the best way to bind a Room repository interface to its implementation in Android?▼

The best way to bind a Room repository interface to its implementation is using Hilt dependency injection, which provides a strict module wiring pattern to connect the repository interface and implementation cleanly.

Does this Room repository pattern support remote API calls alongside local DAO operations?▼

No, this Room repository pattern explicitly excludes remote API concerns, focusing solely on local Room-backed persistence with Flow-based observable streams and suspend one-shot write operations.

When do I need to use Flow versus suspend functions in a Room repository?▼

Use Flow in a Room repository for observable data streams that emit continuously from DAO queries, and use suspend functions for one-shot write operations like inserts or updates that execute once.