S

swift-expert

by @jeffallanv
4.6(23)

Swift言語に精通し、iOS、macOS、watchOS、tvOSを含む複数のプラットフォーム向けに高性能でユーザーフレンドリーなアプリケーションの構築を担当します。

Swift LanguageiOS DevelopmentmacOS DevelopmentXcodeSwiftUI/UIKitGitHub
インストール方法
npx skills add jeffallan/claude-skills --skill swift-expert
compare_arrows

Before / After 効果比較

1
使用前

Appleプラットフォーム向けアプリケーション開発では、UIレイアウトと状態管理が複雑で、コードが冗長になり保守が困難です。これにより、アプリケーションのパフォーマンスが低下し、ユーザーエクスペリエンスが損なわれ、開発サイクルが長期化します。

使用後

iOS/macOSアプリケーションを効率的に構築します。SwiftUIを活用してUI開発と状態管理を簡素化し、明確で理解しやすいコードを実現します。アプリケーションのパフォーマンスとユーザーエクスペリエンスを向上させ、開発プロセスを加速し、迅速なイテレーションを可能にします。

description SKILL.md


name: swift-expert description: Builds iOS/macOS/watchOS/tvOS applications, implements SwiftUI views and state management, designs protocol-oriented architectures, handles async/await concurrency, implements actors for thread safety, and debugs Swift-specific issues. Use when building iOS/macOS applications with Swift 5.9+, SwiftUI, or async/await concurrency. Invoke for protocol-oriented programming, SwiftUI state management, actors, server-side Swift, UIKit integration, Combine, or Vapor. license: MIT metadata: author: https://github.com/Jeffallan version: "1.1.0" domain: language triggers: Swift, SwiftUI, iOS development, macOS development, async/await Swift, Combine, UIKit, Vapor role: specialist scope: implementation output-format: code related-skills:

Swift Expert

Core Workflow

  1. Architecture Analysis - Identify platform targets, dependencies, design patterns
  2. Design Protocols - Create protocol-first APIs with associated types
  3. Implement - Write type-safe code with async/await and value semantics
  4. Optimize - Profile with Instruments, ensure thread safety
  5. Test - Write comprehensive tests with XCTest and async patterns

Validation checkpoints: After step 3, run swift build to verify compilation. After step 4, run swift build -warnings-as-errors to surface actor isolation and Sendable warnings. After step 5, run swift test and confirm all async tests pass.

Reference Guide

Load detailed guidance based on context:

TopicReferenceLoad When
SwiftUIreferences/swiftui-patterns.mdBuilding views, state management, modifiers
Concurrencyreferences/async-concurrency.mdasync/await, actors, structured concurrency
Protocolsreferences/protocol-oriented.mdProtocol design, generics, type erasure
Memoryreferences/memory-performance.mdARC, weak/unowned, performance optimization
Testingreferences/testing-patterns.mdXCTest, async tests, mocking strategies

Code Patterns

async/await — Correct vs. Incorrect

// ✅ DO: async/await with structured error handling
func fetchUser(id: String) async throws -> User {
    let url = URL(string: "https://api.example.com/users/\(id)")!
    let (data, _) = try await URLSession.shared.data(from: url)
    return try JSONDecoder().decode(User.self, from: data)
}

// ❌ DON'T: mixing completion handlers with async context
func fetchUser(id: String) async throws -> User {
    return try await withCheckedThrowingContinuation { continuation in
        // Avoid wrapping existing async APIs this way when a native async version exists
        legacyFetch(id: id) { result in
            continuation.resume(with: result)
        }
    }
}

SwiftUI State Management

// ✅ DO: use @Observable (Swift 5.9+) for view models
@Observable
final class CounterViewModel {
    var count = 0
    func increment() { count += 1 }
}

struct CounterView: View {
    @State private var vm = CounterViewModel()

    var body: some View {
        VStack {
            Text("\(vm.count)")
            Button("Increment", action: vm.increment)
        }
    }
}

// ❌ DON'T: reach for ObservableObject/Published when @Observable suffices
class LegacyViewModel: ObservableObject {
    @Published var count = 0  // Unnecessary boilerplate in Swift 5.9+
}

Protocol-Oriented Architecture

// ✅ DO: define capability protocols with associated types
protocol Repository<Entity> {
    associatedtype Entity: Identifiable
    func fetch(id: Entity.ID) async throws -> Entity
    func save(_ entity: Entity) async throws
}

struct UserRepository: Repository {
    typealias Entity = User
    func fetch(id: UUID) async throws -> User { /* … */ }
    func save(_ user: User) async throws { /* … */ }
}

// ❌ DON'T: use classes as base types when a protocol fits
class BaseRepository {  // Avoid class inheritance for shared behavior
    func fetch(id: UUID) async throws -> Any { fatalError("Override required") }
}

Actor for Thread Safety

// ✅ DO: isolate mutable shared state in an actor
actor ImageCache {
    private var cache: [URL: UIImage] = [:]

    func image(for url: URL) -> UIImage? { cache[url] }
    func store(_ image: UIImage, for url: URL) { cache[url] = image }
}

// ❌ DON'T: use a class with manual locking
class UnsafeImageCache {
    private var cache: [URL: UIImage] = [:]
    private let lock = NSLock()  // Error-prone; prefer actor isolation
    func image(for url: URL) -> UIImage? {
        lock.lock(); defer { lock.unlock() }
        return cache[url]
    }
}

Constraints

MUST DO

  • Use type hints and inference appropriately
  • Follow Swift API Design Guidelines
  • Use async/await for asynchronous operations (see pattern above)
  • Ensure Sendable compliance for concurrency
  • Use value types (struct/enum) by default
  • Document APIs with markup comments (/// …)
  • Use property wrappers for cross-cutting concerns
  • Profile with Instruments before optimizing

MUST NOT DO

  • Use force unwrapping (!) without justification
  • Create retain cycles in closures
  • Mix synchronous and asynchronous code improperly
  • Ignore actor isolation warnings
  • Use implicitly unwrapped optionals unnecessarily
  • Skip error handling
  • Use Objective-C patterns when Swift alternatives exist
  • Hardcode platform-specific values

Output Templates

When implementing Swift features, provide:

  1. Protocol definitions and type aliases
  2. Model types (structs/classes with value semantics)
  3. View implementations (SwiftUI) or view controllers
  4. Tests demonstrating usage
  5. Brief explanation of architectural decisions

forumユーザーレビュー (0)

レビューを書く

効果
使いやすさ
ドキュメント
互換性

レビューなし

統計データ

インストール数900
評価4.6 / 5.0
バージョン
更新日2026年3月16日
比較事例1 件

ユーザー評価

4.6(23)
5
0%
4
0%
3
0%
2
0%
1
0%

この Skill を評価

0.0

対応プラットフォーム

🔧Claude Code
🔧OpenClaw
🔧OpenCode
🔧Codex
🔧Gemini CLI
🔧GitHub Copilot
🔧Amp
🔧Kimi CLI

タイムライン

作成2026年3月16日
最終更新2026年3月16日