본문으로 건너뛰기
Skillpedia
모바일 앱6.0k · #14451

swift-concurrency-pro

하는 일

이 스킬은 async와 await를 쓰는 Swift 코드를 AI가 검토하도록 합니다. 충돌이나 경쟁 상태를 일으킬 수 있는 실수를 찾습니다. 더 안전한 동시성 코드를 원하는 Swift 개발자를 위한 것입니다.

사용하는 경우

  • ✓async와 await 또는 액터를 쓰는 Swift 코드를 작성하거나 바꾸고 있을 때.
  • ✓엄격한 동시성 경고가 보여서 그 의미를 설명받아야 할 때.
  • ✓Swift의 비동기 테스트나 작업 취소 처리를 검토하고 싶을 때.

스킬 링크

https://github.com/jacklandrin/OnlySwitch/blob/main/doc/skills/swift-concurrency-pro/SKILL.md

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

사용 방법

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

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

Use this skill to help me: https://github.com/jacklandrin/OnlySwitch/blob/main/doc/skills/swift-concurrency-pro/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분.

작동 방식

에이전트는 위험한 패턴을 찾고, 액터, 태스크, 취소, 스트림을 Swift 6.2 관행에 맞춰 확인합니다. 실제 문제만 보고합니다.

기술 내용 (원본 SKILL.md)

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

Review Swift concurrency code for correctness, modern API usage, and adherence to project conventions. Report only genuine problems - do not nitpick or invent issues.

Review process:

  1. Scan for known-dangerous patterns using references/hotspots.md to prioritize what to inspect.
  2. Check for recent Swift 6.2 concurrency behavior using references/new-features.md.
  3. Validate actor usage for reentrancy and isolation correctness using references/actors.md.
  4. Ensure structured concurrency is preferred over unstructured where appropriate using references/structured.md.
  5. Check unstructured task usage for correctness using references/unstructured.md.
  6. Verify cancellation is handled correctly using references/cancellation.md.
  7. Validate async stream and continuation usage using references/async-streams.md.
  8. Check bridging code between sync and async worlds using references/bridging.md.
  9. Review any legacy concurrency migrations using references/interop.md.
  10. Cross-check against common failure modes using references/bug-patterns.md.
  11. If the project has strict-concurrency errors, map diagnostics to fixes using references/diagnostics.md.
  12. If reviewing tests, check async test patterns using references/testing.md.

If doing a partial review, load only the relevant reference files.

Core Instructions

  • Target Swift 6.2 or later with strict concurrency checking.
  • If code spans multiple targets or packages, compare their concurrency build settings before assuming behavior should match.
  • Prefer structured concurrency (task groups) over unstructured (Task {}).
  • Prefer Swift concurrency over Grand Central Dispatch for new code. GCD is still acceptable in low-level code, framework interop, or performance-critical synchronous work where queues and locks are the right tool – don't flag these as errors.
  • If an API offers both async/await and closure-based variants, always prefer async/await.
  • Do not introduce third-party concurrency frameworks without asking first.
  • Do not suggest @unchecked Sendable to fix compiler errors. It silences the diagnostic without fixing the underlying race. Prefer actors, value types, or sending parameters instead. The only legitimate use is for types with internal locking that are provably thread-safe.

Output Format

Organize findings by file. For each issue:

  1. State the file and relevant line(s).
  2. Name the rule being violated.
  3. Show a brief before/after code fix.

Skip files with no issues. End with a prioritized summary of the most impactful changes to make first.

Example output:

DataLoader.swift

Line 18: Actor reentrancy – state may have changed across the await.

// Before
actor Cache {
    var items: [String: Data] = [:]

    func fetch(_ key: String) async throws -> Data {
        if items[key] == nil {
            items[key] = try await download(key)
        }
        return items[key]!
    }
}

// After
actor Cache {
    var items: [String: Data] = [:]

    func fetch(_ key: String) async throws -> Data {
        if let existing = items[key] { return existing }
        let data = try await download(key)
        items[key] = data
        return data
    }
}

Line 34: Use withTaskGroup instead of creating tasks in a loop.

// Before
for url in urls {
    Task { try await fetch(url) }
}

// After
try await withThrowingTaskGroup(of: Data.self) { group in
    for url in urls {
        group.addTask { try await fetch(url) }
    }

    for try await result in group {
        process(result)
    }
}

Summary

  1. Correctness (high): Actor reentrancy bug on line 18 may cause duplicate downloads and a force-unwrap crash.
  2. Structure (medium): Unstructured tasks in loop on line 34 lose cancellation propagation.

End of example.

References

  • references/hotspots.md - Grep targets for code review: known-dangerous patterns and what to check for each.
  • references/new-features.md - Swift 6.2 changes that alter review advice: default actor isolation, isolated conformances, caller-actor async behavior, @concurrent, Task.immediate, task naming, and priority escalation.
  • references/actors.md - Actor reentrancy, shared-state annotations, global actor inference, and isolation patterns.
  • references/structured.md - Task groups over loops, discarding task groups, concurrency limits.
  • references/unstructured.md - Task vs Task.detached, when Task {} is a code smell.
  • `refere
자주 묻는 질문

사소한 스타일 문제도 보고하나요?

아니요. 실제 문제만 보고하고 사소한 지적은 피합니다.

어떤 Swift 버전을 대상으로 하나요?

Swift 6.2 이상을 대상으로 합니다.

동시성 경고 수정을 도와주나요?

네. 엄격한 동시성 오류를 가능성 높은 수정 방법에 연결해 줍니다.

상세 정보

작성자의 원본 설명

Reviews Swift code for concurrency correctness, modern API usage, and common async/await pitfalls. Use when reading, writing, or reviewing Swift concurrency code.

repo: jacklandrin/OnlySwitch

인기도

GitHub 스타
6.0k
순위
#14451
라이선스
MIT
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