Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 7 additions & 69 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,56 +29,13 @@ The app follows a layered architecture: Views send Actions/Effects to a Store, w

### Code Organization

```
β”œβ”€β”€ Bitwarden/ # Password Manager app target
β”‚ └── Application/
β”œβ”€β”€ Authenticator/ # Authenticator app target
β”‚ └── Application/
β”œβ”€β”€ BitwardenShared/ # Main PM shared framework
β”‚ β”œβ”€β”€ Core/ # Data & business logic
β”‚ β”‚ β”œβ”€β”€ Auth/ # Authentication domain
β”‚ β”‚ β”œβ”€β”€ Autofill/ # AutoFill domain
β”‚ β”‚ β”œβ”€β”€ Billing/ # Billing & subscription domain
β”‚ β”‚ β”œβ”€β”€ Platform/ # Cross-cutting (services, stores, utilities)
β”‚ β”‚ β”œβ”€β”€ Tools/ # Generator, Send, Import/Export
β”‚ β”‚ └── Vault/ # Vault items domain
β”‚ β”œβ”€β”€ Sourcery/ # Mock generation config + output
β”‚ └── UI/ # UI layer (same subdirectories)
β”‚ β”œβ”€β”€ Auth/
β”‚ β”œβ”€β”€ Autofill/
β”‚ β”œβ”€β”€ Billing/
β”‚ β”œβ”€β”€ Platform/
β”‚ β”œβ”€β”€ Tools/
β”‚ └── Vault/
β”œβ”€β”€ AuthenticatorShared/ # Authenticator shared framework
β”‚ β”œβ”€β”€ Core/ # Same structure as BitwardenShared
β”‚ β”œβ”€β”€ Sourcery/ # Mock generation config + output
β”‚ └── UI/
β”œβ”€β”€ BitwardenKit/ # Common functionality across both apps
β”‚ β”œβ”€β”€ Core/
β”‚ β”‚ └── Platform/Services/ # Has* protocols, ServiceContainer base
β”‚ β”œβ”€β”€ Sourcery/ # Mock generation config + output
β”‚ └── UI/
β”‚ └── Platform/Application/
β”‚ └── Utilities/ # Store, Processor, Coordinator, Alert
β”œβ”€β”€ BitwardenResources/ # Shared assets, fonts, localizations
β”œβ”€β”€ AuthenticatorBridgeKit/ # PM ↔ Authenticator communication
β”‚ └── Sourcery/ # Mock generation config + output
β”œβ”€β”€ Networking/ # URLSession-based networking (Swift package)
β”œβ”€β”€ BitwardenAutoFillExtension/ # AutoFill Credential Provider extension
β”œβ”€β”€ BitwardenActionExtension/ # Action extension (autofill via share sheet)
β”œβ”€β”€ BitwardenShareExtension/ # Share extension (create Sends)
β”œβ”€β”€ BitwardenWatchApp/ # watchOS companion
β”œβ”€β”€ GlobalTestHelpers/ # Shared test utilities
β”œβ”€β”€ Sourcery/Templates/ # Shared Sourcery Stencil templates
β”œβ”€β”€ Configs/ # xcconfig files (Debug/Release per target)
β”œβ”€β”€ Scripts/ # Build, bootstrap, CI scripts
β”œβ”€β”€ TestPlans/ # Xcode test plans
β”œβ”€β”€ Docs/ # Architecture.md, Testing.md
└── project-*.yml # XcodeGen project specs
```
`Bitwarden/`, `Authenticator/` β€” app targets
`BitwardenShared/`, `AuthenticatorShared/`, `BitwardenKit/` β€” shared frameworks; each has `Core/` + `UI/` with fixed subdirs (see `Docs/Architecture.md` [Architecture Structure] for canonical domain list)
`AuthenticatorBridgeKit/`, `BitwardenResources/`, `Networking/` β€” support frameworks
`BitwardenAutoFillExtension/`, `BitwardenActionExtension/`, `BitwardenShareExtension/`, `BitwardenWatchApp/` β€” extensions
`Docs/`, `Scripts/`, `TestPlans/`, `Configs/`, `Sourcery/Templates/`, `project-*.yml` β€” configuration

**CRITICAL**: Do NOT add new top-level subdirectories to `Core/` or `UI/`. The fixed subdirectories are: `Auth/`, `Autofill/`, `Billing/`, `Platform/`, `Tools/`, `Vault/`.
**CRITICAL**: Do NOT add new top-level subdirectories to `Core/` or `UI/`. The fixed subdirectories are defined in `Docs/Architecture.md` under [Architecture Structure].

