Best for
- Use this skill when designing or reviewing Swift error surfaces.
- Use this skill when code hides recoverable failures in nil, strings, logs, or
- Use this skill when deciding between throws, typed throws, Result,
gaelic-ghost/socket/plugins/swift-lang/skills/swift-error-handling-style-workflow/SKILL.md
Design or repair Swift error handling style using throws, typed throws, Result, Optional, AsyncSequence failure types, domain errors, Cocoa bridging, and concise functional recovery paths.
Decision brief
Design or repair Swift error handling style using throws, typed throws, Result, Optional, AsyncSequence failure types, domain errors, Cocoa bridging, and concise functional recovery paths.
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/gaelic-ghost/socket --skill "plugins/swift-lang/skills/swift-error-handling-style-workflow"Inspect the Agent Skill "swift-error-handling-style-workflow" from https://github.com/gaelic-ghost/socket/blob/ccbde05d2d542ce20d1645b425c75dc531b53721/plugins/swift-lang/skills/swift-error-handling-style-workflow/SKILL.md at commit ccbde05d2d542ce20d1645b425c75dc531b53721. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
1. Identify the failure boundary: - operation - inputs - success value - expected absence - recoverable failures - programmer errors - framework or transport errors - async or streaming boundary 2. Choose the carrier: - nonoptional value when failure is impossible after construc…
Make Swift failure behavior clear at the call site and useful when something breaks.
Use repo-local guidance first. For general language behavior, prefer the Swift Book, Swift Standard Library docs, Swift Evolution, and Apple Foundation docs:
Use this skill when designing or reviewing Swift error surfaces.
Prefer typed throws for Swift-owned synchronous and structured-concurrency
Permission review
The documentation includes network, browsing, or remote request actions.
let data = try await fetch(url)Evidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 92/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 6 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Make Swift failure behavior clear at the call site and useful when something breaks.
The house style is concise, typed by default for Swift-owned failure surfaces, and functional in feel: fallible values should move through explicit carriers, error messages should explain the failed operation, and recovery should happen at the boundary that can actually choose a next step.
Use repo-local guidance first. For general language behavior, prefer the Swift Book, Swift Standard Library docs, Swift Evolution, and Apple Foundation docs:
nil, strings, logs, or
broad catch-all wrappers.throws, typed throws, Result,
Optional, AsyncSequence failure types, framework errors, or domain errors.do/catch, callback-era
Result-passing, weak diagnostics, or awkward Objective-C/Cocoa error
bridging.Optional when absence is expected and not diagnosticthrows or async throws when the operation forwards broad,
open-ended framework, filesystem, networking, database, plugin, or
dependency failures without adding a useful typed boundaryResult when success or failure must be stored, combined, cached, tested,
or delivered through a non-throwing callbackAsyncSequence failure types when values arrive over time and iteration can
failenum errors with associated values when the cases are closed
and meaningfulLocalizedError for user-visible or operator-facing descriptionsCustomNSError when Cocoa interop, error domains, codes, or user-info
keys matterRecoverableError only when the caller can present concrete recovery
choicestry and try await for straight-line fallible workmap, flatMap, mapError, Result.get(), and typed transforms when
the failure value is intentionally part of the pipelinefailed, invalid, or unknown errorthrows when forwarding broad framework, filesystem,
networking, database, plugin, or dependency failures without changing their
meaning.Result for value-level composition, storage, callback interop, batch
outcomes, and tests that need to assert failure as data.Optional only for ordinary absence. Do not erase useful failure
information to make a pipeline look tidy.Typed throws is the preferred house style for Swift-owned error surfaces, while
untyped throws remains the right tool for open-ended failure domains.
Use typed throws when:
catch handlingAvoid typed throws when:
any ErrorA small shared helper package could become useful if several repositories start needing the same concise diagnostic, wrapping, or recovery helpers.
Treat that as a separate design decision. A future package might explore generic helpers, variadic generics or parameter packs, and macros, but do not invent a local helper framework inside one app or skill unless the repeated call sites already exist and the package design has been discussed.
Use the root Socket maintainer plan at
docs/maintainers/errorhandles-package-plan.md when deciding whether that helper
belongs in Socket or in a separate Swift package repository.
Straight-line fallible work:
func loadManifest(at url: URL) async throws -> Manifest {
let data = try await fetch(url)
return try ManifestDecoder().decode(data)
}
Closed domain failures:
enum ManifestError: Error, Equatable {
case missingName(URL)
case unsupportedVersion(String)
}
func validate(_ manifest: Manifest) throws(ManifestError) -> Manifest {
guard let name = manifest.name else {
throw .missingName(manifest.sourceURL)
}
guard manifest.version.isSupported else {
throw .unsupportedVersion(manifest.version.rawValue)
}
return manifest
}
Stored or batched failures:
let results: [Result<Package, PackageLoadError>] = urls.map { url in
Result { try loadPackage(at: url) }
}
let packages = results.compactMap { try? $0.get() }
let failures = results.compactMap { result -> PackageLoadError? in
guard case let .failure(error) = result else { return nil }
return error
}
Operator-facing error context:
enum PackageLoadError: LocalizedError {
case unreadableManifest(url: URL, underlying: any Error)
var errorDescription: String? {
switch self {
case let .unreadableManifest(url, underlying):
"Could not read Package.swift at \(url.path). Check that the file exists, is readable, and contains valid Swift package syntax. Underlying error: \(underlying)"
}
}
}
Return:
Failure state: current operation, success value, absence, recoverable
failures, and programmer errors.Carrier choice: why throws, typed throws, Result, Optional,
AsyncSequence, existing framework errors, or domain errors fit.House-style changes: API signatures, error types, propagation, recovery,
and diagnostics to change.Examples: compact call-site or implementation sketch.Validation: compile, tests, and failure-case checks needed.nil, default values, or comments.do/catch is clearer.Frequently asked questions
Design or repair Swift error handling style using throws, typed throws, Result, Optional, AsyncSequence failure types, domain errors, Cocoa bridging, and concise functional recovery paths.
The source record exposes this install command: npx skills add https://github.com/gaelic-ghost/socket --skill "plugins/swift-lang/skills/swift-error-handling-style-workflow". Inspect the command and pinned source before running it.
Static rules flagged network in the source; the page lists the matching lines and excerpts.
Alternatives
prowler-cloud/prowler
PostgreSQL indexing best practices for Prowler: index design, partial indexes, partitioned table indexing, EXPLAIN ANALYZE validation, concurrent operations, monitoring, and maintenance. Trigger: When creating or modifying PostgreSQL indexes, analyzing query performance with EXPLAIN, debugging slow queries, reviewing index usage statistics, reindexing, dropping indexes, or working with partitioned table indexes. Also trigger when discussing index strategies, partial indexes, or index maintenance
oaustegard/claude-skills
Generate hierarchical _FEATURES.md files that describe what a codebase DOES from a user/consumer perspective, anchored to source symbols via tree-sitting. Supports large complex codebases through feature-driven decomposition into sub-feature files. Uses a multi-pass synthesis: orientation → detail → overview rewrite. Use when someone says "what does this do", "document features", "feature inventory", "_FEATURES.md", or needs to understand a codebase's purpose before modifying it. Complements tre
HKUDS/Vibe-Trading
Create, modify, and optimize quantitative trading strategies, then backtest and evaluate them.
vasilyu1983/AI-Agents-public
Guides iOS testing with XCTest, XCUITest, Swift Testing, simctl, and xcresult. Use when choosing destinations, controlling flakes, or parsing test artifacts for native apps.