agentleFS
DesquaredDesquared/agents-rules-skills/skills/ios-swift-api-design-reviewer/SKILL.md

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.

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
  1. Distinctive:

    Follow established standard library conventions so your API “feels Swift”.

    line 14
  2. Very specific:

    Prefer precise words over generic ones (data, info, manager, handler, util).

    line 15
  3. Very specific:

    Avoid “noise” suffixes like String, Array, Data unless they add meaning.

    line 23
  4. Very specific:

    Prefer predicates: is, has, can, should, did.

    line 27
  5. Distinctive:

    Use labels to clarify roles, units, and semantics:

    line 53
  6. Distinctive:

    Keep default parameters last when it improves scanning and discoverability.

    line 57
  7. Distinctive:

    If there are multiple closures, label them clearly.

    line 59
  8. Distinctive:

    If a closure is *configuration* rather than *action*, it may be clearer earlier.

    line 60
  9. Very specific:

    Use optional only when nil is a meaningful “no value” state.

    line 75
  10. Very specific:

    Use throws for failures that should be handled via do/catch.

    line 76
  11. Distinctive:

    Prefer structs over tuples when:

    line 81
  12. Very specific:

    Prefer async/await over completion handlers for new APIs.

    line 88
  13. Very specific:

    Avoid Async suffixes unless required for disambiguation.

    line 89
  14. Distinctive:

    Prefer being cancellation-cooperative rather than inventing custom cancel APIs.

    line 93
  15. Very specific:

    Consider how the API behaves when the task is cancelled (does it throw CancellationError?).

    line 94
  16. Very specific:

    Avoid marking pure data models @MainActor.

    line 96
  17. Very specific:

    Keep UI-bound types @MainActor when they are truly view-facing.

    line 97

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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, Data unless 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)

IssueBetter Fix
var visiblevar isVisible
func get()Use a precise verb or a noun that reads well at the call site: func userName(), func loadUserName(), func fetchUserName()
var nameStringvar 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 scope
  • from: source
  • to: destination
  • at: position or index
  • with: accompanying value
  • using: algorithm/tool dependency
  • for: beneficiary or target entity
  • by: delta, factor, or means

Return Types & Error Handling

  • Use optional only when nil is 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/await over completion handlers for new APIs.
  • Avoid Async suffixes 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 @MainActor when they are truly view-facing.

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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.