ios-swift-design-patterns/SKILL.md
Swift-idiomatic design patterns for iOS — VC containment to eliminate Massive ViewController, hand-rolled MVVM Observable binding without RxSwift, delegation naming conventions, associative storage for extension properties, constrained protocol...
npx skillsauth add peterbamuhigire/skills-web-dev ios-swift-design-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
ios-swift-design-patterns or would be better handled by a more specific companion skill.SKILL.md first, then load only the referenced deep-dive files that are necessary for the task.Source: Swift Design Patterns — Paul Hudson, Hacking with Swift Use when: Designing iOS app architecture, refactoring large VCs, choosing communication patterns, inheritance vs composition decisions.
Root cause: one VC conforming to 5+ protocols simultaneously. Four fixes:
@nonobjc extension UIViewController {
func add(_ child: UIViewController, frame: CGRect? = nil) {
addChild(child)
if let frame = frame { child.view.frame = frame }
view.addSubview(child.view)
child.didMove(toParent: self)
}
func remove() {
willMove(toParent: nil)
view.removeFromSuperview()
removeFromParent()
}
}
class DashboardViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let stats = StatsViewController()
add(stats, frame: CGRect(x: 0, y: 0, width: view.bounds.width, height: 200))
}
}
class ContactsDataSource: NSObject, UITableViewDataSource {
var contacts: [Contact] = []
func tableView(_ tableView: UITableView,
numberOfRowsInSection section: Int) -> Int { contacts.count }
func tableView(_ tableView: UITableView,
cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
cell.textLabel?.text = contacts[indexPath.row].name
return cell
}
}
class ContactsViewController: UIViewController {
private let dataSource = ContactsDataSource()
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = dataSource
}
}
// Override loadView() — not viewDidLoad() — to set a custom view
class ProfileViewController: UIViewController {
override func loadView() {
view = ProfileView() // all layout lives in ProfileView
}
var profileView: ProfileView { view as! ProfileView }
}
Use a singleton hidden behind a protocol instead (see Section 6).
Extended guidance for ios-swift-design-patterns was moved to references/skill-deep-dive.md to keep this entrypoint compact and fast to load.
Use that deep dive for:
SECTION 2: Hand-Rolled MVVM Binding (No RxSwift Required)SECTION 3: Delegation — Correct Swift NamingSECTION 4: Stored Properties in Extensions (Associative Storage)SECTION 5: Protocol-Oriented CompositionSECTION 6: Singleton — Swifty ImplementationSECTION 7: Initializer PatternsSECTION 8: Keypath Adapter PatternSECTION 9: Safe Iterator with deferSECTION 10: Responder Chain — Traversal + Custom ChainSECTION 11: Copy-on-Write FlyweightSECTION 12: Swift Anti-PatternsQuick Decision Guidedata-ai
Use when adding AI-powered analytics to a SaaS platform — semantic search over business data, natural language queries, trend detection, anomaly alerts, and AI-generated insights for dashboards. Covers embeddings, NL2SQL, and per-tenant analytics...
data-ai
Design AI-powered analytics dashboards — what metrics to show, how to display AI predictions and confidence, drill-down patterns, KPI cards, trend visualisation, AI Insights panels, export design, and role-based dashboard variants. Invoke when...
development
Use when designing, building, reviewing, or upgrading production software systems that must be secure, performant, maintainable, scalable, and user-centered. Apply before writing specs, code, architecture, APIs, databases, mobile apps, SaaS platforms, or ERP systems.
development
Professional web app UI using commercial templates (Tabler/Bootstrap 5) with strong frontend design direction when needed. Use for CRUD interfaces, dashboards, admin panels with SweetAlert2, DataTables, Flatpickr. Clone seeder-page.php, use...