mcpField
S
solid-swift

solid-swift

github.com/fusengineDevelopment3441 installsUpdated 2w ago
Repository

About solid-swift

solid-swift is a code-organization and implementation-guidance skill for Swift 6 and SwiftUI projects. It applies SOLID and DRY practices through a feature-based structure, concurrency conventions, and reusable code templates.

Key features

  1. 01Feature-based modular directory structure
  2. 02Single-responsibility files and protocol separation
  3. 03@Observable ViewModels and Sendable models
  4. 04Required #Preview for each View
  5. 05SOLID, concurrency, and anti-pattern references

Use cases

  1. 01Structuring a SwiftUI project by feature
  2. 02Reviewing code for SOLID and DRY practices
  3. 03Creating ViewModels, services, and models consistently

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/fusengine/claude-plugins --skill solid-swift

After installing, type/solid-swiftin Claude Code to confirm it loaded.

Details

From the project README
Enforces SOLID and DRY principles for Swift 6 and SwiftUI (iOS 27+) projects: a mandatory Features/[Feature]/ modular directory structure (never a flat Sources/ layout), one responsibility per file with the hook's ceiling (`FUSE_SOLID_MAX_LINES`) as the only line limit, protocols separated into their own Protocols/ directories, @Observable + @MainActor for ViewModels, Sendable structs for models, and mandatory #Preview on every View.

Covers 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:

  1. fuse-ai-pilot:explore-codebase - Analyze existing architecture
  2. fuse-ai-pilot:research-expert - Verify Swift/Apple docs via Apple Docs MCP + Context7
  3. XcodeBuildMCP - Build validation after code changes. Then run fuse-ai-pilot:sniper.

DRY - Reuse Before Creating (MANDATORY)

Before writing ANY new code:

  1. Grep the codebase for similar protocols, services, or logic
  2. Check shared locations: Core/Extensions/, Core/Utilities/, Core/Protocols/
  3. If similar code exists -> extend/reuse instead of duplicate
  4. If code will be used by 2+ features -> create it in Core/ directly

Architecture (Features Modular MANDATORY)

LayerLocation
ViewsFeatures/[Feature]/Views/
ViewModelsFeatures/[Feature]/ViewModels/
ServicesFeatures/[Feature]/Services/
ProtocolsFeatures/[Feature]/Protocols/
SharedCore/{Models,Protocols,Services,Extensions,Utilities}/

File size: the only line limit is the hook ceiling (FUSE_SOLID_MAX_LINES). Split by responsibility well before it; if a legitimate fix cannot fit, report it - never bypass the hook.

NEVER use flat Sources/ structure - always Features/[Feature]/


Critical Rules (MANDATORY)

RuleValue
File limitHook ceiling FUSE_SOLID_MAX_LINES only; one responsibility per file
ViewModels@MainActor @Observable
ProtocolsFeatures/[Feature]/Protocols/ or Core/Protocols/ ONLY
ModelsSendable structs
Documentation/// on all public APIs
PreviewsEvery View MUST have #Preview

Reference Guide

Concepts
TopicReferenceWhen to consult
SOLID Overviewsolid-principles.mdQuick reference all principles
SRPsingle-responsibility.mdFat views/VMs, splitting files
OCPopen-closed.mdAdding providers, extensibility
LSPliskov-substitution.mdProtocol contracts, testing
ISPinterface-segregation.mdFat protocols, splitting
DIPdependency-inversion.mdInjection, testing, mocking
Concurrencyconcurrency-patterns.mdActors, @MainActor, Sendable
Anti-Patternsanti-patterns.mdCode smells detection
Templates
TemplateWhen to use
view.mdSwiftUI View with subviews and #Preview
viewmodel.md@Observable ViewModel with @MainActor
service.mdAPI Service, Mock, Cache actor
protocol.mdService protocol, CQRS, Auth
model.mdModel, DTO, Error, Enum

Forbidden

Anti-PatternFix
File with several responsibilities, or blocked by the hook ceilingSplit by responsibility
Protocols in impl filesMove to Protocols/ directory
ObservableObjectUse @Observable
Completion handlersUse async/await
Missing #PreviewAdd preview for every View
Non-Sendable in asyncUse struct with let
Flat Sources/ structureUse Features/[Feature]/

Comments

Markdown supported