implementing-android-code
БесплатноБез исполняемых скриптовНе проверенThis skill should be used when implementing Android code in Bitwarden. Covers critical patterns, gotchas, and anti-patterns unique to this codebase. Triggered…
от bitwarden★ 9 728 звёзд на GitHubОб этом скилле
Implementing Android Code - Bitwarden Quick Reference
This skill provides tactical guidance for Bitwarden-specific patterns. For comprehensive architecture decisions and complete code style rules, consult docs/ARCHITECTURE.md and docs/STYLE_AND_BEST_PRACTICES.md.
Critical Patterns Reference
A. ViewModel Implementation (State-Action-Event Pattern)
All ViewModels follow the State-Action-Event (SAE) pattern via BaseViewModel<State, Event, Action>.
Key Requirements:
- Annotate with
@HiltViewModel - ViewModels that need navigation arguments receive their route via assisted injection
(
@HiltViewModel(assistedFactory = ...),@AssistedInject constructor(@Assisted route: XGraph.XRoute)) - State class MUST be
@Parcelize data class : Parcelable - Implement
handleAction(action: A)- MUST be synchronous - Post internal actions from coroutines using
sendAction() - Save/restore state via
SavedStateHandle[KEY_STATE] - Private action handlers:
private fun handle*naming convention
Template: See ViewModel template
Pattern Summary:
@HiltViewModel
class ExampleViewModel @Inject constructor(
savedStateHandle: SavedStateHandle,
private val repository: ExampleRepository,
) : BaseViewModel<ExampleState, ExampleEvent, ExampleAction>(
initialState = savedStateHandle[KEY_STATE] ?: ExampleState(),
) {
init {
stateFlow.onEach { savedStateHandle[KEY_STATE] = it }.launchIn(viewModelScope)
}
override fun handleAction(action: ExampleAction) {
// Synchronous dispatch only
when (action) {
is Action.Click -> handleClick()
is Action.Internal.DataReceived -> handleDataReceived(action)
}
}
private fun handleClick() {
viewModelScope.launch {
val result = repository.fetchData()
sendAction(Action.Internal.DataReceived(result)) // Post internal action
}
}
private fun handleDataReceived(action: Action.Internal.DataReceived) {
mutableStateFlow.update { it.copy(data = action.result) }
}
}
ViewModel with navigation arguments (assisted injection):
@HiltViewModel(assistedFactory = ExampleViewModel.Factory::class)
class ExampleViewModel @AssistedInject constructor(
@Assisted route: ExampleGraph.ExampleRoute,
savedStateHandle: SavedStateHandle,
private val repository: ExampleRepository,
) : BaseViewModel<ExampleState, ExampleEvent, ExampleAction>(
initialState = savedStateHandle[KEY_STATE] ?: ExampleState(userId = route.userId),
) {
/**
* Factory for creating an [ExampleViewModel] for a specific [ExampleGraph.ExampleRoute].
*/
@AssistedFactory
interface Factory {
/**
* Creates an [ExampleViewModel] for the given [route].
*/
fun create(route: ExampleGraph.ExampleRoute): ExampleViewModel
}
// ...
}
Reference:
ui/src/main/kotlin/com/bitwarden/ui/platform/base/BaseViewModel.kt(seehandleActionmethod)app/src/main/kotlin/com/x8bit/bitwarden/ui/auth/feature/login/LoginViewModel.kt(see class declaration)app/src/main/kotlin/com/x8bit/bitwarden/ui/vault/feature/item/VaultItemViewModel.kt(assisted injection of the route)
Critical Gotchas:
- ❌ NEVER update
mutableStateFlowdirectly inside coroutines - ✅ ALWAYS post internal actions from coroutines, update state in
handleAction() - ❌ NEVER forget
@IgnoredOnParcelfor sensitive data (causes security leak) - ✅ ALWAYS use
@Parcelizeon state classes for process death recovery - ✅ State restoration happens automatically if properly saved to
SavedStateHandle
B. Navigation Implementation (Navigation 3, Type-Safe)
All navigation uses Navigation 3 with type-safe @Serializable routes. Every NavDisplay
displays one navigation graph: a @Serializable sealed class {Name}Graph : NavKey whose nested
subclasses are its routes (e.g. AuthGraph.LoginRoute). The back stack is owned by a
NavigationController<{Name}Graph> (ui/.../platform/navigation/NavigationController.kt); never
touch a NavBackStack directly. A route may host a nested graph (e.g. RootNavGraph.AuthRoute
hosts the AuthGraph, each nav bar tab hosts its own graph).
Pattern Structure:
@Serializableroute nested in the graph of theNavDisplaythat shows the screen, holding every argument (any@Serializabletype)EntryProviderScope<{Name}Graph>.{screen}Destination()extension that adds theentry, declares its transitions in metadata, and creates the ViewModel for the route (assisted injection)NavigationController<{Name}Graph>.navigateTo{Screen}()extension for navigation calls- Groups of related destinations (a "flow") are added with
EntryProviderScope<{Name}Graph>.{flow}Destinations(navigationController), and a route hosting a nested graph is added with
Установить implementing-android-code в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл implementing-android-code?
This skill should be used when implementing Android code in Bitwarden. Covers critical patterns, gotchas, and anti-patterns unique to this codebase. Triggered by "How do I implement a ViewModel?", "Create a new screen", "Add navigation", "Write a repository", "BaseViewModel pattern", "State-Action-Event", "type-safe navigation", "@Serializable route", "SavedStateHandle persistence", "process death recovery", "handleAction", "sendAction", "Hilt module", "Repository pattern", "implementing a screen", "adding a data source", "handling navigation", "encrypted storage", "security patterns", "Clock injection", "DataState", or any questions about implementing features, screens, ViewModels, data sources, or navigation in the Bitwarden Android app.
Как установить скилл implementing-android-code?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл implementing-android-code запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic