swift-concurrency-pro
यह क्या करती है
यह स्किल आपके AI से वह Swift कोड जँचवाती है जो async और await इस्तेमाल करता है, और ऐसी गलतियाँ ढूँढती है जिनसे क्रैश या race condition हो सकती है। यह उन Swift डेवलपर के लिए है जो सुरक्षित concurrent कोड चाहते हैं।
कब इस्तेमाल करें
- ✓जब आप Swift में async और await या actor वाला कोड लिख या बदल रहे हों।
- ✓जब आपको strict concurrency की चेतावनियाँ दिखें और उनका मतलब समझना हो।
- ✓जब आप Swift में async टेस्ट या cancellation संभालने के तरीके की समीक्षा चाहें।
Skill का लिंक
https://github.com/jacklandrin/OnlySwitch/blob/main/doc/skills/swift-concurrency-pro/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरे Swift नेटवर्किंग कोड में async की गलतियाँ जाँच कीजिए और बताइए कि क्या ठीक करना है।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट जोखिम वाले पैटर्न खोजता है और actor, task, cancellation और stream को 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 या उसके बाद के वर्ज़न के लिए है।
क्या यह concurrency की चेतावनियाँ ठीक करने में मदद कर सकती है?
हाँ। यह strict-concurrency की गलतियों को संभावित समाधानों से जोड़ती है।
जानकारी
लेखक का मूल विवरण
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
- अपडेट की गई
- 1/11/2026
कमेंट
- …
इस repository की और skills
onlyswitch-deeplink
6.0kआपके एजेंट को deeplink से Mac पर OnlySwitch की कार्रवाइयाँ चलाने देती है, जैसे ट्रैश खाली करना, कंप्यूटर जागता रखना या डार्क मोड बदलना।
app-store-review
6.0kयह आपके एजेंट को Apple ऐप का कोड App Store के नियमों से मिलाकर संभावित रिजेक्शन की समस्याएँ पहले ही पकड़ने में मदद करती है।
swift-testing-pro
6.0kयह आपके एजेंट को Swift Testing कोड लिखने और जाँचने में मदद करती है, जिसमें आधुनिक test API, async टेस्ट पैटर्न और साफ़ टेस्ट ढाँचा शामिल है।
मिलती-जुलती skills
android-clean-architecture
280kयह आपके एजेंट को Android projects को व्यवस्थित तरीके से संभालने देता है। यह code को ऐसा ढांचा देता है कि उसकी देखभाल और नए features जोड़ना आसान हो।
compose-multiplatform-patterns
280kKMP projects में Compose Multiplatform और Jetpack Compose patterns इस्तेमाल करने में आपके एजेंट की मदद करता है। इसमें state, navigation, theming और performance शामिल हैं।
dart-flutter-patterns
280kयह आपके एजेंट को Dart और Flutter apps के लिए code लिखने देता है। यह आधुनिक patterns इस्तेमाल करके मज़बूत और आसानी से संभलने वाले apps बनाता है।