Agent skill

Swift Idioms

by irahardianto in irahardianto/awesome-agv

Swift idioms and best practices: value types, Optionals hygiene, protocol-oriented design, async/await and Actor concurrency, and XCTest.

MITAuto-check passedMobile

Install Swift Idioms

skills CLI
$ npx skills add irahardianto/awesome-agv --skill swift-idioms -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install irahardianto/awesome-agv swift-idioms --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/irahardianto/awesome-agv.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/swift-idioms .claude/skills/swift-idioms && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
swift-idioms
GitHub stars
156
Token cost
~2.1k tokens
SKILL.md length
290 words
Files
1
Skills in repo
34
Repo updated
First seen
Licence
MIT

At a glance

Swift idioms and best practices: value types, Optionals hygiene, protocol-oriented design, async/await and Actor concurrency, and XCTest.

  • Works in 3 steps: Prefer structs over classes — value… → Optionals — never force-unwrap (!) in… → Property wrappers for reusable behavior
  • Reviewing Swift iOS
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Server-side code

What it does

Swift Idioms is an agent skill from irahardianto/awesome-agv. Swift idioms and best practices: value types, Optionals hygiene, protocol-oriented design, async/await and Actor concurrency, and XCTest. Use when writing, refactoring, or reviewing Swift iOS, macOS, or server-side code.

Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Mobile, covering iOS development and Async programming. It works with iOS and macOS. The repository describes itself as: Comprehensive sets of standards and practices designed to elevate the capabilities of AI coding agents. The licence is MIT.

When your agent uses it

  • Reviewing Swift iOS
  • Server-side code

Example prompts

  • “/swift-idioms”

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. Prefer structs over classes — value semantics by default. Classes only for identity, inheritance, or reference counting.
  2. Optionals — never force-unwrap (!) in production
  3. Property wrappers for reusable behavior

What it can do on your machine

Read from SKILL.md and the folder at commit 9e997ba. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are swift).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Swift Idioms loads about 2.1k tokens when it runs. Until then it costs about 58 tokens; SKILL.md has 290 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~58
When it runs · the whole SKILL.md, loaded when a task matches
~2.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from irahardianto/awesome-agv at commit 9e997ba, republished under its MIT licence (© irahardianto). 290 words, ~2,120 tokens.

