From qe-framework
Builds iOS/macOS/watchOS/tvOS apps with Swift, SwiftUI, async/await, actors, protocol-oriented design, UIKit, Combine, and Vapor. Invoke for Swift-specific debugging, concurrency, and architecture.
How this skill is triggered — by the user, by Claude, or both
Slash command
/qe-framework:Qswift-expertThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
1. **Architecture Analysis** - Identify platform targets, dependencies, design patterns
Validation checkpoints: After step 3, run
swift buildto verify compilation. After step 4, runswift build -warnings-as-errorsto surface actor isolation and Sendable warnings. After step 5, runswift testand confirm all async tests pass.
Load detailed guidance based on context:
| Topic | Reference | Load When |
|---|---|---|
| SwiftUI | references/swiftui-patterns.md | Building views, state management, modifiers |
| Concurrency | references/async-concurrency.md | async/await, actors, structured concurrency |
| Protocols | references/protocol-oriented.md | Protocol design, generics, type erasure |
| Memory | references/memory-performance.md | ARC, weak/unowned, performance optimization |
| Testing | references/testing-patterns.md | XCTest, async tests, mocking strategies |
/// A protocol defining repository behavior for generic entity types.
protocol DataRepository<T> {
/// The entity type this repository manages.
associatedtype T: Identifiable
/// Fetches an entity by its identifier.
/// - Parameters:
/// - id: The unique identifier of the entity.
/// - Returns: The fetched entity.
/// - Throws: `RepositoryError` if fetch fails.
func fetch(id: T.ID) async throws -> T
}
/// A concrete repository implementation for User entities.
struct UserRepository: DataRepository {
typealias T = User
func fetch(id: UUID) async throws -> User {
// Implementation with proper error handling
return User(id: id, name: "John")
}
}
/// Errors that can occur during repository operations.
enum RepositoryError: Error, LocalizedError {
case notFound
case networkTimeout
case invalidResponse
var errorDescription: String? {
switch self {
case .notFound: return "Entity not found"
case .networkTimeout: return "Request timed out"
case .invalidResponse: return "Invalid server response"
}
}
}
/// Fetches data with comprehensive error handling.
/// - Parameters:
/// - url: The endpoint URL.
/// - Returns: Decoded response data.
/// - Throws: `RepositoryError` on network or parsing failure.
func fetchData(from url: URL) async throws(RepositoryError) -> Data {
do {
let (data, response) = try await URLSession.shared.data(from: url)
guard (response as? HTTPURLResponse)?.statusCode == 200 else {
throw .invalidResponse
}
return data
} catch {
throw .networkTimeout
}
}
/// Thread-safe image cache using actor isolation.
actor ImageCache {
/// Stores cached images keyed by URL.
private var storage: [URL: UIImage] = [:]
/// Retrieves a cached image.
/// - Parameters:
/// - url: The image URL key.
/// - Returns: Cached image or nil.
nonisolated func image(for url: URL) -> UIImage? {
// Note: nonisolated read from stored property requires synchronization
return storage[url]
}
/// Stores an image in the cache.
/// - Parameters:
/// - image: The image to cache.
/// - url: The key URL.
func store(_ image: UIImage, for url: URL) async {
storage[url] = image
}
}
/// Example async/await usage with error handling.
func fetchAndCache(url: URL, cache: ImageCache) async throws -> UIImage {
let (data, _) = try await URLSession.shared.data(from: url)
guard let image = UIImage(data: data) else {
throw RepositoryError.invalidResponse
}
await cache.store(image, for: url)
return image
}
/// Performs a specific task with documented parameters and return value.
///
/// - Parameters:
/// - param1: Description of the first parameter and its constraints.
/// - param2: Description of the second parameter and expected type.
/// - Returns: Description of the return value and when it's nil/empty.
/// - Throws: `ErrorType` when specific failure conditions occur.
/// - Complexity: O(n) where n is the size of the input collection.
func exampleFunction(param1: String, param2: Int) async throws -> Result {
// Implementation
}
/// A view model managing user state and interactions.
///
/// This type centralizes business logic for user-facing features,
/// reducing code duplication across views. It uses @Observable for
/// automatic change propagation in SwiftUI.
@Observable
final class UserViewModel {
var user: User?
var isLoading = false
}
//
// UserRepository.swift
// MyApp
//
// Created by [Name] on [Date].
// Copyright [Year] [Company]. All rights reserved.
//
// Responsibilities:
// - Fetch and save user data from network
// - Cache responses to reduce network calls
// - Map API responses to model types
Commands:
swiftlint lint — Check for style violationsswiftlint --fix — Auto-correct fixable issuesswiftc -typecheck — Verify type safety without buildingConfiguration (.swiftlint.yml):
disabled_rules:
- trailing_whitespace
opt_in_rules:
- force_unwrapping
- missing_docs
line_length: 120
SecureEnclave or Keychain APIsNSSecureTransportRequired = true| Anti-Pattern | ❌ Wrong | ✅ Correct |
|---|---|---|
| Force Unwrap | let value = optionalValue! | guard let value = optionalValue else { return } |
| Massive View Controller | 500+ line UIViewController with all logic | Split into smaller views + ViewModel |
| Retain Cycles | [weak self] in { self?.property } without guard | Use guard let self else { return } pattern |
| Stringly-Typed APIs | userDefaults.string(forKey: "userName") | Define typed @UserDefault property wrapper |
| Not Using Value Types | class Model { var name: String } | Use struct Model { var name: String } |
async/await for asynchronous operations (see pattern above)Sendable compliance for concurrencystruct/enum) by default/// …)!) without justificationWhen implementing Swift features, provide:
npx claudepluginhub inho-team/qe-framework --plugin qe-frameworkCreates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.