swift
Swift development for iOS/macOS with SwiftUI, async/await, and Combine. Use for .swift files.
Best use case
swift is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Swift development for iOS/macOS with SwiftUI, async/await, and Combine. Use for .swift files.
Teams using swift should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/swift/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How swift Compares
| Feature / Agent | swift | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Swift development for iOS/macOS with SwiftUI, async/await, and Combine. Use for .swift files.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Swift
Modern Swift development with protocol-oriented programming and async/await.
## When to Use
- Working with `.swift` files
- Building iOS/macOS applications
- SwiftUI development
- Server-side Swift with Vapor
## Quick Start
```swift
struct User: Identifiable, Codable {
let id: UUID
var name: String
var email: String
var displayName: String {
name.capitalized
}
}
```
## Core Concepts
### Value Types & Structs
```swift
// Prefer structs for data
struct User: Identifiable, Codable, Hashable {
let id: UUID
var name: String
var email: String
var createdAt: Date = .now
}
// Enums with associated values
enum NetworkError: Error, LocalizedError {
case invalidURL
case noData
case decodingError(Error)
var errorDescription: String? {
switch self {
case .invalidURL: return "Invalid URL"
case .noData: return "No data received"
case .decodingError(let error): return "Decoding failed: \(error)"
}
}
}
```
### Protocol-Oriented Programming
```swift
protocol Repository {
associatedtype Entity: Identifiable
func findById(_ id: Entity.ID) async throws -> Entity?
func save(_ entity: Entity) async throws -> Entity
func delete(_ entity: Entity) async throws
}
extension Repository {
func saveAll(_ entities: [Entity]) async throws -> [Entity] {
try await withThrowingTaskGroup(of: Entity.self) { group in
for entity in entities {
group.addTask { try await self.save(entity) }
}
return try await group.reduce(into: []) { $0.append($1) }
}
}
}
```
## Common Patterns
### Async/Await
```swift
func fetchUser(id: UUID) async throws -> User {
let url = URL(string: "https://api.example.com/users/\(id)")!
let (data, response) = try await URLSession.shared.data(from: url)
guard let httpResponse = response as? HTTPURLResponse,
httpResponse.statusCode == 200 else {
throw NetworkError.invalidResponse
}
return try JSONDecoder().decode(User.self, from: data)
}
// Parallel execution
async let user = fetchUser(id: userId)
async let orders = fetchOrders(userId: userId)
let (userResult, ordersResult) = try await (user, orders)
```
### Actors
```swift
actor UserCache {
private var cache: [UUID: User] = [:]
func get(_ id: UUID) -> User? { cache[id] }
func set(_ user: User) { cache[user.id] = user }
}
```
## Best Practices
**Do**:
- Prefer value types (structs, enums) over classes
- Use protocol-oriented programming
- Handle optionals safely with `if let`, `guard`
- Use async/await for concurrency
**Don't**:
- Force unwrap with `!` except for IBOutlets
- Use implicitly unwrapped optionals unnecessarily
- Ignore error handling
- Create reference cycles without `weak`/`unowned`
## Troubleshooting
| Error | Cause | Solution |
| ------------------------- | ------------------------------------ | -------------------- |
| `unexpectedly found nil` | Force unwrap of nil | Use optional binding |
| `Actor-isolated property` | Accessing actor from sync context | Use `await` |
| `Sendable closure` | Non-sendable type across concurrency | Make type Sendable |
## References
- [Swift.org Documentation](https://swift.org/documentation/)
- [Hacking with Swift](https://www.hackingwithswift.com/)Related Skills
swiftui
SwiftUI declarative Apple UI framework. Use for iOS/macOS.
template
Expert [skill-name] assistance covering [feature 1], [feature 2], and [feature 3]. Use when [working with X], [debugging Y], or [implementing Z].
zsh
Zsh shell with oh-my-zsh. Use for terminal shell.
zed
Zed high-performance collaborative editor. Use for fast editing.
xcode
Xcode Apple development IDE with simulators. Use for iOS/macOS development.
webstorm
WebStorm JavaScript IDE with debugging. Use for web development.
webpack
Webpack module bundler with loaders and plugins. Use for bundling.
warp
Warp modern terminal with AI. Use for terminal work.
vscode
Visual Studio Code editor with extensions and debugging. Use for code editing.
vite
Vite fast build tool with HMR. Use for modern frontend builds.
visual-studio
Visual Studio IDE for Windows with debugging and profiling. Use for .NET development.
vim
Vim text editor with motions, macros, and plugins. Use for terminal editing.