android-data-layerlisted
Install: claude install-skill lenorebreakneck630/claude-zero-to-hero-android-KMP
# Android / KMP Data Layer
## Error Handling
This skill uses `Result<T, E>`, `DataError`, and the extension helpers defined in the **android-error-handling** skill. Refer to that skill for the full `Result` wrapper, `DataError` sealed interface, and `map`/`onSuccess`/`onFailure`/`asEmptyResult` extensions.
---
## Data Source vs Repository
- **Data source** — accesses a single data source (local DB, remote API, file system). Most classes in the data layer are data sources.
- **Repository** — combines multiple data sources (e.g., a remote API + a local DB for offline-first). Only use the term "repository" when the class genuinely coordinates multiple sources.
```kotlin
// Single source → data source
interface NoteLocalDataSource {
suspend fun getNotes(): Result<List<Note>, DataError.Local>
suspend fun insertNote(note: Note): EmptyResult<DataError.Local>
}
interface NoteRemoteDataSource {
suspend fun fetchNotes(): Result<List<Note>, DataError.Network>
}
// Multiple sources → repository
interface NoteRepository {
suspend fun getNotes(): Result<List<Note>, DataError>
suspend fun sync(): EmptyResult<DataError>
}
```
## Domain Layer Contracts
- Pure Kotlin — no Android/framework imports.
- Contains: domain models, data source/repository **interfaces**, error types.
- **Every data source or repository used by a ViewModel must have an interface in `domain`** — enforces that `presentation` never depends on `data`, and enables testing.
---
## DTOs and