Skip to content

dpearson2699/swift-ios-skills / skills/swift-language

swift-language

Verified

Apply modern Swift language patterns and idioms for non-concurrency, non-SwiftUI code. Covers if/switch expressions (Swift 5.9+), typed throws (Swift 6+), result builders, property wrappers, opaque and existential types (some vs any), guard patterns, Never type, Regex builders (Swift 5.7+), basic Codable shaping (CodingKeys, custom decoding, nested containers), modern collection APIs (count(where:), contains(where:), replacing()), basic FormatStyle usage, and string interpolation patterns. Use when writing core Swift code involving generics, protocols, enums, closures, or modern language features; route deep Codable to swift-codable, detailed formatting/localization to swift-formatstyle, and API naming to swift-api-design-guidelines.

FileKindSize
SKILL.mdskill md14.8 KB
evals/evals.jsonconfig4.8 KB
references/swift-attributes-interop.mdmarkdown3.7 KB
references/swift-patterns-extended.mdmarkdown13.2 KB

evals/evals.json

View on GitHub
{
  "skill_name": "swift-language",
  "evals": [
    {
      "id": 0,
      "name": "modern-language-refactor",
      "prompt": "Review and modernize this Swift helper without changing behavior. Use current Swift language idioms where they help, but keep the answer concise.\n\n```swift\nenum Priority { case low, normal, high }\nenum ValidationError: Error { case empty, tooLong }\n\nfunc validateTitle(_ title: String) throws -> String {\n    if title.isEmpty {\n        throw ValidationError.empty\n    }\n    if title.count > 80 {\n        throw ValidationError.tooLong\n    }\n    return title.trimmingCharacters(in: .whitespacesAndNewlines)\n}\n\nfunc iconName(priority: Priority) -> String {\n    var name = \"circle\"\n    switch priority {\n    case .low:\n        name = \"arrow.down.circle\"\n    case .normal:\n        name = \"circle\"\n    case .high:\n        name = \"exclamationmark.circle\"\n    }\n    return name\n}\n\nfunc summarize(_ tags: [String]) -> String {\n    var urgentCount = 0\n    for tag in tags {\n        if tag == \"urgent\" { urgentCount += 1 }\n    }\n    return \"urgent: \\(urgentCount)\"\n}\n```",
      "expected_output": "A concise modernization that uses guard preconditions, typed throws for the single validation error domain, switch expressions for conditional return, collection APIs such as count(where:), and explains why each change is appropriate.",
      "files": [],
      "assertions": [
        "Uses `throws(ValidationError)` or explicitly recommends typed throws for the single validation error domain.",
        "Uses `guard` for validation preconditions in `validateTitle(_:)`.",
        "Rewrites `iconName(priority:)` with a `switch` expression or equivalent single-expression return without a mutable temporary variable.",
        "Uses `count(where:)` rather than a manual loop for counting urgent tags.",
        "Keeps the answer focused on Swift language idioms and does not expand into SwiftUI, concurrency, or lint configuration."
      ]
    },
    {
      "id": 1,
      "name": "swift63-interop-attributes",
      "prompt": "Correct this Swift 6.3 interoperability/performance note for a team wiki. The draft says: `@c func export(_ bytes: UnsafeBufferPointer<UInt8>) -> Int32` is valid C export syntax, `@specialize` is the official function-specialization attribute, `@inline(always)` is just a hint, and module selectors are written `ModuleName.symbol`.\n\nGive a corrected note with minimal Swift examples.",
      "expected_output": "A source-grounded correction that uses a C-compatible @c signature, names @specialized as the official explicit-specialization attribute, treats @inline(always) as a guaranteed inlining request that can fail when impossible, and uses ModuleName::symbol module selectors.",
      "files": [],
      "assertions": [
        "Rejects `UnsafeBufferPointer<UInt8>` in an `@c` exported function signature because it is a Swift struct, not a C-representable parameter.",
        "Shows an `@c` example using C-compatible pointer and scalar types, optionally with a custom C symbol name.",
        "Uses `@specialized`, not `@specialize`, for explicit specialization.",
        "States that Swift 6.3 `@inline(always)` guarantees inlining for direct calls and can produce an error when inlining is impossible.",
        "Uses `ModuleName::symbol` syntax for module selectors."
      ]
    },
    {
      "id": 2,
      "name": "sibling-boundary-routing",
      "prompt": "I have three cleanup requests in an iOS package: build full Codable API models with snake_case key strategies and date decoding, design locale-sensitive currency/date/list formatting for several markets, and decide whether a reusable Swift helper should use `some`, `any`, or `Never`. Which parts should the Swift language skill own, and which should be routed to sibling skills? Include only minimal examples.",
      "expected_output": "A boundary-aware routing answer that keeps swift-language focused on core type-system features such as some/any/Never, routes deep Codable/API decoding to swift-codable, routes detailed formatting and localization-sensitive display work to swift-formatstyle or ios-localization, and avoids implementing the sibling domains.",
      "files": [],
      "assertions": [
        "Says swift-language owns the core type-system/language decision around `some`, `any`, and `Never`.",
        "Correctly explains that `Never` is uninhabited/bottom-type-like in expression contexts but does not implicitly conform to arbitrary protocols.",
        "Routes full Codable API model design, key strategies, and date decoding to `swift-codable`.",
        "Routes detailed FormatStyle and locale-sensitive display work to `swift-formatstyle` and mentions localization review when appropriate.",
        "Does not provide a full Codable model suite or full formatting/localization implementation."
      ]
    }
  ]
}
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall