Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,6 @@ Authenticator/Application/Support/Settings.bundle/Acknowledgements.latest_result

# Backup files
*.bak

# AI
.claude
82 changes: 82 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Bitwarden iOS - Claude Code Configuration

Copy link
Contributor

@SaintPatrck SaintPatrck Oct 14, 2025

Choose a reason for hiding this comment

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

I think it would be helpful to add a clear purpose statement so Claude has immediate context and directive. Something like

This document provides the necessary context and rules for you, an expert iOS developer, to contribute to the Bitwarden iOS project.

## Project Context Files

**Read these files first to fully understand the project and contributing guidelines.**

Files prefixed with `@` are references to other files in this `.ai` directory. You MUST read them for context before proceeding.

The bottom "Files prefixed with @...", part is to clarify file notation since it varies throughout the doc. Some places, like L7-L9, are prefixed @ while others use hyperlinks pointing to the file.

Copy link
Member Author

@fedemkr fedemkr Oct 14, 2025

Choose a reason for hiding this comment

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

Agree, I'll add that. I think I can just switch to use @ in all places as it's the preferred way on Claude docs to avoid stating it here.

## Project Context Files

**Read these files before reviewing to ensure that you fully understand the project and contributing guidelines**

1. @README.md
2. @CONTRIBUTING.md
3. @.github/PULL_REQUEST_TEMPLATE.md


Copy link
Contributor

Choose a reason for hiding this comment

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

Extra newline can be removed.

## Project Structure Quick Reference