For key principles (unidirectional data flow, dependency injection, coordinator navigation, zero-knowledge), core patterns (Coordinator/Processor/State/View/Action/Effect files), adding new features, adding services/repositories, and common patterns, see `Docs/Architecture.md`.

Expand Down Expand Up @@ -106,32 +63,13 @@ Build configurations use xcconfig files in `Configs/` (Debug/Release per target)

Xcode version requirement: see `.xcode-version` file

### Authentication & Authorization

- **Login flows**: Email+password, SSO, SSO+TDE, passwordless (device approval), biometric unlock, PIN unlock
- **Key derivation**: PBKDF2 or Argon2id (configurable per account)
- **Token lifecycle**: Access tokens refreshed preemptively 5 minutes before expiry (`tokenRefreshThreshold`)
- **Biometric auth**: Touch ID / Face ID unlock via Keychain access control flags
- **Multi-account**: Up to 5 accounts with per-user data isolation (CoreData `userId` scoping)

## Testing

**You MUST follow testing guidelines in `Docs/Testing.md`** (authoritative source for test structure, naming, templates, decision matrix, running tests, and simulator configuration). Snapshot tests are currently disabled β€” prefix function names with `disable`.

## Code Style & Standards

### Core Directives

**You MUST follow these directives at all times:**

1. **Adhere to Architecture**: All code modifications MUST follow patterns in `Docs/Architecture.md`
2. **Follow Code Style**: ALWAYS follow https://contributing.bitwarden.com/contributing/code-style/swift
3. **Follow Testing Guidelines**: Tests MUST follow guidelines in `Docs/Testing.md`
4. **Best Practices**: Follow Swift / SwiftUI best practices (value over reference types, guard clauses, extensions, protocol-oriented programming)
5. **Document Everything**: All code requires DocC documentation except protocol property/function implementations (docs live in the protocol) and mocks
6. **Dependency Management**: Use `ServiceContainer` as established in the project
7. **Use Established Patterns**: Leverage existing components before creating new ones
8. **File References**: Use `file_path:line_number` format when referencing code
Architecture and testing rules are in `Docs/Architecture.md` and `Docs/Testing.md` (authoritative). Key style rules are inline below.

### Formatting

Expand Down
38 changes: 38 additions & 0 deletions .claude/commands/plan-ios-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
description: Plan implementation for a Bitwarden iOS Jira ticket or task description. Fetches requirements, performs gap analysis, designs the implementation approach, and saves a design doc to .claude/outputs/plans/.
argument-hint: <PM-XXXXX ticket ID or task description>
---

# Plan iOS Work: $ARGUMENTS

## Phase 1: Ingest Requirements

If `$ARGUMENTS` looks like a Jira ticket ID (e.g., `PM-12345` or `BWA-456`):
- Fetch the ticket: `mcp__plugin_bitwarden-atlassian-tools_bitwarden-atlassian__get_issue`
- Fetch comments for context: `mcp__plugin_bitwarden-atlassian-tools_bitwarden-atlassian__get_issue_comments`

If `$ARGUMENTS` is a description, use it directly as the requirements source.

## Phase 2: Refine Requirements

Invoke the `refining-ios-requirements` skill to:
- Extract structured requirements and acceptance criteria
- Perform gap analysis (error states, edge cases, extensions, accessibility)
- Map to iOS domain (see `Docs/Architecture.md` Architecture Structure for domain list)

**Pause here**: Present requirements to user and confirm accuracy before proceeding.

## Phase 3: Plan Implementation

Once requirements are confirmed, invoke the `planning-ios-implementation` skill to:
- Classify the change type
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Maybe it's defined in another place but which would be the possible change types? Or is it just general for the LLM to figure out?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Classifying is a step in the planning-ios-implementation skill. This is "priming" Claude so it knows what the skill will be doing. I see that planning-ios-implementation doesn't mirror the Android version, though, so I'll fix that up.

- Explore existing similar patterns in the codebase
- List all files to create/modify with domain placement
- Order implementation into dependency-ordered phases
- Assess risks (security, extensions, multi-account, SDK)

## Phase 4: Save Design Doc

Save the complete plan to `.claude/outputs/plans/<ticket-id>.md`.

**Final output**: "Plan saved to `.claude/outputs/plans/<ticket-id>.md`. Ready to implement with `/work-on-ios <ticket-id>`."
103 changes: 103 additions & 0 deletions .claude/skills/planning-ios-implementation/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
name: planning-ios-implementation
description: Plan implementation, design an approach, or create an architecture plan for a Bitwarden iOS feature. Use when asked to "plan implementation", "design approach", "architecture plan", "how should I implement", "what files do I need", or to create a design doc before writing code.
---

