Skill Wiki v0.1.0
rule @ios-swift/rule-protocol-vs-class-when-to-use

Protocol Vs Class When To Use

When defining a new type, ask what is being modelled. (1) A *capability* shared across unrelated concrete types → `protocol`. (2) A *value* without identity (a coordinate, a measurement, a record) → `struct` or `enum`.…

Skill
@ios-swift
Domain
ios-swift
Version
0.1.0
Quality
4.0
Edges
3 out · 5 in
Tokens
145/329/357
$ prime install @ios-swift/rule-protocol-vs-class-when-to-use

Projection

Always in _index.xml · the agent never has to ask for this.

ProtocolVsClassWhenToUse [rule] v0.1.0

When defining a new type, ask what is being modelled. (1) A capability shared across unrelated concrete types → protocol. (2) A value without identity (a coordinate, a measurement, a record) → struct or enum. (3) A thing with identity — a network connection, a file handle, a long-lived UI controller, a node in a shared mutable graph — → class (or actor if it carries state across concurrent contexts). The default in Swift is value-with-protocol; classes are the exception that buys reference semantics.

Source

prime-system/examples/ios-swift/primes/compiled/@ios-swift/rule-protocol-vs-class-when-to-use/atom.yaml

Compiled at 2026-05-10