Modern Swift
Generates clean, modern Swift code snippets for SwiftUI views and related frontend tasks, optimized for performance.
Install on your platform
We auto-selected Claude Code based on this skill’s supported platforms.
Run in terminal (recommended)
claude mcp add modern-swift npx -- -y @trustedskills/modern-swift
Or manually add to ~/.claude/settings.json
{
"mcpServers": {
"modern-swift": {
"command": "npx",
"args": [
"-y",
"@trustedskills/modern-swift"
]
}
}
}Requires Claude Code (claude CLI). Run claude --version to verify your install.
About This Skill
What it does
This skill generates clean, modern Swift code snippets for SwiftUI views and related frontend tasks, optimized for performance using Swift 6.2+ features. It focuses on utilizing new concurrency patterns like async/await, @MainActor, and actor to replace older approaches (completion handlers, DispatchQueue, locks) and ensure compile-time safety against data races. The skill emphasizes leveraging these modern techniques for thread-safe code and efficient asynchronous operations.
When to use it
- When needing to convert existing completion handler based code to Swift's new
async/awaitsyntax. - For implementing UI updates that require execution on the main thread using
@MainActor. - When dealing with shared mutable state, replacing locks or serial queues with actors for safer concurrency.
- To run multiple asynchronous operations in parallel utilizing
TaskGroup. - When migrating legacy code to incorporate modern Swift attributes like
@preconcurrencyand@backDeployed.
Key capabilities
- Generates code using
async/awaitfor asynchronous operations. - Utilizes
@MainActorfor UI updates on the main thread. - Employs
actorfor managing shared mutable state safely. - Supports the use of
TaskGroupfor parallel task execution. - Provides guidance on implementing task cancellation with
Task.isCancelledandTask.checkCancellation().
Example prompts
- "Generate a SwiftUI view that fetches data asynchronously using
async/await." - "Show me how to update a UI element safely using
@MainActor." - "How do I use an actor to manage shared state in Swift?"
Tips & gotchas
- Reference Loading: Always load reference files, especially when dealing with concurrency patterns. This ensures the skill has access to necessary context and best practices.
- Avoid
@unchecked Sendable: Using this as a quick fix silences compiler errors but can mask potential data races; address the underlying issue instead. - Task Cancellation is Crucial: Remember to check
Task.isCancelledor callTask.checkCancellation()within loops for long-running operations to ensure cancellation signals are processed correctly.
Tags
TrustedSkills Verification
Unlike other registries that point to live repositories, TrustedSkills pins every skill to a verified commit hash. This protects you from malicious updates — what you install today is exactly what was reviewed and verified.
Security Audits
| Gen Agent Trust Hub | Pass |
| Socket | Pass |
| Snyk | Pass |
🌐 Community
Passed automated security scans.