swift-error-handling-pro
Skill5 starsChanged 11 days agoMITView on GitHub
Reviews Swift error handling for modern patterns including typed throws, Result vs throws, LocalizedError conformance, and async error propagation. Use when writing or reviewing Swift error types and throwing functions.
In this repository19 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- app-intents-proSkill
- coredata-swift6-proSkill
- instruments-profiling-proSkill
- motion-design-proSkill
- store-compliance-proSkill
- swift-accessibility-proSkill
- swift-adaptive-layout-proSkill
- swift-concurrency-proSkill
- swiftdata-proSkill
- swift-design-system-proSkill
- swift-docc-proSkill
- swift-logging-proSkill
- swift-memory-storage-proSkill
- swift-modularization-proSkill
- swift-package-proSkill
- swift-testing-proSkill
- swiftui-proSkill
- xcode-security-proSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 2 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
Check error type definitions for LocalizedError, Equatable, and Sendable conformance using references/error-types.md.
- Very specific: line 17
Check async error propagation patterns using references/async-errors.md.
- Distinctive: line 20
If doing a partial review, load only the relevant reference files.
- Very specific: line 26
Prefer throws over Result in modern async code — async throws reads more naturally than returning a Result.
- Very specific: line 29
Never use try! or try? to silence errors that could meaningfully be handled or surfaced.
- Very specific: line 30
Avoid catch { } blocks that swallow the error — at minimum, log it.
- Distinctive: line 31
Don't wrap errors in nested types unnecessarily — flatten error hierarchies where possible.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Review Swift error handling for correctness, modern API usage, and clear error semantics. Report only genuine problems - do not nitpick or invent issues.
Review process:
- Check error type definitions for
LocalizedError,Equatable, andSendableconformance usingreferences/error-types.md. - Evaluate whether typed throws (Swift 6.0+) would clarify the API using
references/typed-throws.md. - Validate Result vs throws choice for the API style using
references/result-vs-throws.md. - Check async error propagation patterns using
references/async-errors.md. - Flag swallowed errors (catch blocks that ignore errors silently).
If doing a partial review, load only the relevant reference files.
Core Instructions
- Target Swift 6.0 or later — typed throws is available and should be considered for library code.
- Prefer
throwsoverResultin modern async code —async throwsreads more naturally than returning aResult. - Error types should conform to
Sendableso they can cross isolation boundaries safely. - Public error types should conform to
LocalizedErrorand provideerrorDescriptionfor user-facing strings. - Never use
try!ortry?to silence errors that could meaningfully be handled or surfaced. - Avoid
catch { }blocks that swallow the error — at minimum, log it. - Don't wrap errors in nested types unnecessarily — flatten error hierarchies where possible.
Output Format
Organize findings by file. For each issue:
- State the file and relevant line(s).
- Name the rule being violated.
- Show a brief before/after code fix.
Skip files with no issues. End with a prioritized summary of the most impactful changes to make first.
Example output:
Sources/Storage/FileStoreError.swift
Line 12: Public error type should conform to LocalizedError for user-facing strings.
// Before
public enum FileStoreError: Error {
case readFailed
case writeFailed
}
// After
public enum FileStoreError: LocalizedError {
case readFailed
case writeFailed
public var errorDescription: String? {
switch self {
case .readFailed: "Failed to read from disk."
case .writeFailed: "Failed to write to disk."
}
}
}Line 34: Use typed throws for clearer API contract.
// Before
public func read() throws -> Data
// After
public func read() throws(FileStoreError) -> DataSummary
- API clarity (high): Public error types lack
LocalizedErrorconformance, making error messages opaque to consumers. - Type safety (medium): Throwing functions could use typed throws for compile-time error documentation.
End of example.
References
references/error-types.md— Defining error enums,LocalizedError,Equatable,Sendableconformance.references/typed-throws.md— Swift 6.0 typed throws syntax, when to use, performance benefits, migration.references/result-vs-throws.md— When to useResult<T, E>vsthrows, async considerations, callback APIs.references/async-errors.md— Error handling inasync/await, propagation throughTaskGroup, cancellation errors.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

