clean-archi-swiftui
Clean Architecture patterns for Swift/SwiftUI iOS projects. Use when working on Swift/SwiftUI projects that follow Clean Architecture with bounded contexts, ports/adapters pattern, and layered separation (domain/UI). Triggers for creating features, use cases, refactoring to bounded contexts, reviewing architecture compliance, or understanding project structure.
Security Assessment
Detected risks:
About clean-archi-swiftui
The clean-archi-swiftui skill is designed for developers working on iOS projects using Swift and SwiftUI, specifically those implementing Clean Architecture principles. This skill facilitates the structure and organization of Swift/SwiftUI code by applying the concepts of bounded contexts, ports/adapters, and layered separation. It helps to create maintainable, scalable, and testable applications by enforcing strict boundaries between different layers of the application, allowing for a clear separation between the domain logic and the UI layer. By following Clean Architecture, this skill simplifies refactoring, ensures better adherence to software design principles, and reduces dependencies between the UI and the core business logic of the application.
The skill provides a well-defined project structure, featuring a clear separation between the domain layer (pure Swift) and the app/extension layer (SwiftUI). It employs the ports and adapters pattern, where the domain layer defines protocols (ports) and the app/extension layer implements them (adapters). This structure promotes a modular approach to development, where the business logic is isolated from the UI, and shared adapters are used across the app. The skill also emphasizes dependency direction and error handling strategies, using Swift's `throws` and `Result<T, E>` types to handle failures and multiple outcomes efficiently.
The clean-archi-swiftui skill is ideal for developers seeking to implement Clean Architecture in their Swift/SwiftUI applications. It is especially useful for teams working on large-scale projects or those needing to refactor an existing codebase to follow these principles. Whether you're building new features, reviewing architecture compliance, or refactoring to adhere to Clean Architecture, this skill helps to structure projects in a way that maintains scalability, testability, and clear separation of concerns.
FAQ
What is the purpose of the domain layer?
The domain layer in the clean-archi-swiftui structure is used for pure Swift logic, without any UI dependencies. It contains core business logic, entities, use cases, ports (protocols), and errors. This layer ensures that the application logic remains independent of the UI layer, promoting a clean separation of concerns.
Can I use UIKit in the domain layer?
No, the domain layer should not contain any UI framework dependencies such as UIKit or SwiftUI. It is designed to be framework-agnostic and should only use Foundation and pure Swift to maintain its independence from the UI.
What is the difference between shared and UI-specific adapters?
Shared adapters are implementations that are used across multiple apps or extensions and are located in the `domain/Adapters/` directory. UI-specific adapters, on the other hand, are tailored to specific app or extension needs and are placed in the respective app's `Adapters/` directory.
How is error handling implemented in this architecture?
Error handling in the clean-archi-swiftui skill uses Swift's `throws` and `Result<T, E>` types. `throws` is used for simple success/failure cases, while `Result<T, E>` is used for more complex scenarios where multiple outcomes may exist, and the caller needs to handle specific errors.
Does this skill support cross-platform development?
This skill is specifically designed for Swift and SwiftUI iOS projects. While it promotes good architecture practices, it is primarily intended for iOS development and does not directly support cross-platform frameworks.
Install clean-archi-swiftui
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
benaor/claude-config