swift-api-design-guidelines
Skill1.3k starsChanged 3 months agoMITView on GitHub
Use whenever you write, name, or review any public (or internal-but-API-shaped) Swift declaration in this repo — a method, function, initializer, property, protocol, or parameter — and especially before opening a PR that adds or renames public API. Covers naming clarity, argument labels, factory/initializer conventions, boolean and mutating/nonmutating naming, and terms of art, per https://www.swift.org/documentation/api-design-guidelines/. Also use when reviewing a PR's diff for naming issues, or when the user asks "does this read well", "what should I call this", or "is this the Swift-y name". This is the naming/clarity layer; AGENTS.md's "Enum-like Values" and "Codable Conformance" sections cover the structural rules (RawRepresentable vs enum, which protocols to conform to) — use both together when a change touches an enum-like value's shape.
3 other projects use a version of this.
Trending
Quiet since October.about the whole repository
Most recently taken up by
- mac95sb/skillstheir own version, first seen Jul 31, 2026
- K95M65/AI_ONBOARDtheir own version, first seen Jul 18, 2026
- dpearson2699/swift-ios-skillstheir own version, first seen Jul 13, 2026
Who's talking about supabase/supabase-swift
- supabase/supabase-js“refactor(ci): use reusable workflows from supabase/actions”GitHub · Jan 21, 2026 · 2 reactions
- supabase/supabase-flutter“Allow to pass query params when invoking function”GitHub · May 10, 2024 · 2 reactions
- skiptools/skip“Cannot depend on external packages when using Skip native”GitHub · Apr 29, 2025 · 1 reactions
- supabase/supabase-flutter“[Feature request]: Add pull token approach to Realtime”GitHub · Dec 5, 2024 · 1 reactions
- supabase-community/supabase-kt“[Bug]: After deleting a user via edge function you can not logout”GitHub · Jun 25, 2024 · 1 reactions
The biggest 5 of 32 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 32
Talked about on GitHub (32 times).
On GitHub · 32
- Jan 21, 2026refactor(ci): use reusable workflows from supabase/actions — supabase/supabase-js2 reactions
- May 10, 2024Allow to pass query params when invoking function — supabase/supabase-flutter2 reactions · 3 comments
- Apr 29, 2025Cannot depend on external packages when using Skip native — skiptools/skip1 reaction · 11 comments
- Dec 5, 2024[Feature request]: Add pull token approach to Realtime — supabase/supabase-flutter1 reaction · 1 comment
- Jun 25, 2024[Bug]: After deleting a user via edge function you can not logout — supabase-community/supabase-kt1 reaction · 6 comments
27 more on GitHub
- Oct 5, 2026chore(deps): bump the swift-minor-patch group across 1 directory with 5 updates — matthewcross27/Pictalis0 reactions
- Oct 1, 2026chore(deps): bump the ios-deps group in /iOS with 4 updates — thegoodcompany-sst/TAVAttendance0 reactions
- Sep 29, 2026deps: bump github.com/supabase/supabase-swift from 2.55.1 to 2.55.2 in /Packages/AlbumRaterKit in the swift group — jaimerabazo/album-rater0 reactions · 1 comment
- Sep 26, 2026Bump github.com/supabase/supabase-swift from 2.54.1 to 2.55.2 in /macOS — prioneto/signalcase0 reactions · 1 comment
- Sep 21, 2026deps: bump the swift-packages group across 1 directory with 3 updates — bobokenbippers/meetup-ios0 reactions
- Sep 19, 2026chore(deps): bump the swift-minor-patch group across 1 directory with 6 updates — matthewcross27/Pictalis0 reactions · 1 comment
- Sep 16, 2026【iOS】Pealsh 担当タスク — Magii-Corp/Magii_AirLine0 reactions
- Sep 15, 2026chore(deps): bump github.com/supabase/supabase-swift from 2.55.1 to 2.55.2 in /packages/RecAnimeKit in the swift-minor-and-patch group — DANIELSSF/RecAnime0 reactions · 1 comment
- Sep 14, 2026deps: bump github.com/supabase/supabase-swift from 2.55.1 to 2.55.2 in the swift-packages group — bobokenbippers/meetup-ios0 reactions · 1 comment
- Sep 12, 2026chore(deps): bump the swift-minor-patch group across 1 directory with 7 updates — matthewcross27/Pictalis0 reactions · 1 comment
- Sep 5, 2026chore(deps): bump the swift-minor-patch group across 1 directory with 6 updates — matthewcross27/Pictalis0 reactions · 1 comment
- Sep 1, 2026chore(deps): bump the ios-deps group in /iOS with 3 updates — thegoodcompany-sst/TAVAttendance0 reactions
- Aug 29, 2026chore(deps): bump the swift-minor-patch group across 1 directory with 3 updates — matthewcross27/Pictalis0 reactions · 1 comment
- Aug 25, 2026build(deps): bump the swift-health-updates group in /native-plugins/sendlog-health with 2 updates — jirathip-dev/sendmeter0 reactions
- Aug 19, 2026Bump github.com/supabase/supabase-swift from 2.41.1 to 2.55.1 — surenss861/movemark-ios0 reactions
- Aug 17, 2026deps: bump github.com/supabase/supabase-swift from 2.54.1 to 2.55.1 in the swift-packages group — bobokenbippers/meetup-ios0 reactions
- Aug 15, 2026chore(deps): bump the swift-minor-patch group across 1 directory with 2 updates — matthewcross27/Pictalis0 reactions · 1 comment
- Aug 10, 2026deps: bump github.com/supabase/supabase-swift from 2.53.0 to 2.54.1 in the swift-packages group — bobokenbippers/meetup-ios0 reactions
- Jul 29, 2026chore(deps): bump github.com/supabase/supabase-swift from 2.53.0 to 2.54.0 in /iOS — thegoodcompany-sst/TAVAttendance0 reactions · 2 comments
- Jul 27, 2026deps: bump the swift-packages group with 2 updates — bobokenbippers/meetup-ios0 reactions
- Jul 22, 2026chore(deps): bump github.com/supabase/supabase-swift from 2.46.0 to 2.53.0 in /iOS — thegoodcompany-sst/TAVAttendance0 reactions
- Jun 22, 2026chore(deps): bump github.com/supabase/supabase-swift from 2.41.1 to 2.48.0 — Xomware/Float0 reactions · 1 comment
- May 11, 2026chore(deps): bump github.com/supabase/supabase-swift from 2.34.0 to 2.46.0 — barclayd/keepfresh-ios0 reactions · 1 comment
- Mar 30, 2026deps(swift): bump github.com/supabase-community/supabase-swift from 2.37.0 to 2.43.0 — geoffsipperly/BendFlyShop0 reactions · 1 comment
- Mar 27, 2026Build CloudTour AVP - Native visionOS Apple Vision Pro App — EdwardZehuaZhang/cloudtour-monorepo0 reactions
- Oct 13, 2025build(deps): bump github.com/supabase/supabase-swift from 2.31.2 to 2.34.0 — zunda-pixel/niabis-api0 reactions
- Dec 5, 2024[Feature request]: Add pull token approach to Realtime — supabase/supabase-py0 reactions · 3 comments
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- dpearson2699/swift-ios-skills★ 1.2ksame name
- mac95sb/skills★ 1same name
- K95M65/AI_ONBOARD★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository5 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- swift-doccSkill
- writing-migration-guidesSkill
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 4 are distinctive, and 4 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 29
Every public declaration gets a documentation comment (see the swift-docc skill for the format and building the catalog).
- Very specific: line 47
Prefer names that make the call site read as a grammatical English phrase: x.insert(y, at: z) ("x, insert y at z"), not x.insert(y, …
- Distinctive: line 68
Prefer the common word over the term of art when both convey the meaning — don't say "epidermis" for "skin."
- Distinctive: line 70
If you do use a term of art, use it exactly as the field already uses it.
- Distinctive: line 72
Avoid abbreviations, especially non-standard ones — they're terms of art too, understandable only if the reader can guess the expansion.
- Distinctive: line 79
Document the complexity of any computed property that isn't O(1) — callers assume property access is free.
- Very specific: line 81
Prefer methods and properties to free functions.
- Very specific: line 109
If the first argument forms part of a prepositional phrase, label it starting at the preposition, with the label itself beginning right …
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Swift API Design Guidelines
Reference: swift.org/documentation/api-design-guidelines.
The test for every rule below is the same: read the call site, not the declaration. A name is declared once and used many times, so an awkward declaration that reads fine at the use site beats a tidy declaration that reads badly there. When in doubt, write the call site out and read it as an English phrase.
Fundamentals
- Clarity at the point of use outranks brevity. Swift's terseness should come from the type system and inference, not from cutting words a reader needs.
- Every public declaration gets a documentation comment (see the
swift-doccskill for the format and building the catalog). If the summary is hard to write in one sentence fragment, the API is probably shaped wrong — fix the design before you fix the doc comment.
Promote Clear Usage
- Include every word needed to avoid ambiguity at the call site.
remove(at: position)vs.remove(position)— the second reads like "remove the element equal to position," which is wrong. - Omit words that don't add information, especially ones that just repeat the type:
remove(_ member: Element)overremoveElement(_ member: Element)—allViews.remove(cancelButton)already tells you what's being removed. - Name parameters, variables, and associated types after their role, not their type.
func restock(from widgetFactory: WidgetFactory), notfunc restock(from factory: WidgetFactory)repurposed as if the type name were the role.
Strive for Fluent Usage
- Prefer names that make the call site read as a grammatical English phrase:
x.insert(y, at: z)("x, insert y at z"), notx.insert(y, position: z). - It's fine for fluency to degrade after the first argument or two, once those arguments stop
being central to the call's meaning (e.g. trailing
options:/completionHandler:). - Factory methods start with
make:x.makeIterator(). - The first argument to an initializer or factory method doesn't form a phrase with the base
name — don't chase grammatical continuity there:
let foreground = Color(red: 32, green: 64, blue: 128) // good let foreground = Color(havingRGBValuesRed: 32, ...) // no — forcing a phrase - Boolean methods and properties read as assertions about the receiver:
x.isEmpty,line1.intersects(line2), notx.emptyorx.getIntersects(line2). - Mutating/nonmutating pairs follow the verb/
-ed-or--ingpattern, or theform- prefix when there's no natural participle:x.sort()/x.sorted(),x.append(y)/x.appending(y),x.formUnion(y)/x.union(y). - Protocols that describe what something is read as nouns (
Collection). Protocols that describe a capability use-able/-ible/-ing(Equatable,ProgressReporting).
Use Terminology Well
- Prefer the common word over the term of art when both convey the meaning — don't say "epidermis" for "skin."
- If you do use a term of art, use it exactly as the field already uses it. Don't invent a new meaning for an existing term; an expert reader will trust the familiar meaning and be misled.
- Avoid abbreviations, especially non-standard ones — they're terms of art too, understandable only if the reader can guess the expansion.
- Embrace precedent: reuse names and patterns the standard library and Apple frameworks already
established (
Sequence,map,flatMap) instead of inventing parallel vocabulary.
General Conventions
- Document the complexity of any computed property that isn't O(1) — callers assume property access is free.
- Prefer methods and properties to free functions. Free functions are for the cases with no
obvious
self(min(x, y)), unconstrained generics (print(x)), or established math notation (sin(x)). - Case conventions: types and protocols are
UpperCamelCase, everything elselowerCamelCase. Acronyms that are conventionally all-caps stay all-caps as a unit (utf8Bytes,userSMTPServer); other acronyms are treated as ordinary words (radarDetector).
Parameters
- Choose parameter names for how they read in the generated documentation, not just at the call
site —
filter(_ predicate: ...)documents naturally as "elements that satisfypredicate";filter(_ includedInResult: ...)doesn't. - Give a parameter a default when one value is overwhelmingly common — it simplifies the call site for the typical case without losing the explicit form for the rest.
Argument Labels
func move(from start: Point, to end: Point)
x.move(from: x, to: y)- Omit all labels when arguments can't be usefully distinguished:
min(number1, number2),zip(sequence1, sequence2). - In an initializer that performs a value-preserving type conversion, omit the first label —
the source type is already the whole story:
String(veryLargeNumber). In a narrowing conversion, label the narrowing:UInt32(truncating: someUInt64),UInt32(saturating: someUInt64). - If the first argument forms part of a prepositional phrase, label it starting at the
preposition, with the label itself beginning right after that preposition:
a.moveTo(x: b, y: c),a.fadeFrom(red: b, green: c, blue: d). - Otherwise, if the first argument is part of a grammatical phrase, omit its label and fold any
preceding words into the base name:
x.addSubview(y). If it isn't part of a phrase, it needs a label:view.dismiss(animated: false).
Special Instructions
- Label tuple members and name closure parameters wherever they appear in your API — those names carry explanatory power and can be referenced from doc comments, even though closure-parameter labels aren't visible at the call site.
- Take extra care with unconstrained polymorphism (
Any,AnyObject, unconstrained generics) — it's easy to create ambiguous overloads that only differ under the hood.
Common mistakes
| Mistake | Fix |
removeElement(_:) | remove(_:) — the type name in the method name is redundant with the call site |
remove(x) for "remove at position x" | remove(at: x) — bare noun implies value-equality removal |
Color(havingRGBValuesRed:green:andBlue:) | Color(red:green:blue:) — don't force initializer args into a phrase with the base name |
x.getIntersects(y) / x.empty | x.intersects(y) / x.isEmpty — booleans read as assertions |
x.sort() returning a new array | x.sorted() for the nonmutating form; sort() implies mutation |
A capability protocol named as an adjective-less noun, e.g. Progress for something reporting progress | ProgressReporting — capability protocols take -able/-ible/-ing |
A free function where a method would do (describe(x)) | Make it a method (x.describe()) unless there's no obvious self |
Abbreviated parameter name (fn, cfg) | Full word (function, configuration) — abbreviations are terms of art |
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.