# Planning iOS Implementation

Use this skill to design a complete implementation plan before writing code. Output is saved as a design document.

## Prerequisites

- Requirements must be clear. If not, invoke `refining-ios-requirements` first.
- Read `Docs/Architecture.md` before proceeding β€” it is the authoritative source for all patterns.

Comment on lines +10 to +14
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ€” Should it also read the Testing.md file as prerequisite? As sometimes having the structure to be testable changes how it's implemented.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not run into that as an issue on the Android side of things. I would wait until we see Claude exhibiting undesirable behavior before preemptively telling it to consume more context. If that turns out to be needed, I would prefer a simple directive like, "consider testability while designing implementation." before having it re-ingest the entire Testing.md.

## Step 1: Classify the Change

Determine the change type to guide scope and planning depth:

| Type | Description | Typical Scope |
|------|-------------|---------------|
| **New Feature** | Entirely new functionality, screens, or flows | New files + modifications, multi-phase |
| **Enhancement** | Extending existing feature with new capabilities | Mostly modifications, 1-2 phases |
| **Bug Fix** | Correcting incorrect behavior | Targeted modifications, single phase |
| **Refactoring** | Restructuring without behavior change | Modifications only, migration-aware |
| **Infrastructure** | Build, CI, tooling, or dependency changes | Config files, minimal code changes |

State the classification and rationale before proceeding.

## Step 2: Explore Existing Patterns

Search the codebase for similar existing implementations to follow:
- Find a similar existing feature in the same domain
- Identify which services/repositories it uses
- Note how its Coordinator, Processor, and View are structured
- Check if `BitwardenKit/UI/` has reusable components for the new UI

## Step 3: List Files to Create/Modify

For each file, specify path, action (create/modify), domain placement, and purpose. Group by layer:

```
### New Files (Create)

#### Core Layer
- `BitwardenShared/Core/<Domain>/<Feature>/Services/<Feature>Service.swift`
- Protocol + Default<Feature>Service + Has<Feature>Service

#### UI Layer
- `BitwardenShared/UI/<Domain>/<Feature>/<Feature>Coordinator.swift`
- `BitwardenShared/UI/<Domain>/<Feature>/<Feature>Processor.swift`
- `BitwardenShared/UI/<Domain>/<Feature>/<Feature>State.swift`
- `BitwardenShared/UI/<Domain>/<Feature>/<Feature>Action.swift`
- `BitwardenShared/UI/<Domain>/<Feature>/<Feature>Effect.swift`
- `BitwardenShared/UI/<Domain>/<Feature>/<Feature>View.swift`

#### Tests (co-located with implementation)
- `BitwardenShared/UI/<Domain>/<Feature>/<Feature>ProcessorTests.swift`
- `BitwardenShared/Core/<Domain>/<Feature>/Services/<Feature>ServiceTests.swift`

### Modified Files
- `BitwardenShared/Core/Platform/Services/ServiceContainer.swift` β€” Add new service
- `<Existing>Coordinator.swift` β€” Add new route
```

## Step 4: Dependency-Ordered Implementation Phases

Order phases so each builds on the previous:

```
### Phase 1: Data / Core Layer
Models, CoreData entities (if needed), service protocols, repository protocols

### Phase 2: Service/Repository Implementations
Default<Name>Service/Repository β€” business logic, SDK calls, network

### Phase 3: DI Wiring
ServiceContainer extensions, Has* protocol additions

### Phase 4: Processor + State
StateProcessor subclass, State struct, Action enum, Effect enum

### Phase 5: View + Coordinator
SwiftUI View with store.binding, Coordinator with routes, navigation wiring

### Phase 6: Tests
ProcessorTests (action/effect paths), ServiceTests (business logic), ViewTests (snapshots if UI)
```

## Step 5: Risk Assessment

Identify risks and mitigations:
- **Security**: Does this touch vault data, auth tokens, or Keychain? β†’ Security review required
- **Extensions**: Does this affect AutoFill/Action/Share extensions? β†’ Memory limit check needed
- **Multi-account**: Does this need per-account isolation? β†’ CoreData userId scoping
- **SDK dependency**: Does this require BitwardenSdk changes? β†’ Coordinate with SDK team

## Step 6: Save Design Document

Save the plan to `.claude/outputs/plans/<ticket-id>.md`.

## Confirm Before Proceeding

