This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
StealthyStash is a Swift Package Manager library that provides a Swifty database interface into macOS/iOS Keychain Services. It supports storing and retrieving both generic and internet passwords with an abstraction layer for complex composite objects.
The library is built around several core protocols and types:
- StealthyRepository: Main protocol for storing/retrieving keychain items. Implemented by
KeychainRepository. - StealthyProperty: Protocol for individual keychain items (
GenericPasswordItem,InternetPasswordItem). - StealthyModel: Protocol for composite objects that span multiple keychain items.
- ModelQueryBuilder: Defines how to build queries for creating, updating, and deleting
StealthyModelobjects. - Query: Protocol for querying the keychain (TypeQuery, etc.).
The codebase uses conditional compilation (#if canImport(Security)) to support both Apple platforms (using Keychain Services) and Linux (using swift-log).
swift build# Run all tests
swift test
# Run specific test
swift test --filter <test-name>The library includes DocC documentation in Sources/StealthyStash/Documentation.docc/.
This project has two package manifests:
Package.swift: Uses Swift 5.8 tools version with basic upcoming featuresPackage@swift-6.0.swift: Uses Swift 6.0 with extensive experimental features
Key compiler settings (especially in Swift 6.0 manifest):
- Strict concurrency checking (
-strict-concurrency=complete) - Actor data race checks
- Long function/expression warnings (>100 lines/ms)
- Experimental features:
BitwiseCopyable,NoncopyableGenerics,MoveOnlyClasses,VariadicGenerics, and many more
When adding new code:
- Ensure it follows the strict concurrency model (all types must be
Sendablewhere appropriate) - Avoid long functions or expressions (>100 lines)
- Use
#if swift(>=6.0)for Swift version-specific code - Use
#if canImport(Security)for platform-specific code (Apple platforms vs Linux)
- Apple Platforms: iOS 14+, macOS 12+, watchOS 7+, tvOS 14+
- Linux: Ubuntu 18.04+
- Swift: 5.8+ (Swift 6.0+ for development)
StealthyModel allows composite objects spanning multiple keychain items. A ModelQueryBuilder implementation must provide:
queries(from:): Returns dictionary of Query objects keyed by property namesmodel(from:): Builds model from dictionary of[String: [AnyStealthyProperty]]properties(from:for:): ExtractsAnyStealthyPropertyarray from model for create/delete operationsupdates(from:to:): CreatesStealthyPropertyUpdatearray for model updates
Example implementations in Samples/Demo/App/Keychain/:
CompositeCredentials.swift: Simple model with username, password, and tokenCompositeCredentialsQueryBuilder.swift: FullModelQueryBuilderimplementation pattern