### Install Skill with Codex / Cursor / Windsurf Source: https://context7.com/twostraws/swift-agent-skills/llms.txt Skills are plain-text instruction files loadable by AI tools supporting custom context. This example shows a generic pattern for cloning a skill and integrating it with Cursor or Windsurf. ```bash # Clone the desired skill git clone https://github.com/twostraws/Swift-Concurrency-Agent-Skill \ ~/.ai-skills/swift-concurrency-pro # For Cursor: add the skill file path to .cursorrules or the Cursor settings echo "$(cat ~/.ai-skills/swift-concurrency-pro/skill.md)" >> .cursorrules # For Windsurf: reference the file in the project's .windsurfrules cp ~/.ai-skills/swift-concurrency-pro/skill.md .windsurfrules ``` -------------------------------- ### App Store Connect CLI: List Apps and Builds Source: https://context7.com/twostraws/swift-agent-skills/llms.txt Automate App Store Connect tasks using the CLI skill. This example shows how to list all apps in your account and specific builds for an app. ```bash # Example: list all apps in your account xcrun altool --list-apps \ --apiKey "$APP_STORE_CONNECT_KEY_ID" \ --apiIssuer "$APP_STORE_CONNECT_ISSUER_ID" # Or use the official CLI tool the skill teaches: app-store-connect list-apps app-store-connect list-builds --app-id 123456789 --platform IOS ``` -------------------------------- ### Install Skill with Claude Code Source: https://context7.com/twostraws/swift-agent-skills/llms.txt Follow these steps to clone a skill repository and register it in your Claude Code configuration. The skill will then be automatically applied by Claude Code. ```bash # 1. Browse the index and pick a skill, e.g. SwiftUI Pro by Paul Hudson # 2. Clone the skill repository into a local skills directory git clone https://github.com/twostraws/SwiftUI-Agent-Skill ~/.claude/skills/swiftui-pro # 3. Register the skill in your Claude Code project configuration (.claude/config.json) # (exact field names depend on the Claude Code version you are using) cat >> .claude/config.json <<'EOF' { "skills": [ { "path": "~/.claude/skills/swiftui-pro" } ] } EOF # 4. Start Claude Code — it will now apply SwiftUI Pro guidance automatically claude ``` -------------------------------- ### SwiftUI Skill Example Prompt Source: https://context7.com/twostraws/swift-agent-skills/llms.txt This Swift code demonstrates a `ContentView` that can benefit from a loaded SwiftUI Pro skill. When active, the AI agent suggests refactoring techniques like extracting subviews and applying modifiers. ```swift // Example prompt benefiting from a SwiftUI Pro skill loaded into Claude Code: // "Refactor this view to follow proper SwiftUI composition rules." struct ContentView: View { @State private var items: [String] = ["Alpha", "Beta", "Gamma"] var body: some View { // With SwiftUI Pro skill active, the agent suggests extracting // subviews, applying .task modifiers, and using @ViewBuilder helpers. List(items, id: \.self) { item in ItemRow(title: item) } } } struct ItemRow: View { let title: String var body: some View { Text(title).font(.headline) } } ``` -------------------------------- ### Securely Save Sensitive Data to Keychain (Swift) Source: https://context7.com/twostraws/swift-agent-skills/llms.txt This example shows how to securely save sensitive data, like authentication tokens, to the iOS Keychain using the Security framework. It replaces existing entries and handles potential errors during the save operation. ```swift import Security func saveToken(_ token: String, account: String) throws { let data = Data(token.utf8) let query: [String: Any] = [ kSecClass as String: kSecClassGenericPassword, kSecAttrAccount as String: account, kSecValueData as String: data, kSecAttrAccessible as String: kSecAttrAccessibleWhenUnlockedThisDeviceOnly ] SecItemDelete(query as CFDictionary) // remove old value if present let status = SecItemAdd(query as CFDictionary, nil) guard status == errSecSuccess else { throw KeychainError.saveFailed(status) } } ``` -------------------------------- ### Swift Testing: Parameterized and Basic Tests Source: https://context7.com/twostraws/swift-agent-skills/llms.txt Demonstrates writing tests for a CartService using the Swift Testing framework. Includes a basic test for adding an item and a parameterized test for total price calculation. ```swift import Testing @Suite("CartService Tests") struct CartServiceTests { @Test("Adding an item increases item count") func addItemIncreasesCount() { var cart = CartService() cart.add(item: Item(id: "1", name: "Book", price: 9.99)) #expect(cart.itemCount == 1) } @Test("Total price is correct", arguments: [1, 3, 5]) func totalPriceCalculation(quantity: Int) { var cart = CartService() cart.add(item: Item(id: "2", name: "Pen", price: 1.50), quantity: quantity) #expect(cart.totalPrice == 1.50 * Double(quantity)) } } ``` -------------------------------- ### README Entry Template for New Skill Source: https://context7.com/twostraws/swift-agent-skills/llms.txt This markdown template is used for contributing a new skill to the project's README file. It specifies the required format for linking to the skill's repository and author. ```markdown ### My Framework Skills - [My Framework Expert](https://github.com/your-username/my-framework-skill) by [Your Name](https://github.com/your-username) ``` -------------------------------- ### Create SwiftData Model and Fetch Data Source: https://context7.com/twostraws/swift-agent-skills/llms.txt Defines a SwiftData model for a Task and demonstrates how to fetch incomplete tasks sorted by due date. Ensure SwiftData is configured in your project. ```swift import SwiftData @Model final class Task { var title: String var dueDate: Date var isCompleted: Bool init(title: String, dueDate: Date, isCompleted: Bool = false) { self.title = title self.dueDate = dueDate self.isCompleted = isCompleted } } // Fetch incomplete tasks sorted by due date let descriptor = FetchDescriptor( predicate: #Predicate { !$0.isCompleted }, sortBy: [SortDescriptor(\.dueDate)] ) let pendingTasks = try modelContext.fetch(descriptor) ``` -------------------------------- ### Swift Accessibility Skill: Semantic Labels and Traits Source: https://context7.com/twostraws/swift-agent-skills/llms.txt Use accessibility skills to suggest proper semantic labels and traits for UI elements. Ensure Dynamic Type support for varying text sizes. ```swift Button(action: submitOrder) { Label("Submit Order", systemImage: "cart.badge.plus") } .accessibilityLabel("Submit your order") .accessibilityHint("Double-tap to confirm and place the order") .accessibilityAddTraits(.isButton) // Dynamic Type support Text(product.name) .font(.headline) .dynamicTypeSize(.small ... .accessibility3) ``` -------------------------------- ### Concurrent Data Fetching with Swift Concurrency Source: https://context7.com/twostraws/swift-agent-skills/llms.txt Fetches user profile and posts concurrently using async/await. Cancellation is automatically propagated. An actor is included for caching profiles. ```swift // Prompt: "Fetch user profile and their posts concurrently, handle cancellation." func loadDashboard(userID: String) async throws -> Dashboard { async let profile = fetchProfile(userID: userID) async let posts = fetchPosts(userID: userID) // Both network calls run in parallel; cancellation propagates automatically return try await Dashboard(profile: profile, posts: posts) } actor ProfileCache { private var store: [String: Profile] = [: ] func profile(for id: String) -> Profile? { store[id] } func cache(_ profile: Profile, for id: String) { store[id] = profile } ``` -------------------------------- ### Swift Architecture Skill: Protocol-Oriented Design Source: https://context7.com/twostraws/swift-agent-skills/llms.txt Define clear module boundaries using protocols for better testability and maintainability. Inject concrete implementations at the composition root. ```swift // Architecture skill guidance: define clear module boundaries with protocols protocol UserRepositoryProtocol { func fetchUser(id: String) async throws -> User func saveUser(_ user: User) async throws } // Concrete implementation is injected at the composition root struct UserRepository: UserRepositoryProtocol { private let apiClient: APIClient init(apiClient: APIClient) { self.apiClient = apiClient } func fetchUser(id: String) async throws -> User { try await apiClient.get("/users/\(id)") } func saveUser(_ user: User) async throws { try await apiClient.put("/users/\(user.id)", body: user) } } // ViewModel depends only on the protocol — easy to test and swap @MainActor class UserViewModel: ObservableObject { @Published var user: User? private let repository: UserRepositoryProtocol init(repository: UserRepositoryProtocol) { self.repository = repository } func load(id: String) async { user = try? await repository.fetchUser(id: id) } } ``` -------------------------------- ### Generate Typed Fetch Request with Predicate (Swift) Source: https://context7.com/twostraws/swift-agent-skills/llms.txt This snippet demonstrates how to create a typed NSFetchRequest for Core Data, including setting predicates, sort descriptors, and fetch limits. It shows error handling for the fetch operation. ```swift let request: NSFetchRequest = CDTask.fetchRequest() request.predicate = NSPredicate(format: "isCompleted == %@ AND dueDate < %@", NSNumber(value: false), Date() as NSDate) request.sortDescriptors = [NSSortDescriptor(key: "dueDate", ascending: true)] request.fetchLimit = 50 do { let overdueTasks = try viewContext.fetch(request) overdueTasks.forEach { print($0.title ?? "Untitled") } } catch { print("Fetch failed: \(error.localizedDescription)") } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.