- **BitwardenShared/**: Main codebase (Core + UI layers)
- **Core/**: Data layer (Models, Services, Repositories, Stores)
- **Sourcery/**: Sourcery related files, including auto generated mocks.
- **UI/**: Presentation layer (Coordinators, Processors, Views, State)
- **AuthenticatorShared/**: Same as `BitwardenShared` but for Authenticator app.
- **Domains**: Auth | Autofill | Platform | Tools | Vault
- **Apps**: The projects contain two main apps: "Password Manager" and "Authenticator".
- **
Copy link
Contributor

Choose a reason for hiding this comment

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

Blank bullet can be removed.

Copy link
Member Author

@fedemkr fedemkr Oct 14, 2025

Choose a reason for hiding this comment

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

Work in progress need to add some things in there; missed to add them before committing. Thanks for catching this!

- **Main Password Manager targets**: Bitwarden, BitwardenActionExtension, BitwardenAutoFillExtension, BitwardenShareExtension, BitwardenWatchApp, BitwardenWatchWidgetExtension
- **Main Authenticator target**: Authenticator
- **Shared apps frameworks**: BitwardenKit, BitwardenKitMocks, BitwardenResources, AuthenticatorBridgeKit, AuthenticatorBridgeKitMocks, Networking, TestHelpers

## Critical Rules
Copy link
Contributor

Choose a reason for hiding this comment

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

🧠 ⛈️ I've found terminology like "should not" to be less effective than using more direct phrases like, "You MUST NOT do x." When possible, providing reasoning is also helpful to express criticality in following instructions.

- You **MUST NOT** install third-party libraries unless explicitly told to.
- New encryption logic **MUST NOT** be added to this repository.
- Before providing any code or making changes, you **MUST** have read and understood the "iOS Client Architecture" and "Code Style" documents listed in the References section.


- **NEVER** install third-party libaries unless explicitly told to.
- **CRITICAL**: new encryption logic should not be added to this repo.
- **NEVER** send unencrypted vault data to API services
- **NEVER** commit secrets, credentials, or sensitive information.
- **NEVER** log decrypted data, encryption keys, or PII
- No vault data in error messages or console logs
- **ALWAYS** Read "iOS Client Architecture" and "Code Style" in References before answer.

## Common Patterns

- **UI changes**: Always follow Coordinator → Processor → State → View flow
- **Data access**: UI layer mostly uses Repositories (never Stores directly and scarsely Services)
- **State mutations**: Only in Processors
- **Navigation**: Coordinators handle navigation via Routes/Events enums
- **Testing**: Test file goes in same folder as implementation (e.g., `FooProcessor.swift` + `FooProcessorTests.swift`)
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 Should this explicitly call out that we can have multiple test files per class?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should. Something like...

Suggested change
- **Testing**: Test file goes in same folder as implementation (e.g., `FooProcessor.swift` + `FooProcessorTests.swift`)
- **Testing**: Test files go in the same folder as the implementation (e.g., `FooProcessor.swift` + `FooProcessorTests.swift`). Multiple test files can be used for a single class to improve readability.

Copy link
Member Author

@fedemkr fedemkr Oct 14, 2025

Choose a reason for hiding this comment

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

I can add a direct link to the testing docs explanation on contributing docs as in there, it's explained how test files are organized. Also will make it plural.

- **Mocking**: Mocks should be done on protocols. Prefer to use Sourcery AutoMockable approach by adding `// sourcery: AutoMockable` to the protocol.
- **Dependencies**: Use protocol composition via Services typealias

## Anti-Patterns to Avoid

- **NEVER** mutate state directly in Views
- **NEVER** put business logic in Coordinators
- **NEVER** access Stores from UI layer (use Repositories)
- **NEVER** create new top-level folders in Core/ or UI/ (use existing domains)
- **NEVER** use concrete types in Services typealias (use protocols for mocking)

## Common File Locations

- Dependency injection: [BitwardenShared/Core/Platform/Services/ServiceContainer.swift](BitwardenShared/Core/Platform/Services/ServiceContainer.swift)
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 Part of me wonders if this will be sufficient for BWA, or if we need to call BWA out separately, or if we should work at getting some of these files actually migrated to BitwardenKit

Copy link
Member Author

Choose a reason for hiding this comment

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

I will rewrite this to take into account both apps. Even though we could move some things into BitwardenKit there are some objects/services that are particular of each app so we will still need the specific app ServiceContainers; so we should still be documenting them.

- App module (coordinator factory): [BitwardenShared/UI/Platform/Application/AppModule.swift](BitwardenShared/UI/Platform/Application/AppModule.swift)
- Store (View-Processor bridge): [BitwardenShared/UI/Platform/Application/Utilities/Store.swift](BitwardenShared/UI/Platform/Application/Utilities/Store.swift)
- Project generation
- `project-pm.yml`: for main Password Manager
- `project-bwa.yml`: for Authenticator
- `project-bwk.yml`: for shared frameworks like Bitwarden Kit

## Testing Requirements

- Every type with logic needs tests
- Test files named `<TypeToTest>Tests.swift` in same folder
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we elaborate on this?

Suggested change
- Test files named `<TypeToTest>Tests.swift` in same folder
Test files must be named `<TypeToTest>Tests.swift` and be located in the same folder as the file being tested.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is repeated from the Common patterns section. I'm wondering if there's actually value in it being in both places. 🤔

- Snapshot tests use device/iOS version from `.test-simulator-device-name` and `.test-simulator-ios-version`
- Test in light mode, dark mode, and large dynamic type
Copy link
Contributor

Choose a reason for hiding this comment

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

⛏️ Can we elaborate more here, too?

Suggested change
- Test in light mode, dark mode, and large dynamic type
- Tests must pass in light mode, dark mode, and large dynamic type.


Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 It may be helpful to provide instructions on how to run tests.

Suggested change
### How to Run Tests
- After making changes, run the tests for the relevant scheme in Xcode to ensure your changes have not broken anything.
- You can also run tests from the command line using `xcodebuild`.

## References

When searching for references of https://contributing.bitwarden.com, first check if there's a local copy on ../ContributingDocs/src.

- [iOS Client Architecture](https://contributing.bitwarden.com/architecture/mobile-clients/ios/)
- [Code Style](https://contributing.bitwarden.com/contributing/code-style/swift)
- [Architectural Decision Records (ADRs)](https://contributing.bitwarden.com/architecture/adr/)
- [Contributing Guide](https://contributing.bitwarden.com/)
- [iOS Client Setup Guide](https://contributing.bitwarden.com/getting-started/mobile/ios/)
- [Security Whitepaper](https://bitwarden.com/help/bitwarden-security-white-paper/)
- [Security Definitions](https://contributing.bitwarden.com/architecture/security/definitions)
- [Accessibility](https://contributing.bitwarden.com/contributing/accessibility/)
Loading