Present the plan to the user and ask: "Here is the implementation plan. Should I proceed with implementation?"
94 changes: 94 additions & 0 deletions .claude/skills/refining-ios-requirements/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
name: refining-ios-requirements
description: Refine requirements, analyze a ticket, perform gap analysis, or clarify what a Jira/Confluence ticket is asking before coding in Bitwarden iOS. Use when asked to "refine requirements", "analyze ticket", "gap analysis", "clarify ticket", "what does this ticket mean", or to understand scope before implementation begins.
---

# Refining iOS Requirements

Use this skill to analyze a Jira or Confluence ticket and produce structured, implementation-ready requirements before writing any code.

## Step 1: Ingest the Ticket

If a ticket ID or URL is provided, fetch it via MCP:
- Use `mcp__plugin_bitwarden-atlassian-tools_bitwarden-atlassian__get_issue` for Jira tickets
- Use `mcp__plugin_bitwarden-atlassian-tools_bitwarden-atlassian__get_issue_comments` for additional context
- Use `mcp__plugin_bitwarden-atlassian-tools_bitwarden-atlassian__get_confluence_page` for Confluence specs

If no ticket is provided, ask for a description of the requirements.

## Step 2: Extract Requirements

Identify and list:
1. **Core functionality**: What must this feature/fix do?
2. **Acceptance criteria**: What defines "done"?
3. **Out of scope**: What is explicitly excluded?
4. **Dependencies**: Other tickets, SDK changes, API endpoints needed?

## Step 3: Gap Analysis

Identify unstated requirements the ticket may have missed:

**Error states**
- Network errors, timeout, server errors
- Validation failures, empty states
- SDK errors (encryption/decryption failures)

**Edge cases**
- Multi-account scenarios (up to 5 accounts)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️ Is it actually needed to state there are a maximum of 5 accounts here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it hurts. It's not obvious without exploring the code but could impact planning and it's not token heavy.

- Account switching during the operation
- Locked vs unlocked vault state
- Empty vault / first-time user

**Platform concerns**
- App extension impact (AutoFill, Action, Share β€” memory limits apply)
- watchOS companion impact (if vault data is involved, especially TOTP data)
- Offline mode behavior

**Accessibility**
- VoiceOver labels for new UI elements
- Dynamic Type support
- Keyboard navigation

## Step 4: Map to iOS Domain

Determine which Bitwarden iOS domain(s) are involved. Read `Docs/Architecture.md` (Architecture Structure section) for the canonical domain list and descriptions.

Determine which app(s) are affected:
- **BitwardenShared**: Password Manager
- **AuthenticatorShared**: Authenticator
- **Both**: If the feature touches shared components

## Step 5: Output Structured Requirements

```markdown
## Ticket: [PM-XXXXX] β€” [Title]

### What
[1-2 sentence summary of what needs to be built]

### Why
[Business/user reason for the change]

### Acceptance Criteria
1. [Criterion 1]
2. [Criterion 2]

### Gap Analysis
**Unstated requirements identified:**
- [ ] Error state: [description]
- [ ] Edge case: [description]
- [ ] Platform concern: [description]

**Clarifying questions (if any):**
1. [Question for product/design]

### Scope
- **Domain**: [from Architecture Structure domain list]
- **App(s)**: [Password Manager / Authenticator / Both]
- **Extensions affected**: [AutoFill / Action / Share / Watch / None]
- **Out of scope**: [explicit exclusions]
```

## Confirm Before Proceeding

Present the structured requirements to the user and ask: "Are these requirements accurate? Should I proceed with planning the implementation?"
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Bitwarden-specific structural constraints that reviewers must verify. These are
## Domain Folder Constraints

- [ ] No new top-level subdirectories added to `Core/` or `UI/`
- [ ] Fixed subdirectories only: `Auth/`, `Autofill/`, `Platform/`, `Tools/`, `Vault/`
- [ ] Fixed subdirectories only (see `Docs/Architecture.md` Architecture Structure for canonical list)
- [ ] New files placed in the correct domain folder (Auth vs Vault vs Platform)

## File-Set Completeness
Expand Down
3 changes: 2 additions & 1 deletion Docs/Architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Most of the app's functionality is implemented in the `BitwardenShared` and `Aut

- `Auth`
- `Autofill`
- `Billing`
- `Platform`
- `Tools`
- `Vault`
Expand Down Expand Up @@ -382,7 +383,7 @@ Test files are co-located with the code they test, maintaining the same folder s

- Makes it easy to find tests for a given type
- Ensures tests evolve alongside the code
- Reinforces the architectural boundaries (Auth, Autofill, Platform, Tools, Vault)
- Reinforces the architectural boundaries (see [Architecture Structure](#architecture-structure) for domain list)

### Dependency Mocking

Expand Down
Loading