본문으로 건너뛰기
Skillpedia
일반 코딩48k · #5910

swift-concurrency-expert

하는 일

이 Swift 동시성 전문가는 프로그램의 여러 부분이 안전하게 소통하는 방식과 관련된 Swift 코드의 오류를 찾아 고치도록 돕습니다. 특히 그래픽 인터페이스가 있는 앱에서 데이터 접근이 올바르게 처리되도록 합니다.

사용하는 경우

  • ✓컴파일러가 Swift 동시성 관련 오류를 표시할 때.
  • ✓코드를 'actor'로 정리하거나 작업을 메인 스레드에서 격리해야 할 때.
  • ✓예전 코드를 최신 Swift 동시성 패턴으로 옮기는 경우.

스킬 링크

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/swift-concurrency-expert/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/swift-concurrency-expert/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“이 Swift 코드를 검토하고 동시성 오류를 고쳐서, 데이터 접근이 안전하도록 해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

도구는 컴파일러가 가리키는 오류를 분석하고, 프로젝트 설정을 확인한 뒤, 가장 단순하고 안전한 수정을 적용합니다. 목표는 코드의 서로 다른 부분이 예기치 않게 간섭하는 것을 막는 것입니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Swift Concurrency Expert

Overview

Review and fix Swift Concurrency issues in Swift 6.2+ codebases by applying actor isolation, Sendable safety, and modern concurrency patterns with minimal behavior changes.

When to Use

  • When the user asks to review Swift concurrency usage or fix compiler diagnostics.
  • When you need guidance on actor isolation, Sendable, @MainActor, or async migration.

Workflow

1. Triage the issue

  • Capture the exact compiler diagnostics and the offending symbol(s).
  • Check project concurrency settings: Swift language version (6.2+), strict concurrency level, and whether approachable concurrency (default actor isolation / main-actor-by-default) is enabled.
  • Identify the current actor context (@MainActor, actor, nonisolated) and whether a default actor isolation mode is enabled.
  • Confirm whether the code is UI-bound or intended to run off the main actor.

2. Apply the smallest safe fix

Prefer edits that preserve existing behavior while satisfying data-race safety.

Common fixes:

  • UI-bound types: annotate the type or relevant members with @MainActor.
  • Protocol conformance on main actor types: make the conformance isolated (e.g., extension Foo: @MainActor SomeProtocol).
  • Global/static state: protect with @MainActor or move into an actor.
  • Background work: move expensive work into a @concurrent async function on a nonisolated type or use an actor to guard mutable state.
  • Sendable errors: prefer immutable/value types; add Sendable conformance only when correct; avoid @unchecked Sendable unless you can prove thread safety.

3. Verify the fix

  • Rebuild and confirm all concurrency diagnostics are resolved with no new warnings introduced.
  • Run the test suite to check for regressions — concurrency changes can introduce subtle runtime issues even when the build is clean.
  • If the fix surfaces new warnings, treat each one as a fresh triage (return to step 1) and resolve iteratively until the build is clean and tests pass.

Examples

UI-bound type — adding @MainActor

// Before: data-race warning because ViewModel is accessed from the main thread
// but has no actor isolation
class ViewModel: ObservableObject {
    @Published var title: String = ""
    func load() { title = "Loaded" }
}

// After: annotate the whole type so all stored state and methods are
// automatically isolated to the main actor
@MainActor
class ViewModel: ObservableObject {
    @Published var title: String = ""
    func load() { title = "Loaded" }
}

Protocol conformance isolation

// Before: compiler error — SomeProtocol method is nonisolated but the
// conforming type is @MainActor
@MainActor
class Foo: SomeProtocol {
    func protocolMethod() { /* accesses main-actor state */ }
}

// After: scope the conformance to @MainActor so the requirement is
// satisfied inside the correct isolation context
@MainActor
extension Foo: SomeProtocol {
    func protocolMethod() { /* safely accesses main-actor state */ }
}

Background work with @concurrent

// Before: expensive computation blocks the main actor
@MainActor
func processData(_ input: [Int]) -> [Int] {
    input.map { heavyTransform($0) }   // runs on main thread
}

// After: hop off the main actor for the heavy work, then return the result
// The caller awaits the result and stays on its own actor
nonisolated func processData(_ input: [Int]) async -> [Int] {
    await Task.detached(priority: .userInitiated) {
        input.map { heavyTransform($0) }
    }.value
}

// Or, using a @concurrent async function (Swift 6.2+):
@concurrent
func processData(_ input: [Int]) async -> [Int] {
    input.map { heavyTransform($0) }
}

Reference material

  • See references/swift-6-2-concurrency.md for Swift 6.2 changes, patterns, and examples.
  • See references/approachable-concurrency.md when the project is opted into approachable concurrency mode.
  • See references/swiftui-concurrency-tour-wwdc.md for SwiftUI-specific concurrency guidance.

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
자주 묻는 질문

'actor'와 'Sendable'은 무엇인가요?

'actor'는 충돌을 막는 안전한 상자와 같은 데이터 보관 방식입니다. 'Sendable'은 데이터 타입이 프로그램의 여러 부분 사이에서 안전하게 공유될 수 있음을 보장하는 표시입니다.

동시성이 왜 중요한가요?

현대 앱에서는 많은 일이 동시에 일어납니다. 동시성은 이 작업들이 인터페이스를 멈추게 하거나 데이터를 망가뜨리는 문제를 일으키지 않도록 합니다.

'actor 격리'는 무엇을 뜻하나요?

'actor'(또는 그것이 보호하는 데이터)에 접근하는 코드가 안전한 곳에서만 접근하도록 보장해, 여러 접근이 동시에 일어나 오류가 나는 것을 막는다는 뜻입니다.

상세 정보

작성자의 원본 설명

Review and fix Swift concurrency issues such as actor isolation and Sendable violations.

repo: sickn33/agentic-awesome-skills

인기도

GitHub 스타
48k
순위
#5910
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