Token导航 LogoToken导航

Agent Skill · 开发规范

swift-api-design-guidelines(Swift API 设计 guidelines)

用于辅助 API 设计、接口文档、请求响应结构和服务集成说明。它适合让 Agent 梳理 endpoint、生成 OpenAPI 草稿、检查字段命名、整理错误码或辅助前后端联调。使用时需要确认真实业务语义、鉴权方式、分页和错误处理规则;涉及生成接口文档时,应避免凭空补字段,最好从现有代码、schema 或接口样例中提取事实。

swift-api-design-guidelines 是开发规范类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在开发规范类的 1,265 个 Skill 里排第 306。

总安装 3,504周安装 146GitHub Stars 470下载 1,168核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:swift-api-design-guidelines(Swift API 设计 guidelines)
来源仓库:https://github.com/dpearson2699/swift-ios-skills
仓库路径:skills/swift-api-design-guidelines
安装命令:
npx skills add https://github.com/dpearson2699/swift-ios-skills --skill swift-api-design-guidelines
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/dpearson2699/swift-ios-skills --skill swift-api-design-guidelines

这个 Skill 是做什么的

开发规范类 Skill 用来统一代码风格、目录结构和评审口径,产出多为检查清单或改写建议。

swift-api-design-guidelines 用于辅助 API 设计、接口文档和服务集成说明。可梳理 endpoint、生成 OpenAPI 草稿、检查字段命名和整理错误码。需确认真实业务语义、鉴权方式、分页和错误处理规则。涉及生成接口文档时应避免凭空补字段,最好从现有代码或样例中提取事实。

适合前后端联调和接口规范制定场景。

来源仓库内路径:skills/swift-api-design-guidelines

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/dpearson2699/swift-ios-skills --skill swift-ap…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

swift-api-design-guidelines 怎么安装?

在终端执行 npx skills add https://github.com/dpearson2699/swift-ios-skills --skill swift-api-design-g…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

swift-api-design-guidelines 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

swift-api-design-guidelines 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

swift-api-design-guidelines 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

swift-api-design-guidelines 用的人多吗?

公开数据是累计安装 3,504 次,近一周安装 146 次,下载 1,168 次,GitHub 470 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

swift-api-design-guidelines 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发规范类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

开发规范类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
vercel-react-best-practices

Vercel React 最佳实践 · Codex、Claude

8,490,72025,918操作浏览器MIT通过
web-design-guidelines

网页设计指南 · Codex、Claude

6,686,01625,885需要联网MIT有提醒
remotion-best-practices

Remotion 最佳实践 · Codex、Claude

6,505,6323,027操作浏览器MIT有提醒
supabase-postgres-best-practices

Supabase Postgres 最佳实践 · Codex、Claude

3,175,5232,030需要联网MIT通过
next-best-practices

Next.js 最佳实践 · Codex、Claude

1,848,240841操作浏览器MIT通过
swift-api-design-guidelines

Swift API 设计 guidelines · 本页

3,504470需要联网未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Swift API Design Guidelines

Apply the Swift API Design Guidelines when naming types, methods, properties, parameters, and argument labels. Targets Swift 6.3. For language features and syntax, see swift-language. For concurrency patterns, see swift-concurrency.

Contents

Argument Label Rules

Argument labels determine how a call site reads. Apply these rules in order.

When to omit the first argument label

Grammatical phrase rule. When the first argument forms a grammatical phrase with the base name, omit the label. Move any leading words from what would be the label into the base name instead.

// GOOD — reads as "add subview y"
view.addSubview(y)

// BAD — redundant label breaks the phrase
view.add(subview: y)

Value-preserving type conversions. When an initializer performs a value-preserving (widening) conversion, omit the first argument label.

// GOOD — widening conversion, no label
let value = Int64(someUInt32)
let str = String(someCharacter)

// Narrowing or lossy conversions keep a label
let approx = Int64(truncating: someDecimal)
let str = String(describing: someObject)

Indistinguishable arguments. When all arguments cannot be usefully distinguished, omit all labels.

