Back to Skills

ios-swift-concurrency

verified

Use when implementing async/await, Task management, actors, or Combine reactive patterns in iOS applications.

View on GitHub

Marketplace

han

TheBushidoCollective/han

Plugin

jutsu-ios

Technique

Repository

TheBushidoCollective/han
60stars

jutsu/jutsu-ios/skills/swift-concurrency/SKILL.md

Last Verified

January 24, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/TheBushidoCollective/han/blob/main/jutsu/jutsu-ios/skills/swift-concurrency/SKILL.md -a claude-code --skill ios-swift-concurrency

Installation paths:

Claude
.claude/skills/ios-swift-concurrency/
Powered by add-skill CLI

Instructions

# iOS - Swift Concurrency

Modern concurrency patterns using async/await, actors, and structured concurrency in Swift.

## Key Concepts

### Async/Await Fundamentals

```swift
// Async function declaration
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)
}

// Calling async functions
func loadUserProfile() async {
    do {
        let user = try await fetchUser(id: "123")
        await MainActor.run {
            updateUI(with: user)
        }
    } catch {
        await MainActor.run {
            showError(error)
        }
    }
}
```

### Task Management

```swift
class UserViewController: UIViewController {
    private var loadTask: Task<Void, Never>?

    override func viewDidLoad() {
        super.viewDidLoad()

        // Create a task for async work
        loadTask = Task {
            await loadUserData()
        }
    }

    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        // Cancel when view disappears
        loadTask?.cancel()
    }

    private func loadUserData() async {
        // Check for cancellation
        guard !Task.isCancelled else { return }

        do {
            let user = try await fetchUser()

            // Check again before UI update
            guard !Task.isCancelled else { return }

            await MainActor.run {
                displayUser(user)
            }
        } catch {
            // Handle error
        }
    }
}
```

### Actors for Thread Safety

```swift
actor UserCache {
    private var cache: [String: User] = [:]

    func user(for id: String) -> User? {
        cache[id]
    }

    func setUser(_ user: User, for id:

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
7358 chars

Issues Found:

  • name_directory_mismatch