一键导入
room-entity-pattern
Room entity, DAO, mapper, and migration pattern guide. Use when adding or changing persistence models, join tables, and schema migrations.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Room entity, DAO, mapper, and migration pattern guide. Use when adding or changing persistence models, join tables, and schema migrations.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use ADB to connect devices, install Android debug builds, and troubleshoot deployment failures. Use for device detection errors, install failures, launch failures, package selection across flavors, and first-pass process checks. For deeper runtime investigation, prefer the Argent workflow.
Android platform/helper layer guide for AniTrend. Use when working in `:android:*` modules or deciding whether to reuse or extend existing Android-side helpers for configuration/theme, context or fragment utilities, notification permission flows, deep links, drawer/app-shell behavior, or other platform APIs.
Investigate Android runtime bugs with evidence-first workflows. Use for emulator targeting, logcat/AndroidRuntime/Timber inspection, Chucker HTTP/GraphQL payloads, UIAutomator hierarchy capture, Room database forensics, and root-cause analysis before changing code.
Capture quick Android UI evidence with explicit launches, UIAutomator dumps, and adb screenshots for fast visual debugging and reproducible repro notes.
Use when planning or thinking of AniTrend brand identity UI & UX covering compose screens, various surfaces, interaction-heavy UI, layout hierarchy, component decomposition, preview strategy, Material3 layering, or incremental product-facing refactors before coding.
Diagnose and fix silent empty-UI bugs caused by CacheRequest enum collisions in AniTrend. Use when a new offline-first source variant produces blank UI with no crash, no exception, and the Room tables have zero rows. Covers: cache_log collision diagnosis, ADB Room database forensics, WAL checkpoint, Chucker traffic check, CacheRequest isolation fix, and Koin factory update pattern.
| name | room-entity-pattern |
| description | Room entity, DAO, mapper, and migration pattern guide. Use when adding or changing persistence models, join tables, and schema migrations. |
Persistence follows a strict four-file pattern for each domain entity. Reading an existing
implementation (e.g., tag) is the fastest way to understand what to produce for a new entity.
data/src/main/kotlin/co/anitrend/data/tag/entity/TagEntity.kt — Room @Entity with
schema-aware query-builder annotationsdata/src/main/kotlin/co/anitrend/data/tag/entity/filter/TagQueryFilter.kt — dynamic Room
query filter built with the support-query-builder DSLdata/src/main/kotlin/co/anitrend/data/tag/ — full package: entity, DAO, mapper, source,
repository, usecase, koinThese rules apply specifically when a table uses a Room-autogenerated surrogate PK (common for many-to-many join tables and local-only caches). They do not apply to entities whose PK is server-provided.
@PrimaryKey(autoGenerate = true) val id: Long? = null.IEntity<Long> when the surrogate PK is Long?; implement IEntity<Int> only when
the surrogate PK is explicitly Int?.@Index(value = ["tag_id", "media_id"], unique = true).@Insert(onConflict = REPLACE) for batch upserts keyed by the composite columns, not
the surrogate PK.id in interfaces or mapper inputs — Room fills it after
insert.When making schema-impacting changes:
DATABASE_SCHEMA_VERSION in the Room database class.@AutoMigration(from = X, to = Y) for additive-only changes such as new tables or new
columns with safe defaults. Provide a manual Migration object for renames, type changes,
constraint changes, or any data transform that @AutoMigration cannot express.data/schemas/.../AniTrendStore/<version>.json; verify
nullability, indices, and identity hash are as expected.from version) to confirm migration applies
without crashes.| File | Responsibility |
|---|---|
XxxEntity.kt | @Entity data class; mirrors DB columns; uses query-builder annotations |
XxxDao.kt | @Dao interface; @Query, @Insert(onConflict=REPLACE), @Delete |
XxxMapper.kt | Converts network model → entity; calls DAO upsert in persist() |
XxxRepository.kt | Implements domain IXxxRepository; wires source + controller into DataState |