swift-concurrency

Installation
SKILL.md

Swift Structured Concurrency

async/await Fundamentals

Mark functions that perform asynchronous work with async. Use throws alongside async for fallible operations. Call async functions with await.

func fetchUser(id: String) async throws -> User {
    let url = URL(string: "https://api.example.com/users/\(id)")!
    let (data, response) = try await URLSession.shared.data(from: url)

    guard let httpResponse = response as? HTTPURLResponse,
          httpResponse.statusCode == 200 else {
        throw APIError.invalidResponse
    }

    return try JSONDecoder().decode(User.self, from: data)
}
Related skills
Installs
4
GitHub Stars
366
First Seen
Mar 27, 2026