About solid-swift
solid-swift is a coding skill for Swift 6 and SwiftUI projects, using modular layout rules, SOLID and DRY guidance, and code templates to shape implementation. It is intended for Swift developers who need consistent architecture and concurrency conventions.
Key features
- 01Requires feature-based modular directories
- 02Provides references for SOLID principles
- 03Sets file-size and layer limits
- 04Covers Swift concurrency patterns
- 05Includes common code templates
- 06Checks for reusable shared code
Use cases
- 01Plan directory structure for SwiftUI features
- 02Split oversized views or view models
- 03Implement code following concurrency conventions
- 04Check for reusable components before adding features
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ fusengine/ agents --skill solid-swiftAfter installing, type/solid-swiftin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
references/anti-patterns.mdconcurrency-patterns.mddependency-inversion.mdinterface-segregation.mdliskov-substitution.mdopen-closed.mdsingle-responsibility.mdsolid-principles.mdreferences/templates/model.mdprotocol.mdservice.mdview.mdviewmodel.mdDetails
From the project READMECovers all five SOLID principles with dedicated references (SRP, OCP, LSP, ISP, DIP), concurrency patterns (actors, @MainActor, Sendable), an anti-pattern catalog, and code templates for views, view models, services, protocols, and models.
Requires grepping the codebase for reusable protocols/services before writing new code, and checking shared locations (Core/Extensions/, Core/Utilities/, Core/Protocols/) before duplicating logic used by 2+ features.
SOLID Swift - Apple Best Practices 2026
Agent Workflow (MANDATORY)
Before ANY implementation, spawn 3 agents in parallel, one Agent call each with a name:
- fuse-ai-pilot:explore-codebase - Analyze existing architecture
- fuse-ai-pilot:research-expert - Verify Swift/Apple docs via Apple Docs MCP + Context7
- XcodeBuildMCP - Build validation after code changes. Then run fuse-ai-pilot:sniper.
DRY - Reuse Before Creating (MANDATORY)
Before writing ANY new code:
- Grep the codebase for similar protocols, services, or logic
- Check shared locations:
Core/Extensions/,Core/Utilities/,Core/Protocols/ - If similar code exists -> extend/reuse instead of duplicate
- If code will be used by 2+ features -> create it in
Core/directly
Architecture (Features Modular MANDATORY)
| Layer | Location | Max Lines |
|---|---|---|
| Views | Features/[Feature]/Views/ | 80 |
| ViewModels | Features/[Feature]/ViewModels/ | 100 |
| Services | Features/[Feature]/Services/ | 100 |
| Protocols | Features/[Feature]/Protocols/ | 30 |
| Shared | Core/{Models,Protocols,Services,Extensions,Utilities}/ | - |
NEVER use flat Sources/ structure - always Features/[Feature]/
Critical Rules (MANDATORY)
| Rule | Value |
|---|---|
| File limit | 100 lines (split at 90) |
| ViewModels | @MainActor @Observable |
| Protocols | Features/[Feature]/Protocols/ or Core/Protocols/ ONLY |
| Models | Sendable structs |
| Documentation | /// on all public APIs |
| Previews | Every View MUST have #Preview |
Reference Guide
Concepts
| Topic | Reference | When to consult |
|---|---|---|
| SOLID Overview | solid-principles.md | Quick reference all principles |
| SRP | single-responsibility.md | Fat views/VMs, splitting files |
| OCP | open-closed.md | Adding providers, extensibility |
| LSP | liskov-substitution.md | Protocol contracts, testing |
| ISP | interface-segregation.md | Fat protocols, splitting |
| DIP | dependency-inversion.md | Injection, testing, mocking |
| Concurrency | concurrency-patterns.md | Actors, @MainActor, Sendable |
| Anti-Patterns | anti-patterns.md | Code smells detection |
Templates
| Template | When to use |
|---|---|
| view.md | SwiftUI View with subviews and #Preview |
| viewmodel.md | @Observable ViewModel with @MainActor |
| service.md | API Service, Mock, Cache actor |
| protocol.md | Service protocol, CQRS, Auth |
| model.md | Model, DTO, Error, Enum |
Forbidden
| Anti-Pattern | Fix |
|---|---|
| Files > 100 lines | Split at 90 |
| Protocols in impl files | Move to Protocols/ directory |
ObservableObject | Use @Observable |
| Completion handlers | Use async/await |
Missing #Preview | Add preview for every View |
| Non-Sendable in async | Use struct with let |
Flat Sources/ structure | Use Features/[Feature]/ |