swift-concurrency-pro
O que ela faz
Esta skill faz sua IA revisar código Swift que usa async e await, procurando erros que podem causar falhas ou condições de corrida. É para desenvolvedores Swift que querem código concorrente mais seguro.
Quando usar
- ✓Quando você está escrevendo ou alterando código Swift que usa async e await ou actors.
- ✓Quando você vê avisos de concorrência estrita e precisa de explicações.
- ✓Quando você quer uma revisão de testes assíncronos ou do tratamento de cancelamento em Swift.
Link da skill
https://github.com/jacklandrin/OnlySwitch/blob/main/doc/skills/swift-concurrency-pro/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“Revise meu código de rede em Swift em busca de erros assíncronos e me diga o que corrigir.”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
O agente procura padrões de risco e verifica actors, tarefas, cancelamento e streams conforme as práticas do Swift 6.2, relatando apenas problemas reais.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do 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
Perguntas frequentes
Ela relata problemas pequenos de estilo?
Não. Ela relata apenas problemas genuínos e evita detalhes irrelevantes.
Qual versão do Swift ela visa?
Ela visa o Swift 6.2 ou mais recente.
Ela ajuda a corrigir avisos de concorrência?
Sim. Ela relaciona erros de concorrência estrita às correções prováveis.
Detalhes
Descrição original do autor
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
Popularidade
- Estrelas no GitHub
- 6,0 mil
- Posição no ranking
- #14451
- Licença
- MIT
- Atualizada em
- 01/11/2026
Comentários
- …
Mais skills deste repositório
onlyswitch-deeplink
6,0 milPermite que seu agente acione ações do OnlySwitch em um Mac, como esvaziar a lixeira, manter o Mac acordado ou alternar o modo escuro, usando um deeplink.
app-store-review
6,0 milAjuda seu agente a verificar o código de apps da Apple contra as diretrizes de revisão da App Store, para identificar prováveis problemas de rejeição antes do envio.
swift-testing-pro
6,0 milAjuda seu agente a escrever e revisar código de testes Swift, usando APIs de teste modernas, padrões de testes assíncronos e uma estrutura limpa de testes.
Skills parecidas
android-clean-architecture
280 milFaz seu agente organizar projetos Android de forma eficiente. Ele estrutura o código para facilitar a manutenção e o desenvolvimento de novos recursos.
compose-multiplatform-patterns
280 milAjuda seu agente a usar Compose Multiplatform e Jetpack Compose em projetos KMP. Cobre estado, navegação, temas e performance.
dart-flutter-patterns
280 milFaz seu agente escrever código para apps Dart e Flutter. Ele usa padrões modernos para criar apps robustos e fáceis de gerenciar.