// GOOD — arguments are peers
let smaller = min(x, y)
zip(sequence1, sequence2)

When to use a prepositional label

Prepositional phrase rule. When the first argument completes a prepositional phrase with the base name, label it with the preposition.

// GOOD — "remove boxes having length 12"
x.removeBoxes(havingLength: 12)

// GOOD — "fade from red"
view.fade(from: red)

// GOOD — "relative path from root"
path.relativePath(from: root)

Exception — abstraction boundary. When the first two arguments represent parts of a single abstraction, fold the preposition into the base name so each component gets its own label.

// GOOD — x and y are parts of a single abstraction (a point)
a.moveTo(x: b, y: c)

// BAD — preposition attaches to first arg, leaving y unlabeled
a.move(toX: b, y: c)

Default: label everything else

When no special rule above applies, label the argument.

// GOOD
array.split(maxSplits: 2)
button.setTitle("OK", for: .normal)
controller.dismiss(animated: true)
array.sorted(by: >)

Argument label decision table

SituationRuleExample
First arg completes grammatical phraseOmit label, merge words into base nameaddSubview(y)
Value-preserving init conversionOmit first labelInt64(someUInt32)
Arguments are indistinguishable peersOmit all labelsmin(x, y)
First arg completes prepositional phraseLabel with prepositionfade(from: red)
First two args form a single abstractionFold preposition into base namemoveTo(x: b, y: c)
Everything elseLabel itsplit(maxSplits: 2)

For extended examples and edge cases, see references/argument-labels-and-parameters.md.

Side-Effect Naming

Name functions and methods by their side effects.

Functions with side effects — imperative verbs

When a function mutates state, name it as an imperative verb phrase.

// Mutates — imperative verb
array.sort()
array.append(newElement)
list.remove(at: index)
timer.invalidate()

Functions without side effects — nouns or adjective phrases

When a function returns a result without mutating anything, name it as a noun phrase, adjective phrase, or read as a description of what it returns.

// Pure — noun/description
let d = point.distance(to: origin)
let area = rect.intersection(other)
let line = text.trimmingCharacters(in: .whitespaces)

Boolean properties and methods

Boolean properties and methods read as assertions about the receiver.

// GOOD — reads as "line is empty"
line.isEmpty
set.contains(element)
url.isFileURL

// BAD — not an assertion
line.empty       // verb? adjective?
set.includes     // incomplete phrase

For more examples, see references/side-effects-and-mutating-pairs.md.

Mutating and Nonmutating Pairs

When an operation has both mutating and nonmutating variants, name them as a pair.

Verb-described operations — -ed/-ing suffix

When the operation is naturally described by a verb:

  • Mutating: imperative verb (sort, append, reverse)
  • Nonmutating: past participle -ed or present participle -ing

Default to -ed (past participle). When -ed is ungrammatical — typically when the verb does not form a natural past participle, or when adding -ed produces an awkward phrase — use -ing (present participle) instead.

MutatingNonmutatingWhy
sort()sorted()-ed — "a sorted array"
reverse()reversed()-ed — "a reversed collection"
append(y)appending(y)-ing — "appended" is ungrammatical here
stripNewlines()strippingNewlines()-ing — "stripped newlines" is awkward

Noun-described operations — form- prefix

When the operation is naturally described by a noun:

  • Nonmutating: the noun itself (union, intersection)
  • Mutating: form prefix (formUnion, formIntersection)
// Nonmutating — returns new value
let combined = a.union(b)

// Mutating — modifies in place
a.formUnion(b)

Factory methods — make- prefix

Factory methods that create a new value start with make.

let iterator = collection.makeIterator()
let buffer = parser.makeBuffer()

Pair decision table

Operation described byMutating nameNonmutating nameExample pair
Verb (default)verbverb + -edsort() / sorted()
Verb (-ed is ungrammatical)verbverb + -ingstripNewlines() / strippingNewlines()
Nounform + NounnounformUnion(b) / union(b)

For the full -ed/-ing decision tree and stdlib examples, see references/side-effects-and-mutating-pairs.md.

