6.7 KiB
Bitwarden Android - Claude Code Configuration
Official Android application for Bitwarden Password Manager and Bitwarden Authenticator, providing secure password management, two-factor authentication, and credential autofill services with zero-knowledge encryption.
Overview
- Multi-module Android application:
:app(Password Manager),:authenticator(2FA TOTP generator) - Zero-knowledge architecture: encryption/decryption happens client-side via Bitwarden SDK
- Target users: End-users via Google Play Store and F-Droid
Key Concepts
- Zero-Knowledge Architecture: Server never has access to unencrypted vault data or encryption keys
- Bitwarden SDK: Rust-based cryptographic SDK handling all encryption/decryption operations
- DataState: Wrapper for streaming data states (Loading, Loaded, Pending, Error, NoNetwork)
- Result Types: Custom sealed classes for operation results (never throw exceptions from data layer)
- UDF (Unidirectional Data Flow): State flows down, actions flow up through ViewModels
Architecture
User Request (UI Action)
|
Screen (Compose)
|
ViewModel (State/Action/Event)
|
Repository (Business Logic)
|
+----+----+----+
| | | |
Disk Network SDK
| | |
Room Retrofit Bitwarden
DB APIs Rust SDK
Key Principles
- No Exceptions from Data Layer: All suspending functions return
Result<T>or custom sealed classes - State Hoisting to ViewModel: All state that affects behavior must live in the ViewModel's state
- Interface-Based DI: All implementations use interface/
...Implpairs with Hilt injection - Encryption by Default: All sensitive data encrypted via SDK before storage
Core Patterns
- BaseViewModel: Enforces UDF with State/Action/Event pattern. See
ui/src/main/kotlin/com/bitwarden/ui/platform/base/BaseViewModel.kt. - Repository Result Pattern: Type-safe error handling using custom sealed classes for discrete operations and
DataState<T>wrapper for streaming data. - Common Patterns: Flow collection via
Internalactions, error handling viawhenbranches,DataStatestreaming with.map { }and.stateIn().
For complete architecture patterns, code templates, and module organization, see
docs/ARCHITECTURE.md.
Development Guide
Workflow Skills
Quick start: Use the
bitwarden-tech-lead:bitwarden-tech-leadagent (or/plan-android-work <task>) to refine requirements and plan, then thebitwarden-software-engineer:bitwarden-software-engineeragent (or/work-on-android <task>) for implementation, then/review-android <PR#>to review the result.
Skills & Commands
| Skill | Triggers |
|---|---|
build-test-verify |
"build", "run tests", "lint", "format", "verify build" |
implementing-android-code |
"implement", "write code", "add screen", "create feature" |
planning-android-implementation |
"plan implementation", "architecture design", "phased task breakdown" |
refining-android-requirements |
"refine requirements", "analyze ticket", "gap analysis" |
reviewing-changes |
"review", "code review", "check PR" |
testing-android-code |
"write tests", "add test coverage", "unit test" |
| Command | Usage |
|---|---|
/plan-android-work <task> |
Fetch ticket → refine requirements → design implementation approach |
/work-on-android <task> |
Full workflow: implement → test → verify → preflight → commit → review → PR |
/review-android <PR#> |
Full review workflow: PR context gathering → Android checklist → output |
Security Rules
MANDATORY - These rules have no exceptions:
- Zero-Knowledge Architecture: Never transmit unencrypted vault data or master passwords to the server. All encryption happens client-side via the Bitwarden SDK.
- No Plaintext Key Storage: Encryption keys must be stored using Android Keystore (biometric unlock) or encrypted with PIN/master password.
- Sensitive Data Cleanup: On logout, all sensitive data must be cleared from memory and storage via
UserLogoutManager.logout(). - Input Validation: Validate all user inputs before processing, especially URLs and credentials.
- SDK Isolation: Use scoped SDK sources (
ScopedVaultSdkSource) to prevent cross-user crypto context leakage.
Code Style & Standards
- Formatter: Android Studio with
bitwarden-style.xml| Line Limit: 100 chars | Detekt: Enabled - Naming:
camelCase(vars/fns),PascalCase(classes),SCREAMING_SNAKE_CASE(constants),...Impl(implementations) - KDoc: Required for all public APIs
- String Resources: Add new strings to
:uimodule (ui/src/main/res/values/strings.xml). Use typographic quotes/apostrophes (""') not escaped ASCII (\"\'). Name each resource from its own text content insnake_case— not with generic suffixes (_message,_title). E.g.,one_or_more_email_addresses_are_incorrect, notinvalid_email_addresses_message.
For complete style rules (imports, formatting, documentation, Compose conventions), see
docs/STYLE_AND_BEST_PRACTICES.md.
Anti-Patterns
In addition to the Key Principles above, follow these rules:
DO
- Map async results to internal actions before updating state
- Inject
Clockfor time-dependent operations - Return early to reduce nesting
DON'T
- Update state directly inside coroutines (use internal actions)
- Use
anytypes or suppress null safety - Catch generic
Exception(catch specific types) - Use
e.printStackTrace()(use Timber logging) - Create new patterns when established ones exist
- Skip KDoc for public APIs
Quick Reference
- Code style: Full rules:
docs/STYLE_AND_BEST_PRACTICES.md - Before writing code: Use
implementing-android-codeskill for Bitwarden-specific patterns, gotchas, and templates - Before writing tests: Use
testing-android-codeskill for test patterns and templates - Building/testing: Use
build-test-verifyskill | App tests:./gradlew app:testStandardDebugUnitTest - Before committing: Use
bitwarden-delivery-tools:perform-preflightskill, thenbitwarden-delivery-tools:committing-changesskill for message format - Code review: Use
/review-androidfor the full review workflow;reviewing-changesskill for checklist-only - Creating PRs: Use
bitwarden-delivery-tools:creating-pull-requestskill for PR workflow and templates - Troubleshooting: See
docs/TROUBLESHOOTING.md - Architecture:
docs/ARCHITECTURE.md| Bitwarden SDK | Jetpack Compose | Hilt DI