Download SKILL.mdSave it as .claude/skills/swift-idioms/SKILL.md (or your agent's skills folder).
name
swift-idioms
description
Swift idioms and best practices: value types, Optionals hygiene, protocol-oriented design, async/await and Actor concurrency, and XCTest. Use when writing, refactoring, or reviewing Swift iOS, macOS, or server-side code.

Swift Idioms and Patterns

Swift rewards value types, optionals, and protocol-oriented design. Idiomatic Swift = safe, expressive, Swifty.

Scope: Swift coding idioms. Test naming: .agents/rules/testing-strategy.md.

Value Types and Optionals
  1. Prefer structs over classes — value semantics by default. Classes only for identity, inheritance, or reference counting.

  2. Optionals — never force-unwrap (!) in production:

    swift
    // ✅ Guard let for early exit
    guard let task = storage.findById(id) else {
        throw TaskError.notFound(id)
    }
    
    // ✅ Optional chaining
    let title = task?.title ?? "Untitled"
    
    // ✅ if let for conditional binding
    if let deadline = task.deadline {
        scheduleReminder(for: deadline)
    }
    
    // ❌ Force unwrap — crash risk
    let task = storage.findById(id)!
  3. Property wrappers for reusable behavior:

    swift
    @propertyWrapper
    struct Clamped<Value: Comparable> {
        var wrappedValue: Value {
            didSet { wrappedValue = min(max(wrappedValue, range.lowerBound), range.upperBound) }
        }
        let range: ClosedRange<Value>
    
        init(wrappedValue: Value, _ range: ClosedRange<Value>) {
            self.range = range
            self.wrappedValue = min(max(wrappedValue, range.lowerBound), range.upperBound)
        }
    }
    
    struct Task {
        @Clamped(0...100) var progress: Int = 0
    }
Error Handling

For universal error handling principles, see .agents/rules/error-handling-principles.md.

  1. Typed throws (Swift 6) or Error protocol:

    swift
    enum TaskError: Error, LocalizedError {
        case notFound(String)
        case validationFailed(field: String, message: String)
        case storageUnavailable
    
        var errorDescription: String? {
            switch self {
            case .notFound(let id): "Task '\(id)' not found"
            case .validationFailed(let field, let msg): "Validation failed on \(field): \(msg)"
            case .storageUnavailable: "Storage is unavailable"
            }
        }
    }
    
    func getTask(id: String) throws(TaskError) -> Task { ... }
  2. Result type for async callbacks (pre-async/await):

    swift
    func fetchTask(id: String) async -> Result<Task, TaskError> { ... }
  3. do/catch with pattern matching:

    swift
    do {
        let task = try getTask(id: "123")
        process(task)
    } catch TaskError.notFound(let id) {
        logger.warn("Task not found", metadata: ["taskId": id])
    } catch {
        logger.error("Unexpected error", metadata: ["error": "\(error)"])
    }
  4. defer for cleanup:

    swift
    func processFile(at path: String) throws -> Data {
        let handle = try FileHandle(forReadingFrom: URL(fileURLWithPath: path))
        defer { handle.closeFile() }  // ✅ Always runs on exit
    
        return handle.readDataToEndOfFile()
    }
Protocol-Oriented Design
  1. Protocols over abstract classes:

    swift
    // ✅ Interface defined as protocol
    protocol TaskStorage {
        func getById(_ id: String) async throws -> Task?
        func save(_ task: Task) async throws
    }
    
    // ✅ Production implementation
    struct PostgresTaskStorage: TaskStorage {
        let pool: ConnectionPool
    
        func getById(_ id: String) async throws -> Task? {
            try await pool.query("SELECT * FROM tasks WHERE id = $1", [id]).first
        }
    
        func save(_ task: Task) async throws {
            try await pool.execute("INSERT INTO tasks ...", [task.id, task.title])
        }
    }
    
    // ✅ Test implementation
    struct MockTaskStorage: TaskStorage {
        var tasks: [Task] = []
    
        func getById(_ id: String) async throws -> Task? {
            tasks.first { $0.id == id }
        }
    
        func save(_ task: Task) async throws {
            tasks.append(task)
        }
    }
  2. Protocol extensions for default implementations:

    swift
    protocol Identifiable {
        var id: String { get }
    }
    
    extension Identifiable {
        var isNew: Bool { id.isEmpty }
    }
  3. Associated types for generic protocols:

    swift
    protocol Repository {
        associatedtype Entity
        func findById(_ id: String) async throws -> Entity?
        func save(_ entity: Entity) async throws
    }
Show full SKILL.md (284 more words)Show less
Concurrency
  1. Structured concurrency with async/await:

    swift
    func loadDashboard() async throws -> Dashboard {
        async let user = fetchUser(id)
        async let tasks = fetchTasks(userId: id)
        async let stats = fetchStats()
    
        return Dashboard(
            user: try await user,
            tasks: try await tasks,
            stats: try await stats
        )
    }
  2. @Sendable for closures crossing concurrency domains.

  3. Actors for thread-safe mutable state:

    swift
    actor TaskCache {
        private var cache: [String: Task] = [:]
    
        func get(_ id: String) -> Task? { cache[id] }
        func set(_ id: String, task: Task) { cache[id] = task }
        func invalidate(_ id: String) { cache.removeValue(forKey: id) }
    }
    
    // ✅ Safe concurrent access
    let cache = TaskCache()
    await cache.set("123", task: newTask)
    if let task = await cache.get("123") { ... }
  4. TaskGroup for dynamic concurrency:

    swift
    func fetchAllTasks(ids: [String]) async throws -> [Task] {
        try await withThrowingTaskGroup(of: Task.self) { group in
            for id in ids {
                group.addTask { try await fetchTask(id: id) }
            }
            return try await group.reduce(into: []) { $0.append($1) }
        }
    }
Naming (Swift API Design Guidelines)
  1. camelCase for functions, properties, variables.
  2. PascalCase for types, protocols, enums.
  3. Omit needless words — remove(at:) not removeItem(atIndex:).
  4. Protocols for capabilities use -able/-ible: Codable, Identifiable.
  5. Factory methods use make prefix: makeIterator().
  6. Boolean properties read as assertions: isEmpty, hasChanges, isValid.
Anti-Patterns
  • ❌ Force unwrap (!) in production code — crashes at runtime
  • ❌ var when let suffices — always prefer immutability
  • ❌ Classes when structs work — unnecessary reference semantics
  • ❌ Stringly-typed APIs — use enums for finite option sets
  • ❌ Massive view controllers — extract to view models, coordinators
  • ❌ try? silently discarding errors — log or handle the error case
  • ❌ Nested if let pyramids — use guard let for early returns
swift
// ❌ Pyramid of doom
if let user = getUser() {
    if let tasks = getTasks(for: user) {
        if let first = tasks.first {
            process(first)
        }
    }
}

// ✅ Flat with guard
guard let user = getUser() else { return }
guard let tasks = getTasks(for: user), let first = tasks.first else { return }
process(first)
Testing

XCTest or Swift Testing (6.0+). Mock via protocols.

swift
// XCTest
final class TaskServiceTests: XCTestCase {
    func testGetTask_returnsNotFound() async throws {
        let storage = MockTaskStorage()
        let service = TaskService(storage: storage)

        do {
            _ = try await service.getTask(id: "999")
            XCTFail("Expected notFound error")
        } catch TaskError.notFound(let id) {
            XCTAssertEqual(id, "999")
        }
    }
}

// Swift Testing (6.0+)
@Test func getTask_returnsNotFound() async throws {
    let storage = MockTaskStorage()
    let service = TaskService(storage: storage)

    #expect(throws: TaskError.notFound("999")) {
        try await service.getTask(id: "999")
    }
}
Formatting and Static Analysis
ToolPurposeCommand
swift-formatFormattingswift-format -i -r Sources/
SwiftLintLintingswiftlint lint --strict
Xcode AnalyzerStatic analysisBuilt-in
  • Code Idioms and Conventions .agents/rules/code-idioms-and-conventions.md
  • Testing Strategy .agents/rules/testing-strategy.md
  • Error Handling Principles .agents/rules/error-handling-principles.md
  • Concurrency and Threading Principles @.agents/rules/concurrency-and-threading-principles.md

