用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/G1Joshi/Agent-Skills --skill swift命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | swift |
| description | Swift development for iOS/macOS with SwiftUI, async/await, and Combine. Use for .swift files. |
Modern Swift development with protocol-oriented programming and async/await.
.swift filesstruct User: Identifiable, Codable {
let id: UUID
var name: String
var email: String
var displayName: String {
name.capitalized
}
}
// 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 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) }
}
}
}
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)
actor UserCache {
private var cache: [UUID: User] = [:]
func get(_ id: UUID) -> User? { cache[id] }
func set(_ user: User) { cache[user.id] = user }
}
Do:
if let, guardDon't:
! except for IBOutletsweak/unowned| 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 |