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가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
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:
- Scan for known-dangerous patterns using
references/hotspots.mdto prioritize what to inspect. - Check for recent Swift 6.2 concurrency behavior using
references/new-features.md. - Validate actor usage for reentrancy and isolation correctness using
references/actors.md. - Ensure structured concurrency is preferred over unstructured where appropriate using
references/structured.md. - Check unstructured task usage for correctness using
references/unstructured.md. - Verify cancellation is handled correctly using
references/cancellation.md. - Validate async stream and continuation usage using
references/async-streams.md. - Check bridging code between sync and async worlds using
references/bridging.md. - Review any legacy concurrency migrations using
references/interop.md. - Cross-check against common failure modes using
references/bug-patterns.md. - If the project has strict-concurrency errors, map diagnostics to fixes using
references/diagnostics.md. - 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/awaitand closure-based variants, always preferasync/await. - Do not introduce third-party concurrency frameworks without asking first.
- Do not suggest
@unchecked Sendableto fix compiler errors. It silences the diagnostic without fixing the underlying race. Prefer actors, value types, orsendingparameters 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:
- State the file and relevant line(s).
- Name the rule being violated.
- 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
- Correctness (high): Actor reentrancy bug on line 18 may cause duplicate downloads and a force-unwrap crash.
- 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.
댓글
- …
이 저장소의 다른 스킬
onlyswitch-deeplink
6.0k에이전트가 딥링크로 휴지통 비우기, 화면 깨어 있기, 다크 모드 전환 같은 Mac의 OnlySwitch 동작을 실행하게 합니다.
app-store-review
6.0k에이전트가 Apple 앱 코드를 App Store 심사 지침과 대조해, 제출 전에 거절될 수 있는 문제를 찾도록 돕습니다.
swift-testing-pro
6.0k에이전트가 최신 테스트 API, 비동기 테스트 패턴, 깔끔한 테스트 구조로 Swift Testing 코드를 작성하고 검토하도록 돕습니다.
비슷한 스킬
android-clean-architecture
280k에이전트가 Android 프로젝트를 효율적으로 구성하도록 돕습니다. 유지보수와 새 기능 개발이 쉽도록 코드를 구조화합니다.
compose-multiplatform-patterns
280k에이전트가 KMP 프로젝트에서 Compose Multiplatform과 Jetpack Compose 패턴을 쓰도록 돕습니다. 상태, 내비게이션, 테마, 성능을 다룹니다.
dart-flutter-patterns
280kDart와 Flutter 앱용 코드를 작성하도록 에이전트를 돕습니다. 견고하고 관리하기 쉬운 앱을 만드는 현대적인 패턴을 씁니다.