write-swift SKILL.md skillA
write-swift from suge8/friedbun is an agent skill: a SKILL.md folder an AI agent loads when a task calls for it.
mdr add suge8/friedbun/write-swift@git:20261012.7466c71Pins git:20261012.7466c71 in mdr.lock. Pin the fingerprint instead.
- Audit grade
- A, 17 of 17 checks passed
- Kind
- SKILL.md skill
- Repository
- suge8/friedbun
- Path
skills/development/write-swift/SKILL.md- Versions recorded
- 1
- Latest version
- git:20261012.7466c71, committed Oct 12, 2026
- Size
- 3,330 bytes
- Repository stars
- 12
- License
- MIT
写、审查或迁移 Swift 时读:Swift 6.2 起的并发规则、默认主线程隔离、数据竞争的修法,以及模型常写成旧样子的新写法.
Collected from public GitHub. Every version is saved exactly as it was and never changes. Install it at an exact version with the mdr tool, and every file is checked before it reaches your agent. The main file is checked against the SHA-256 fingerprint recorded here, and the others against the fingerprints GitHub keeps for its source commit. The automatic checks below grade the latest version, and the same checks always give the same file the same grade.
What the file says
# Write Swift
以项目工具链为准:下文到 Swift 6.3 都可用;标 ⚠ 的属于未发布的 6.4,确认工具链后才用。
## 默认
从最简单、最静态、单线程的写法起步,说得出理由才往下走一档:
- `struct`/`enum` 优先于 `class`;互斥状态用一个 `enum`,不用一组可选属性。
- 具体类型优先;出现跨类型的重复代码才抽协议,没有逐类型定制的协议改成约束扩展。
- `some P` 优先;要存放异构类型才用 `any P`。
- 主线程同步代码优先;Instruments 显示卡顿才 `async` → `@concurrent` → `actor`。
## 并发(Swift 6.2 起)
- `async` 不再自动离开当前 actor,在调用处的隔离上运行。把自己的计算挪到后台用 `@concurrent`;库 API 用 `nonisolated`,让调用方决定在哪跑。
- App 与界面模块开 Approachable Concurrency 和 Default Actor Isolation = MainActor(包里 `.defaultIsolation(MainActor.self)`);通用库不开。开了之后类型与函数上不再写 `@MainActor`,只在默认隔离管不到处写:函数类型与回调参数、`nonisolated` 类型里的成员、非主线程回调里起的 `Task`。
- 修数据竞争按顺序:不共享(每个并发任务用自己的实例)→ 改成 Sendable 值类型 → 隔离到 actor → 最后才用 `Synchronization` 的 `Mutex`/`Atomic`(放在 `let` 里)或 `@unchecked Sendable`。不用 `NSLock`、`DispatchSemaphore`;跨 `await` 不持锁。
- 每个 `await` 都是挂起点,回来后重新检查前提;actor 的状态修改放在同步段里,actor 不保证先进先出。
- 结构化并发优先:固定个数用 `async let`,动态个数用有上限的 `withTaskGroup`,无返回值用 `withDiscardingTaskGroup`;`Task {}` 只给挂在界面事件上的工作,几乎不用 `Task.detached`。取消是协作的,开始昂贵工作前检查。
- 回调桥接:`withCheckedContinuation` 每条路径恰好 resume 一次;委托式 API 包成 `AsyncStream`,在 `onTermination` 里清理。
…Read the whole file at its exact version.
How to install
mdr add suge8/friedbun/write-swift@sha256:00f311bddadf2656The line at the top of this page pins the label git:20261012.7466c71, which is what most people want. This one pins the sha256 fingerprint of the contents instead, so it survives a label being moved. Either way the exact version is written to mdr.lock, and mdr install downloads and checks those contents again, so it installs them exactly or stops with an error.
[](https://markdownregistry.com/a/art_6mssw5qwclt6dlf4)
1 badge image fetches in 30 days. What the badge shows.
Versions
The registry has recorded 1 version of this file, committed on Oct 12, 2026.
Audit of the latest version
- pass: Frontmatter block present
- pass: Frontmatter declares a name
- pass: Frontmatter declares a description
- pass: Size between 200 bytes and 200 KB (3330 bytes)
- pass: No zero-width or bidi control characters
- pass: No instruction hidden inside an HTML comment
- pass: No link to an exfiltration or paste host
- pass: No credential-shaped string
- pass: No instruction to send local credentials anywhere
- pass: No text hidden with inline styles
- pass: No prompt-injection phrasing
- pass: No curl or wget piped into a shell
- pass: No recursive delete of root, home or parent
- pass: No instruction to read or print local credentials
- pass: No base64 blob over 200 characters
- pass: No link to a raw IP address
- pass: No script tag
Source
suge8/friedbun · 12 stars · license MIT · pushed 2026-10-21 · branch main
API
GET https://markdownregistry.com/api/v1/artifacts/art_6mssw5qwclt6dlf4 GET https://markdownregistry.com/api/v1/resolve?ref=suge8/friedbun/write-swift GET https://markdownregistry.com/api/v1/blob/00f311bddadf2656f8bca23376c532d4f3e8eafb57f4e395b364f29485e757f2
Your AI assistant does the legwork. You hear about the deals worth your word. Hand yours the standing instructions at modelranch.com and it joins the network that reads files like this one.
Guides: the SKILL.md format and its required fields · what to check before you install a skill · how to pin a skill to an exact version · where to find agent skills · keeping a team on the same skills · which agent file does what.