Swift programming patterns for iOS and macOS
- version
- 1.0.0
- GitHub stars
- 26
Add marketplace
/plugin marketplace add miles990/claude-software-skillsRun it inside Claude Code once, then install the plugin below.
Install
/plugin install swift@claude-software-skillsRun it inside Claude Code after adding the marketplace.
Files
Discovered from sourceSwift
Overview
Swift programming patterns including protocols, generics, async/await, and SwiftUI.
Swift Fundamentals
Structs and Classes
import Foundation
// Struct (value type, preferred for most cases)
struct User: Identifiable, Codable {
let id: UUID
var email: String
var name: String
var createdAt: Date
// Memberwise initializer provided automatically
// Custom initializer
init(email: String, name: String) {
self.id = UUID()
self.email = email
self.name = name
self.createdAt = Date()
}
// Computed property
var displayName: String {
"\(name) <\(email)>"
}
// Mutating method (for structs)
mutating func updateEmail(_ newEmail: String) {
email = newEmail
}
}
// Class (reference type)
class UserManager {
static let shared = UserManager() // Singleton
private var users: [UUID: User] = [:]
private init() {}
func add(_ user: User) {
users[user.id] = user
}
func find(id: UUID) -> User? {
users[id]
}
}
// Actor (thread-safe reference type)
actor UserStore {
private var users: [UUID: User] = [:]
func add(_ user: User) {
users[user.id] = user
}
func find(id: UUID) -> User? {
users[id]
}
func count() -> Int {
users.count
}
}
Enums and Pattern Matching
// Enum with associated values
enum Result<Success, Failure: Error> {
case success(Success)
case failure(Failure)
var isSuccess: Bool {
if case .success = self { return true }
return false
}
func map<NewSuccess>(_ transform: (Success) -> NewSuccess) -> Result<NewSuccess, Failure> {
switch self {
case .success(let value):
return .success(transform(value))
case .failure(let error):
return .failure(error)
}
}
}
// Enum with raw values
enum Status: String, Codable, CaseIterable {
case pending = "pending"
case active = "active"
case inactive = "inactive"
var displayName: String {
switch self {
case .pending: return "Pending Review"
case .active: return "Active"
case .inactive: return "Inactive"
}
}
}
// Pattern matching
func process(_ result: Result<User, Error>) {
switch result {
case .success(let user) where user.email.contains("@admin"):
print("Admin user: \(user.name)")
case .success(let user):
print("Regular user: \(user.name)")
case .failure(let error):
print("Error: \(error.localizedDescription)")
}
}
// If-case pattern
if case .success(let user) = result {
print(user.name)
}
// Guard-case pattern
func handleSuccess(_ result: Result<User, Error>) -> User? {
guard case .success(let user) = result else {
return nil
}
return user
}
Optionals
// Optional declaration
var name: String? = nil
var age: Int? = 25
// Optional binding
if let name = name {
print("Name: \(name)")
}
// Multiple bindings
if let name = name, let age = age, age > 18 {
print("\(name) is \(age) years old")
}
// Guard let (early exit)
func processUser(_ user: User?) -> String {
guard let user = user else {
return "No user"
}
return user.displayName
}
// Nil coalescing
let displayName = name ?? "Anonymous"
// Optional chaining
let uppercased = name?.uppercased()
// Map and flatMap
let nameLength = name.map { $0.count }
let parsed: Int? = "42".flatMap { Int($0) }
// Implicitly unwrapped (use sparingly)
var apiKey: String!
Protocols and Generics
Protocols
// Protocol definition
protocol Repository {
associatedtype Entity: Identifiable
func find(id: Entity.ID) async throws -> Entity?
func findAll() async throws -> [Entity]
func save(_ entity: Entity) async throws
func delete(id: Entity.ID) async throws
}
// Protocol with default implementation
extension Repository {
func findAll() async throws -> [Entity] {
// Default implementation
[]
}
}
// Protocol composition
protocol Named {
var name: String { get }
}
protocol Aged {
var age: Int { get }
}
typealias Person = Named & Aged
func greet(_ person: some Person) {
print("Hello, \(person.name)!")
}
// Protocol with Self requirement
protocol Copyable {
func copy() -> Self
}
// Conforming to protocols
struct UserRepository: Repository {
typealias Entity = User
func find(id: UUID) async throws -> User? {
// Implementation
nil
}
func save(_ entity: User) async throws {
// Implementation
}
func delete(id: UUID) async throws {
// Implementation
}
}
Generics
// Generic function
func swap<T>(_ a: inout T, _ b: inout T) {
let temp = a
a = b
b = temp
}
// Generic type
struct Stack<Element> {
private var items: [Element] = []
mutating func push(_ item: Element) {
items.append(item)
}
mutating func pop() -> Element? {
items.popLast()
}
var top: Element? {
items.last
}
var isEmpty: Bool {
items.isEmpty
}
}
// Generic constraints
func findIndex<T: Equatable>(of value: T, in array: [T]) -> Int? {
for (index, item) in array.enumerated() {
if item == value {
return index
}
}
return nil
}
// Where clause
func allItemsMatch<C1: Container, C2: Container>(
_ c1: C1,
_ c2: C2
) -> Bool where C1.Item == C2.Item, C1.Item: Equatable {
guard c1.count == c2.count else { return false }
for i in 0..<c1.count {
if c1[i] != c2[i] { return false }
}
return true
}
// Opaque types (some)
func makeCollection() -> some Collection {
[1, 2, 3]
}
// Primary associated types (Swift 5.7+)
func process<C: Collection<String>>(_ collection: C) {
for item in collection {
print(item)
}
}
Async/Await (Swift 5.5+)
// Async function
func fetchUser(id: String) async throws -> User {
let url = URL(string: "https://api.example.com/users/\(id)")!
let (data, _) = try await URLSession.shared.data(from: url)
return try JSONDecoder().decode(User.self, from: data)
}
// Concurrent execution
func fetchAllUsers(ids: [String]) async throws -> [User] {
try await withThrowingTaskGroup(of: User.self) { group in
for id in ids {
group.addTask {
try await fetchUser(id: id)
}
}
var users: [User] = []
for try await user in group {
users.append(user)
}
return users
}
}
// Async sequences
struct NumberSequence: AsyncSequence {
typealias Element = Int
let start: Int
let end: Int
struct AsyncIterator: AsyncIteratorProtocol {
var current: Int
let end: Int
mutating func next() async -> Int? {
guard current <= end else { return nil }
defer { current += 1 }
try? await Task.sleep(nanoseconds: 100_000_000)
return current
}
}
func makeAsyncIterator() -> AsyncIterator {
AsyncIterator(current: start, end: end)
}
}
// Using async for-in
func processNumbers() async {
for await number in NumberSequence(start: 1, end: 10) {
print(number)
}
}
// Task groups
func processItems(_ items: [Item]) async throws -> [Result] {
try await withThrowingTaskGroup(of: Result.self) { group in
for item in items {
group.addTask {
try await process(item)
}
}
return try await group.reduce(into: []) { $0.append($1) }
}
}
// Actors for thread-safe state
actor Counter {
private var value = 0
func increment() {
value += 1
}
func get() -> Int {
value
}
}
// @MainActor for UI updates
@MainActor
class ViewModel: ObservableObject {
@Published var users: [User] = []
func loadUsers() async {
do {
let fetched = try await fetchAllUsers(ids: ["1", "2", "3"])
users = fetched
} catch {
print(error)
}
}
}
SwiftUI Patterns
import SwiftUI
// View composition
struct UserListView: View {
@StateObject private var viewModel = UserListViewModel()
var body: some View {
NavigationStack {
List(viewModel.users) { user in
NavigationLink(value: user) {
UserRow(user: user)
}
}
.navigationTitle("Users")
.navigationDestination(for: User.self) { user in
UserDetailView(user: user)
}
.refreshable {
await viewModel.refresh()
}
.task {
await viewModel.loadUsers()
}
}
}
}
struct UserRow: View {
let user: User
var body: some View {
HStack {
AsyncImage(url: user.avatarURL) { image in
image
.resizable()
.aspectRatio(contentMode: .fill)
} placeholder: {
ProgressView()
}
.frame(width: 44, height: 44)
.clipShape(Circle())
VStack(alignment: .leading) {
Text(user.name)
.font(.headline)
Text(user.email)
.font(.subheadline)
.foregroundColor(.secondary)
}
}
}
}
// View model with Combine
@MainActor
class UserListViewModel: ObservableObject {
@Published var users: [User] = []
@Published var isLoading = false
@Published var error: Error?
private let userService: UserService
init(userService: UserService = .shared) {
self.userService = userService
}
func loadUsers() async {
isLoading = true
defer { isLoading = false }
do {
users = try await userService.fetchUsers()
} catch {
self.error = error
}
}
func refresh() async {
await loadUsers()
}
}
// Custom view modifier
struct CardModifier: ViewModifier {
func body(content: Content) -> some View {
content
.padding()
.background(Color(.systemBackground))
.cornerRadius(12)
.shadow(radius: 4)
}
}
extension View {
func card() -> some View {
modifier(CardModifier())
}
}
// Environment values
private struct UserServiceKey: EnvironmentKey {
static let defaultValue = UserService.shared
}
extension EnvironmentValues {
var userService: UserService {
get { self[UserServiceKey.self] }
set { self[UserServiceKey.self] = newValue }
}
}
Error Handling
// Define errors
enum NetworkError: Error, LocalizedError {
case invalidURL
case noData
case decodingFailed(Error)
case serverError(statusCode: Int)
var errorDescription: String? {
switch self {
case .invalidURL:
return "Invalid URL"
case .noData:
return "No data received"
case .decodingFailed(let error):
return "Decoding failed: \(error.localizedDescription)"
case .serverError(let code):
return "Server error: \(code)"
}
}
}
// Throwing functions
func fetchData(from urlString: String) async throws -> Data {
guard let url = URL(string: urlString) else {
throw NetworkError.invalidURL
}
let (data, response) = try await URLSession.shared.data(from: url)
guard let httpResponse = response as? HTTPURLResponse else {
throw NetworkError.noData
}
guard (200...299).contains(httpResponse.statusCode) else {
throw NetworkError.serverError(statusCode: httpResponse.statusCode)
}
return data
}
// Result type
func fetchUser(id: String) async -> Result<User, NetworkError> {
do {
let data = try await fetchData(from: "https://api.example.com/users/\(id)")
let user = try JSONDecoder().decode(User.self, from: data)
return .success(user)
} catch let error as NetworkError {
return .failure(error)
} catch {
return .failure(.decodingFailed(error))
}
}
// Do-catch
do {
let user = try await fetchData(from: "...")
print(user)
} catch NetworkError.invalidURL {
print("Bad URL")
} catch {
print("Other error: \(error)")
}
// try? and try!
let user = try? await fetchUser(id: "1") // Returns optional
let definiteUser = try! loadFromCache() // Force unwrap (crashes on error)
Related Skills
- [[mobile]] - iOS/macOS development
- [[frontend]] - SwiftUI patterns
- [[testing]] - XCTest, Quick/Nimble
From the miles990/claude-software-skills README
Claude Software Skills
55 modular software development skills for Claude Code - from architecture to deployment
┌─────────────────────────────────────────────────────────────────┐
│ Claude Software Skills │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Software │ │ Software │ │ Development │ │
│ │ Design │ │ Engineering │ │ Stacks │ │
│ │ 6 │ │ 8 │ │ 8 │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Tools & │ │ Domain │ │ Programming │ │
│ │ Integrations │ │ Applications │ │ Languages │ │
│ │ 9 │ │ 12 │ │ 12 │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
│ AI 自動識別任務 → 載入對應領域知識 │
└─────────────────────────────────────────────────────────────────┘
Features
- MCP Compatible - Works with Claude Code, Cursor, and other MCP clients
- Semantic Search - Claude automatically finds relevant skills for your task
- Cross-Domain Integration - Skills work together seamlessly
- Best Practices Built-In - Each skill includes patterns and anti-patterns
- Modular Architecture - Use only what you need
- Sharp Edges - Proactive warnings about common pitfalls with detection patterns
- Validations - Executable code quality rules with regex/ast patterns
- Collaboration - Skills declare relationships for smart delegation and context passing
Installation
Plugin Marketplace (Recommended)
# 1. Add marketplace (GitHub format: owner/repo)
/plugin marketplace add miles990/claude-software-skills
# 2. Open plugin management interface, view available plugins in Discover tab
/plugin
# 3. Install specific skills (choose what you need)
/plugin install frontend@claude-software-skills
/plugin install backend@claude-software-skills
/plugin install api-design@claude-software-skills
# Or mention skill name in conversation, Claude will auto-load
Supported GitHub formats:
# Short format (recommended)
/plugin marketplace add miles990/claude-software-skills
# HTTPS URL
/plugin marketplace add https://github.com/miles990/claude-software-skills.git
# Specify branch or tag
/plugin marketplace add miles990/claude-software-skills#main
Plugin commands:
| Command | Description |
|---|---|
/plugin | Open interactive plugin management interface |
/plugin install <name>@<marketplace> | Install specific plugin |
/plugin disable <name>@<marketplace> | Temporarily disable plugin |
/plugin uninstall <name>@<marketplace> | Completely remove plugin |
Available Skills
Software Design (6 skills)
| Skill | Description |
|---|---|
architecture-patterns | Software architecture patterns and best practices |
design-patterns | Classic and modern software design patterns |
api-design | RESTful, GraphQL, gRPC, and API best practices |
system-design | Scalability, availability, and distributed systems design |
data-design | Data modeling, schema design, and data architecture |
ux-principles | User experience design principles for developers |
Software Engineering (8 skills)
| Skill | Description |
|---|---|
code-quality | Clean code principles, SOLID, and code review practices |
testing-strategies | Unit, integration, E2E testing and TDD practices |
devops-cicd | CI/CD pipelines, infrastructure as code, and deployment |
performance-optimization | Profiling, optimization techniques, and best practices |
security-practices | OWASP Top 10, authentication, and secure coding |
reliability-engineering | SRE principles, observability, and incident management |
documentation | Technical writing, API docs, and documentation best practices |
internationalization | i18n/l10n architecture design and multi-language support |
Development Stacks (8 skills)
| Skill | Description |
|---|---|
frontend | Modern frontend with React, Vue, and web technologies |
backend | Backend with Node.js, Express, NestJS, and server patterns |
mobile | Mobile with React Native, Flutter, and native patterns |
database | Database design, SQL, NoSQL, and data management |
cloud-platforms | AWS, GCP, Azure services and cloud-native development |
ai-ml-integration | AI/ML APIs, LLM integration, and intelligent apps |
realtime-systems | WebSocket, real-time communication, event-driven |
edge-iot | Edge computing, IoT protocols, and embedded systems |
Tools & Integrations (9 skills)
| Skill | Description |
|---|---|
git-workflows | Git version control, branching, and collaboration |
project-management | Agile, Scrum, Kanban, and issue tracking |
development-environment | IDE setup, dev containers, and local development |
monitoring-logging | Application monitoring, logging, and alerting |
api-tools | API testing, documentation, and development tools |
automation-scripts | Build automation, task runners, and scripting |
auto-dev-setup | Auto-Dev workflow for Human-in-the-Loop automation |
claude-code-plugin | Claude Code Plugin development and marketplace management |
claude-code-sdk | Claude Code SDK for AI-powered applications |
Domain Applications (12 skills)
| Skill | Description |
|---|---|
application-patterns | Common application development patterns |
e-commerce | E-commerce platforms, payments, shopping cart |
saas-platforms | SaaS architecture, multi-tenancy, subscriptions |
content-platforms | CMS, blogging platforms, content management |
communication-systems | Email, notifications, messaging systems |
developer-tools | CLI tools, SDKs, developer experience |
game-development | Game development patterns and architectures |
flame | Flame Engine 2D game development for Flutter |
flame-core | Flame Engine core - components, input, collision |
flame-systems | Flame Engine 14 game systems |
flame-templates | Game templates - RPG, Platformer, Roguelike |
desktop-apps | Desktop apps with Electron and Tauri |
Programming Languages (12 skills)
| Skill | Description |
|---|---|
javascript-typescript | Modern JavaScript and TypeScript patterns |
python | Python programming patterns and best practices |
go | Go programming patterns and idioms |
rust | Rust patterns and ownership concepts |
java-kotlin | Java and Kotlin programming patterns |
csharp-dotnet | C# and .NET development patterns |
cpp | Modern C++ programming patterns and idioms |
ruby | Ruby programming patterns and idioms |
php | Modern PHP programming patterns |
swift | Swift patterns for iOS and macOS |
shell-bash | Shell scripting and Bash programming |
sql | SQL patterns for database querying and design |
Other Installation Methods
Clone to Skills Directory
# Clone to your skills directory
git clone https://github.com/miles990/claude-software-skills.git ~/.claude/skills/software-skills
Claude will automatically discover and use the skills when relevant to your tasks.
With MCP Server
This repository is compatible with claude-skills-mcp:
# Install the MCP server
pip install claude-skills-mcp
# Add this repository as a skill source
# The server will load skills from ~/.claude/skills/
Cursor IDE
Add to your Cursor MCP settings:
{
"mcpServers": {
"software-skills": {
"command": "npx",
"args": ["-y", "claude-skills-mcp"],
"env": {
"SKILLS_PATH": "/path/to/claude-software-skills"
}
}
}
}
Manual Reference
Simply clone and reference the SKILL.md files in your prompts:
git clone https://github.com/miles990/claude-software-skills.git
Auto-Dev: Automated Development Workflow
One-click setup for GitHub Actions automated development workflow, let Claude help you complete development tasks.
Quick Setup
Using API Key:
curl -fsSL https://raw.githubusercontent.com/miles990/claude-software-skills/main/scripts/setup-auto-dev-apikey.sh | bash
Using Claude Max (OAuth):
curl -fsSL https://raw.githubusercontent.com/miles990/claude-software-skills/main/scripts/setup-auto-dev-max.sh | bash
Post-Installation Setup
| Version | Setup Method |
|---|---|
| API Key | Get Key from console.anthropic.com, set in GitHub Secrets ANTHROPIC_API_KEY |
| Claude Max | Run claude /install-github-app for auto OAuth Token setup |
Usage
- Issue Trigger: Create Issue → Add
auto-devlabel - Comment Trigger: Comment
@claude [instruction]on any Issue/PR
Detailed docs: AUTO-DEV.md
Usage Examples
User: Help me design a microservices architecture for an e-commerce platform
Claude: [Automatically uses architecture-patterns + e-commerce + api-design skills]
User: Review this Python code for performance issues
Claude: [Automatically uses python + performance-optimization + code-quality skills]
User: Set up CI/CD for a React + Node.js monorepo
Claude: [Automatically uses devops-cicd + frontend + backend + git-workflows skills]
Directory Structure
claude-software-skills/
├── .claude-plugin/ # Plugin configuration
│ └── marketplace.json # Lists all 55 skills as individual plugins
├── .github/
│ └── workflows/ # CI/CD automation
├── software-design/ # Architecture & design skills
├── software-engineering/ # Development practices
├── development-stacks/ # Tech stack skills
├── tools-integrations/ # Developer tools
├── domain-applications/ # Domain-specific patterns
├── programming-languages/ # Language-specific skills
├── docs/
│ ├── SKILL-TEMPLATE.md # Template for new skills
│ └── software-skills.md
├── CONTRIBUTING.md
├── LICENSE
└── README.md
How It Works
Each skill module contains a SKILL.md file with:
- Metadata - Name, description, tags for semantic search
- Key Concepts - Core knowledge and terminology
- Best Practices - Recommended approaches with examples
- Common Pitfalls - What to avoid and why
- Patterns & Anti-patterns - Do's and don'ts with code
- Tools & Resources - Recommended tools and references
- Decision Guide - When to use this skill
When you describe a task, Claude:
- Searches for relevant skills using semantic matching
- Loads the appropriate SKILL.md files
- Applies the knowledge to your specific context
- Follows best practices while avoiding common pitfalls
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Adding a New Skill
- Create a directory under the appropriate category
- Add a
SKILL.mdfollowing our template - Include practical examples and best practices
- Submit a pull request
License
MIT License - See LICENSE for details.
Related Projects
- claude-domain-skills - Non-technical domain skills
- claude-skills-mcp - MCP server for skill discovery
Built for developers, by developers, with Claude
Details
- Marketplace
- miles990/claude-software-skills
- Source
- programming-languages/swift
- Category
- Community
- Listed since
- Apr 6, 2026
More from miles990/claude-software-skills
All 56- system-designv1.0.0
- testing-strategiesv1.0.0
- ux-principlesv1.0.0
- ai-ml-integrationv1.0.0
- analyze-repov1.0.0
- api-designv1.0.0
- api-toolsv1.0.0
- application-patternsv1.0.0
- architecture-patternsv1.0.0
- auto-dev-setupv1.0.0
- automation-scriptsv1.0.0
- backendv1.0.0
- claude-code-pluginv1.0.0
- claude-code-sdkv1.0.0
- cloud-platformsv1.0.0
- code-qualityv1.0.0
- communication-systemsv1.0.0
- content-platformsv1.0.0
- cppv1.0.0
- csharp-dotnetv1.0.0
- data-designv1.0.0
- databasev1.0.0
- design-patternsv1.0.0
- desktop-appsv1.0.0
Similar to swift
More Mobile Apps
objective-cTheBushidoCollective/han201 starsAdvanced Objective-C programming skills for iOS and macOS development
jutsu-swiftTheBushidoCollective/han201 starsAdvanced Swift programming skills for iOS and protocol-oriented programming
mobilemiles990/claude-software-skills26 starsMobile development with React Native, Flutter, and native patterns
xcodetuist/claude-marketplace45 starsBest practices and guidelines for Xcode and Apple platform development
ios-developerrohitg00/awesome-claude-code-toolkit2.8K starsiOS and Swift development with SwiftUI views and models
java-kotlinmiles990/claude-software-skills26 starsJava and Kotlin programming patterns
