
Swift Expert
Apply production-grade Swift concurrency—async/await, task groups, and actors—for iOS and macOS apps while you build or refactor network and cache layers.
Overview
Swift Expert is an agent skill for the Build phase that guides correct Swift async/await, task groups, and actor-based state on iOS and macOS.
Install
npx skills add https://github.com/jeffallan/claude-skills --skill swift-expertWhat is this skill?
- Async/await patterns with URLSession, decoding, and structured error handling
- Concurrent fetches via withThrowingTaskGroup and typed aggregation
- Actor-isolated caches with in-flight task deduplication
- Thread-safe shared mutable state without manual locks in typical cases
- Copy-paste reference snippets aligned with modern Swift concurrency
Adoption & trust: 2.5k installs on skills.sh; 9.7k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your agent keeps generating completion-handler Swift or unsafe shared mutable state that will race once you add concurrent network or cache access.
Who is it for?
Indie iOS/macOS developers actively implementing networking, caching, or parallel data loads in Swift 5.5+.
Skip if: Teams building only on non-Apple stacks, or projects still frozen on legacy threading with no concurrency migration planned.
When should I use this skill?
When implementing or reviewing Swift code that uses async/await, actors, or concurrent network and cache access on Apple platforms.
What do I get? / Deliverables
You get review-ready Swift concurrency snippets—async APIs, grouped tasks, and actor caches—that you can drop into Xcode and harden before Ship.
- Async/await call chains
- Actor-backed cache modules
- Task-group concurrent fetch patterns
Recommended Skills
Journey fit
Swift implementation work lands in the Build phase when you are writing app code, APIs, and thread-safe state on Apple platforms. Mobile and SwiftUI/UIKit surface area maps to the frontend subphase even when networking and actors sit behind the UI.
How it compares
Use for procedural Swift concurrency depth instead of asking the model for generic “best practices” without actor or task-group structure.
Common Questions / FAQ
Who is swift-expert for?
Solo and indie builders shipping Swift apps who want their coding agent to write async/await and actors correctly on Apple platforms.
When should I use swift-expert?
During Build when adding URLSession calls, refactoring callbacks to async, fanning out parallel requests, or isolating cache state in actors before test and review.
Is swift-expert safe to install?
It is guidance and code patterns only; review the Security Audits panel on this Prism page and treat generated Swift like any other agent-written code before merge.
SKILL.md
READMESKILL.md - Swift Expert
# Async/Await Concurrency ## Async/Await Basics ```swift // Async function func fetchUser(id: Int) 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) } // Calling async functions func loadUserData() async { do { let user = try await fetchUser(id: 123) print("Loaded: \(user.name)") } catch { print("Error: \(error)") } } // Multiple concurrent operations func fetchMultipleUsers(ids: [Int]) 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 } } ``` ## Actors ```swift // Actor for thread-safe state management actor UserCache { private var cache: [Int: User] = [:] private var inProgress: [Int: Task<User, Error>] = [:] func user(id: Int) async throws -> User { // Check cache first if let cached = cache[id] { return cached } // Check if already loading if let task = inProgress[id] { return try await task.value } // Start new load let task = Task { try await fetchUser(id: id) } inProgress[id] = task do { let user = try await task.value cache[id] = user inProgress.removeValue(forKey: id) return user } catch { inProgress.removeValue(forKey: id) throw error } } func clearCache() { cache.removeAll() } } // Usage let cache = UserCache() let user = try await cache.user(id: 123) ``` ## MainActor ```swift // UI updates must happen on main thread @MainActor class ViewModel: ObservableObject { @Published var users: [User] = [] @Published var isLoading = false func loadUsers() async { isLoading = true defer { isLoading = false } do { // This async work happens off main thread let loadedUsers = try await fetchMultipleUsers(ids: [1, 2, 3]) // Property updates happen on main thread automatically users = loadedUsers } catch { print("Error: \(error)") } } } // Isolated functions @MainActor func updateUI() { // This always runs on main thread } // Non-isolated functions in MainActor type @MainActor class DataManager { var data: [String] = [] // Runs on main thread func updateData(_ newData: [String]) { data = newData } // Can run on any thread nonisolated func processData(_ input: String) -> String { return input.uppercased() } } ``` ## Structured Concurrency ```swift // Task groups for dynamic concurrency func downloadImages(urls: [URL]) async throws -> [UIImage] { try await withThrowingTaskGroup(of: (Int, UIImage).self) { group in for (index, url) in urls.enumerated() { group.addTask { let (data, _) = try await URLSession.shared.data(from: url) guard let image = UIImage(data: data) else { throw ImageError.invalidData } return (index, image) } } var images = [UIImage?](repeating: nil, count: urls.count) for try await (index, image) in group { images[index] = image } return images.compactMap { $0 } } } // Parallel async-let func loadDashboard() async throws -> Dashboard { async let user = fetchUser(id: currentUserID) async let posts = fetchPosts() async let notifications = fetchNotifications() return try await Dashboard( user: user, posts: p