© irahardianto, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/swift-idioms of irahardianto/awesome-agv.

Open the folder on GitHubat commit 9e997ba

Compare with similar skills

Swift Idioms next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Swift Idioms compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Swift Idioms this skillirahardianto/awesome-agv156—~2.1kAutomated safety check: PassMIT
Swift ExpertJeffallan/claude-skills12k—~1.5kAutomated safety check: PassMIT
Swift ConcurrencyHoangNguyen0403/agent-skills-standard572—~545Automated safety check: PassMIT
Swift ExpertFNOSP/FlyNarwhal509—~813Automated safety check: PassAGPL-3.0
Stellar iOS Mac SDKSoneso/stellar-ios-mac-sdk132—~4.3kAutomated safety check: PassApache-2.0
iOS Networkingdpearson2699/swift-ios-skills1.2k—~4.2kAutomated safety check: PassCustom licence

Similar skills

  • Swift Expert

    Jeffallan/claude-skills

    Builds Swift apps for Apple platforms with SwiftUI, protocol-oriented design, async/await, actors and Sendable checks, verified with swift build and swift test.

    12k GitHub stars~1.5k tokensUpdated 7 days ago
    MobileAuto-check passed
  • Swift Concurrency

    HoangNguyen0403/agent-skills-standard

    Implement async/await, Actors, and structured concurrency in Swift.

    572 GitHub stars~545 tokensUpdated yesterday
    MobileAuto-check passed
  • Swift Expert

    FNOSP/FlyNarwhal

    A skill your agent uses when building iOS/macOS applications with Swift 5.9+, SwiftUI, or async/await concurrency.

    509 GitHub stars~813 tokensUpdated 2 days ago
    MobileAuto-check passed
  • Stellar iOS Mac SDK

    Soneso/stellar-ios-mac-sdk

    Guides Stellar blockchain development in Swift using stellar-ios-mac-sdk.

    132 GitHub stars~4.3k tokensUpdated 2 days ago
    Backend & APIsAuto-check passed
  • iOS Networking

    dpearson2699/swift-ios-skills

    Build, review, or improve networking code in iOS/macOS apps using URLSession with async/await, structured concurrency, and modern Swift patterns.

    1.2k GitHub stars~4.2k tokensUpdated 2 mo ago
    Backend & APIsAuto-check passed
  • Official

    Resolves .NET runtime frames in Apple .ips crash logs to function names, source files and line numbers using dSYM symbols, atos and the Microsoft symbol server.

    5.6k GitHub starsUsed in 1 repo~2.4k tokens
    MobileAuto-check passed