Documentation Comments

Every public declaration must have a documentation comment.

Summary rules by declaration kind

DeclarationSummary describes
Function / methodWhat it does and what it returns
SubscriptWhat it accesses
InitializerWhat it creates
Type / property / variableWhat it is

Write summaries as a single sentence fragment, beginning with a verb (for actions) or a noun phrase (for entities), ending in a period.

/// Returns the element at the specified index.
func element(at index: Int) -> Element { ... }

/// The number of elements in the collection.
var count: Int { ... }

/// Creates a new array with the given elements.
init(_ elements: some Sequence<Element>) { ... }

/// Accesses the element at the specified position.
subscript(index: Int) -> Element { ... }

Symbol markup

Use standard symbol markup after the summary when relevant:

  • - Parameter name: for individual parameters
  • - Parameters: block for multiple parameters
  • - Returns: for the return value
  • - Throws: for errors thrown
  • - Complexity: for algorithmic complexity
/// Removes and returns the element at the specified position.
///
/// - Parameter index: The position of the element to remove.
/// - Returns: The removed element.
/// - Complexity: O(*n*), where *n* is the length of the collection.
mutating func remove(at index: Int) -> Element { ... }

O(1) complexity rule

Document the complexity of any computed property that is not O(1). Callers assume properties are O(1) by default. If a property does more than constant-time work, state the complexity explicitly.

/// The total weight of all items.
///
/// - Complexity: O(*n*), where *n* is the number of items.
var totalWeight: Double {
    items.reduce(0) { $0 + $1.weight }
}

For documentation patterns and examples, see references/conventions-and-special-rules.md.

Clarity and Naming

Clarity at the point of use is the most important goal. Every design decision serves the person reading a call site.

Clarity over brevity. Longer names are acceptable when they remove ambiguity. Do not abbreviate.

// GOOD
employees.remove(at: position)

// BAD — ambiguous: remove the element? remove at position?
employees.remove(position)

Include words needed to avoid ambiguity. If omitting a word makes the call site unclear, keep it.

// GOOD — "at" clarifies the argument's role
friends.remove(at: index)

// BAD — is "index" the element to remove or the position?
friends.remove(index)

Omit needless words. Do not repeat type information already available from the context.

// GOOD
allViews.remove(cancelButton)

// BAD — "Element" repeats the type
allViews.removeElement(cancelButton)

Name variables and parameters by role, not type. Use the entity's role in the current context, not its type name.

// GOOD — describes the role
var greeting: String
func add(_ observer: NSObject, for keyPath: String)

// BAD — names the type
var string: String
func add(_ object: NSObject, for string: String)

Compensate for weak type information. When a parameter type is Any, AnyObject, or a fundamental type like Int or String, add role-clarifying words to the name.

// GOOD — role is clear despite weak types
func addObserver(_ observer: NSObject, forKeyPath path: String)

// BAD — what does "string" mean here?
func add(_ object: NSObject, for string: String)

For extended naming examples and patterns, see references/naming-and-clarity.md.

Fluent Usage and Protocols

Call sites read as grammatical English. Prefer names that form grammatical phrases at the point of use.

// GOOD — reads fluently
x.insert(y, at: z)          // "x, insert y at z"
x.subviews.remove(at: i)    // "x's subviews, remove at i"
x.makeIterator()             // "x, make iterator"

// BAD — ungrammatical
x.insert(y, position: z)
x.subviews.remove(i)

Initializer first argument. The first argument to an initializer should not form a phrase continuing the type name.

// GOOD
let foreground = Color(red: 32, green: 64, blue: 128)

// BAD — "Color with red" reads awkwardly
let foreground = Color(havingRGBValuesRed: 32, green: 64, blue: 128)

Protocol naming conventions:

Protocol describesNaming patternExamples
What something isNounCollection, IteratorProtocol
A capability-able, -ible, or -ing suffixEquatable, Hashable, Sendable

General Conventions

Casing. Types and protocols use UpperCamelCase. Everything else uses lowerCamelCase. Acronyms that are commonly all-caps in American English appear uniformly upper- or lower-cased based on position.

