ios-swift-api-design-reviewer
Skill4 starsChanged 3 months agoMITView on GitHub
Reviews Swift function, type, and protocol interfaces for alignment with the Swift API Design Guidelines, with emphasis on call-site clarity, naming, parameter labeling, mutability conventions, and modern async/throws patterns. Use for public APIs, reusable components, SDKs, and shared modules.
In this repository20 other files it gives its agents.
- AGENTS.mdAGENTS.md
- accessibility-annotationsSkill
- android-accessibility-validatorSkill
- android-compose-architecture-reviewSkill
- android-kotlin-api-design-reviewerSkill
- android-performance-profilerSkill
- flutter-accessibility-validatorSkill
- flutter-bug-investigationSkill
- flutter-code-reviewSkill
- flutter-design-architectureSkill
- flutter-feature-analysisSkill
- flutter-feature-implementationSkill
- flutter-performance-optimizerSkill
- ios-accessibility-validatorSkill
- ios-performance-profilerSkill
- ios-swiftui-architecture-reviewSkill
- shared-bug-investigationSkill
- shared-perf-comparison-videoSkill
- shared-product-motion-videoSkill
- shared-task-workflowSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
17 rules. About 0 are common, 7 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Follow established standard library conventions so your API “feels Swift”.
- Very specific: line 15
Prefer precise words over generic ones (data, info, manager, handler, util).
- Very specific: line 23
Avoid “noise” suffixes like String, Array, Data unless they add meaning.
- Very specific: line 27
Prefer predicates: is, has, can, should, did.
- Distinctive: line 53
Use labels to clarify roles, units, and semantics:
- Distinctive: line 57
Keep default parameters last when it improves scanning and discoverability.
- Distinctive: line 59
If there are multiple closures, label them clearly.
- Distinctive: line 60
If a closure is *configuration* rather than *action*, it may be clearer earlier.
- Very specific: line 75
Use optional only when nil is a meaningful “no value” state.
- Very specific: line 76
Use throws for failures that should be handled via do/catch.
- Distinctive: line 81
Prefer structs over tuples when:
- Very specific: line 88
Prefer async/await over completion handlers for new APIs.
- Very specific: line 89
Avoid Async suffixes unless required for disambiguation.
- Distinctive: line 93
Prefer being cancellation-cooperative rather than inventing custom cancel APIs.
- Very specific: line 94
Consider how the API behaves when the task is cancelled (does it throw CancellationError?).
- Very specific: line 96
Avoid marking pure data models @MainActor.
- Very specific: line 97
Keep UI-bound types @MainActor when they are truly view-facing.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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
Swift API Design Review
What “good” looks like
- Prioritize clarity at the call site, even if the declaration becomes a bit longer.
- Follow established standard library conventions so your API “feels Swift”.
- Prefer precise words over generic ones (
data,info,manager,handler,util).
Naming Rules (Types, Properties, Methods)
- Clear at point of use, not at declaration.
- Omit needless words, but do not remove words that carry meaning.
- lowerCamelCase: functions, methods, properties, enum cases.
- UpperCamelCase: types, protocols.
- Avoid “noise” suffixes like
String,Array,Dataunless they add meaning.
Boolean naming
- Prefer predicates:
is,has,can,should,did. - Match the natural reading of the call site.
- ✅
if user.isEligible { … } - ✅
if cache.hasValue(forKey: k) { … }
- ✅
Verbs and mutability
- Mutating methods are verbs:
sort(),append(_),removeAll(). - Non-mutating counterparts use “-ed”:
sorted(),appending(_),removingAll()when appropriate.
Common Issues (with better fixes)
| Issue | Better Fix |
var visible | var isVisible |
func get() | Use a precise verb or a noun that reads well at the call site: func userName(), func loadUserName(), func fetchUserName() |
var nameString | var name |
func add(item: x, to: y) | func add(_ item: Item, to collection: Collection) |
func doStuff() | Name the domain action: func refresh(), func rebuildIndex(), func startSession() |
func handle(_ x: …) | Be specific: func handleDeepLink(_:) or func route(_:) |
Parameter & Label Design (call-site first)
- The first argument label should be omitted when it forms a natural phrase:
- ✅
add(_ item:to:) - ✅
contains(_:)
- ✅
- Use labels to clarify roles, units, and semantics:
- ✅
move(from:to:) - ✅
setDeadline(_:, for:) - ✅
resize(to:)(size),resize(by:)(scale factor)
- ✅
- Keep default parameters last when it improves scanning and discoverability.
- Closure parameters are usually last, but:
- If there are multiple closures, label them clearly.
- If a closure is configuration rather than action, it may be clearer earlier.
Preferred label vocabulary (common Swift patterns)
in:container or scopefrom:sourceto:destinationat:position or indexwith:accompanying valueusing:algorithm/tool dependencyfor:beneficiary or target entityby:delta, factor, or means
Return Types & Error Handling
- Use optional only when
nilis a meaningful “no value” state. - Use throws for failures that should be handled via
do/catch. - Use Result when:
- You need to store/transport outcomes,
- You are bridging callback-based APIs,
- You want explicit success/failure as a value.
- Prefer structs over tuples when:
- More than 2–3 fields,
- Fields need names that matter,
- The value is passed around broadly.
Async / Concurrency (modern Swift)
- Prefer
async/awaitover completion handlers for new APIs. - Avoid
Asyncsuffixes unless required for disambiguation.- ✅
func refresh() async throws - ✅
func loadImage() async -> Image
- ✅
- Cancellation:
- Prefer being cancellation-cooperative rather than inventing custom cancel APIs.
- Consider how the API behaves when the task is cancelled (does it throw
CancellationError?).
- Actor isolation:
- Avoid marking pure data models
@MainActor. - Keep UI-bound types
@MainActorwhen they are truly view-facing.
- Avoid marking pure data models
Type & Protocol Naming
- Protocols should name capabilities:
- ✅
Cache,ImageLoading,Persisting
- ✅
- Types should name what they are:
- ✅
ImageCache,URLSessionImageLoader,KeychainStore
- ✅
- Avoid vague names:
- 🚫
Manager,Helper,Util,Common,Base(unless truly established in the domain)
- 🚫
Quick Review Checklist
- Does every API read clearly at the call site?
- Are names consistent with stdlib conventions (mutating vs non-mutating)?
- Are parameter labels meaningful (roles, units, direction:
from/to/at/with)? - Are “get”, “do”, “handle”, “data/info” avoided unless truly accurate?
- Are return types chosen intentionally (optional vs throws vs Result)?
- Do async/throws APIs follow modern Swift patterns without “Async” noise?
Severity
- 🔴 Critical: Violates guidelines or likely to cause misuse/confusion.
- 🟡 Improvement: Usable, but naming/labels could be clearer and more Swift-like.
- 🟢 Enhancement: Polish that improves consistency and ergonomics.
Output format (recommended)
- Summary: 2–5 bullets of highest-impact issues.
- Findings: Grouped by Naming, Parameters, Return Types, Concurrency.
- Each issue labeled with 🔴🟡🟢 and includes a before → after suggestion.
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.