More from irahardianto/awesome-agv

All 34 skills in this repo
  • Distinctive Frontend Design Builder

    irahardianto/awesome-agv

    Commits to one bold aesthetic direction, sets up a CSS token system for it, then builds the interface in Vue or plain HTML using those tokens.

    156 GitHub stars~2.4k tokensUpdated 6 days ago
    Auto-check passed
  • Perf Optimization

    irahardianto/awesome-agv

    Profile-driven performance optimization protocol. An agent skill from irahardianto/awesome-agv.

    156 GitHub stars~4.3k tokensUpdated 6 days ago
    Auto-check passed
  • Angular Idioms and Patterns

    irahardianto/awesome-agv

    Coding conventions for Angular 19 and later: standalone components, signals, OnPush change detection, lazy routes and where RxJS still belongs.

    156 GitHub stars~3.8k tokensUpdated 6 days ago
    Auto-check passed
  • CI/CD Pipeline Principles

    irahardianto/awesome-agv

    Rules for designing CI/CD pipelines in layers: universal lint, test and scan stages, container builds with SBOM attestation, and GitOps for orchestrated deployments.

    156 GitHub stars~2.7k tokensUpdated 6 days ago
    Auto-check: notes
  • Hono Idioms

    irahardianto/awesome-agv

    Hono lightweight web framework patterns: type-safe route handlers, middleware composition, Zod validation, and RPC clients for Cloudflare Workers, Node, or Bun.

    156 GitHub stars~3k tokensUpdated 6 days ago
    Auto-check passed
  • Mobile Testing

    irahardianto/awesome-agv

    Mobile E2E testing patterns — Flutter integrationtest, Patrol, Maestro, golden testing, device matrix, and test data management.

    156 GitHub stars~1.8k tokensUpdated 6 days ago
    Auto-check: notes

Works with

Questions about Swift Idioms

What does Swift Idioms do?

Swift idioms and best practices: value types, Optionals hygiene, protocol-oriented design, async/await and Actor concurrency, and XCTest. Swift Idioms is an agent skill from irahardianto/awesome-agv. Swift idioms and best practices: value types, Optionals hygiene, protocol-oriented design, async/await and Actor concurrency, and XCTest.

When should I use Swift Idioms?

Swift Idioms fits situations like: reviewing Swift iOS; server-side code.

How do I install Swift Idioms in Claude Code?

Run `npx skills add irahardianto/awesome-agv --skill swift-idioms -a claude-code`. Or copy the skill folder (.agents/skills/swift-idioms in irahardianto/awesome-agv) into .claude/skills/swift-idioms in your project. Claude Code loads it when a task matches its description.

How do I install Swift Idioms in Codex?

Run `npx skills add irahardianto/awesome-agv --skill swift-idioms -a codex`. Or copy the skill folder (.agents/skills/swift-idioms in irahardianto/awesome-agv) into .agents/skills/swift-idioms in your project. Codex loads it when a task matches its description.

Can I use Swift Idioms in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add irahardianto/awesome-agv --skill swift-idioms -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/swift-idioms, .gemini/skills/swift-idioms, .github/skills/swift-idioms and .opencode/skills/swift-idioms in your project.

What does Swift Idioms need to run?

SKILL.md names no scripts, command-line tools or credentials: Swift Idioms is instructions for the agent only.

Does Swift Idioms access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Swift Idioms safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Swift Idioms use?

Swift Idioms is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Swift Idioms use?

About 2.1k tokens (SKILL.md is roughly 8.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Swift Idioms?

Skills that share tags, products or a category with Swift Idioms: Swift Expert (Jeffallan/claude-skills, 12k stars), Swift Concurrency (HoangNguyen0403/agent-skills-standard, 572 stars), Swift Expert (FNOSP/FlyNarwhal, 509 stars) and Stellar iOS Mac SDK (Soneso/stellar-ios-mac-sdk, 132 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Swift Idioms?

irahardianto (a GitHub user) maintains it in irahardianto/awesome-agv, which has 156 GitHub stars. The repository holds 34 skills in this directory. The repository was last updated on October 5, 2026.

Source: irahardianto/awesome-agv on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.