.claude/skills/write-viewmodel/SKILL.md
Use when writing a new ViewModel or modifying an existing one in the Alkaa project. Triggers on tasks like "add a ViewModel", "create VM for X screen", "implement state handling", or "connect use case to UI".
npx skillsauth add igorescodro/alkaa write-viewmodelInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
ViewModels in Alkaa bridge domain use cases and Compose UI via cold flows and sealed state classes. They contain no business logic — only orchestration, mapping, and scope management.
data object for stateless states, data class for states with data, ImmutableList for list payloads → see references/CODE_PATTERNS.mdFlow<ViewState> by default; hot StateFlow only when multiple collectors share the same stream → see references/CODE_PATTERNS.mdreferences/CODE_PATTERNS.mdapplicationScope for DB mutations that survive ViewModel destruction; viewModelScope for UI-bound work → see references/CODE_PATTERNS.mdreferences/CODE_PATTERNS.mdFor unit test setup and fake patterns → see references/CODE_PATTERNS.md and the write-unit-tests skill.
| Situation | Scope |
|-----------|-------|
| DB insert / update / delete | applicationScope.launch { } |
| Network call that should persist | applicationScope.launch { } |
| Debounced UI updates | viewModelScope |
| Short-lived UI-bound work | viewModelScope |
| Mistake | Fix |
|---------|-----|
| Calling repository directly | Wrap in a use case first |
| Exposing StateFlow for a screen-scoped stream | Return cold Flow<ViewState> |
| Mapping models inline in ViewModel | Create a XxxMapper class |
| Using viewModelScope for DB writes | Use applicationScope.launch { } |
| Depending on another ViewModel | Extract shared logic into a use case |
| Testing with mocks | Write a XxxFake that implements the use case interface |
write-unit-tests skillwrite-composable skilldevelopment
A skill for reviewing Android code before it is pushed to production.
testing
Use when writing or modifying unit tests in the Alkaa project — triggers on tasks like "add a test", "write tests for X", "test this ViewModel", "cover this use case with tests", or "add unit test coverage".
testing
Use when writing or modifying UI/Compose instrumented tests in the Alkaa project — triggers on tasks like "add a UI test", "test this composable", "add instrumented test", "test this screen behavior".
documentation
Use when a new feature needs to persist data locally in Alkaa — triggers on tasks like "add database support", "create a new table", "store this data in SQLDelight", or when write-feature Phase 2 requires a new entity in the local database.