var utf8Bytes: [UTF8.CodeUnit]
var isRepresentableAsASCII = true
var userSMTPServer: SMTPServer

Methods and properties over free functions. Prefer methods and properties. Use free functions only when:

  1. There is no obvious self — min(x, y)
  2. The function is an unconstrained generic — print(value)
  3. The function syntax is established domain notation — sin(x)

Default arguments over method families. Prefer a single method with default parameters over a family of methods that differ only in which parameters they accept. Place defaulted parameters at the end. Parameters with default values should always have argument labels — defaulted parameters are usually omitted at call sites, so their labels must be clear when they do appear.

// GOOD — labeled with defaults
func decode(_ data: Data, encoding: String.Encoding = .utf8) -> String?

// BAD — method family
func decode(_ data: Data) -> String?
func decode(_ data: Data, encoding: String.Encoding) -> String?

Overload safety. Methods may share a base name when they operate in different type domains or when their meaning is clear from context. Avoid return-type-only overloads that cause ambiguity at the call site.

For casing edge cases, overload patterns, and tuple/closure naming, see references/conventions-and-special-rules.md.

Common Mistakes

  1. Omitting needed argument labels. Using remove(position) instead of remove(at: position) when the role of the argument is ambiguous without the label.
  2. Using -ed when -ing is correct. Applying stripped() when the past participle is ungrammatical — use stripping() instead. Test: does "a [verb]-ed [noun]" read naturally?
  3. Using verb names for side-effect-free operations. Naming a nonmutating method sort() that returns a new collection — use sorted() to signal no mutation.
  4. Naming by type instead of role. Using string instead of greeting, or array instead of elements, when the role would be more informative.
  5. Missing documentation comments. Leaving public declarations undocumented, or writing summaries that describe the implementation rather than the purpose.
  6. Not documenting non-O(1) computed properties. Exposing a linear-time computed property without a Complexity: note, causing callers to assume O(1) and use it in loops.
  7. Applying form- prefix to verb-based operations. Writing formSort() instead of just sort() — the form prefix is only for noun-based operations (formUnion).
  8. Factory methods without make- prefix. Naming factory methods as createIterator() or buildBuffer() instead of makeIterator() and makeBuffer().
  9. Repeating type information in names. Writing removeElement(cancelButton) or stringValue: String when the type is already evident from context.
  10. Return-type-only overloads. Defining overloads that differ only in return type, creating ambiguity when the compiler cannot infer the expected type.
  11. Unlabeled tuple members and closure parameters. Exposing tuples or closures in public API without naming their components, forcing callers to use positional access.

Review Checklist

Argument Labels

  • First argument follows the correct label rule (grammatical phrase, prepositional, conversion, or labeled)
  • Prepositional labels do not incorrectly group independent arguments
  • Value-preserving conversion initializers omit the first label
  • All non-special-case arguments have labels

Naming Semantics

  • Mutating methods use imperative verb form
  • Nonmutating methods use -ed/-ing or noun form
  • Mutating/nonmutating pairs follow the correct pattern (verb pair or noun/form-noun pair)
  • Boolean properties read as assertions (isEmpty, isValid, contains)
  • Variables and parameters are named by role, not type

Documentation

  • Every public declaration has a doc comment
  • Summaries are single sentence fragments ending in a period
  • Summaries describe the correct thing per declaration kind (action, access, creation, entity)
  • Non-O(1) computed properties document their complexity
  • Parameters, return values, and thrown errors are documented with symbol markup

Conventions

  • Types and protocols use UpperCamelCase; everything else uses lowerCamelCase
  • Acronyms are uniformly cased based on position
  • Default arguments are preferred over method families
  • Overloads do not differ only in return type
  • Protocol names follow the noun (is-a) or suffix (capability) convention

References

平台分布

Codex

35.14%
按下载量换算410

Claude

30.04%
按下载量换算351

Cursor

20.16%
按下载量换算235

Gemini CLI

9.88%
按下载量换算115

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills