Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
git clone --depth 1 https://github.com/nongjun/awesome-harness-engineeringWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/nongjun/awesome-harness-engineering/swift)<a href="https://agentmods.dev/rules/nongjun/awesome-harness-engineering/swift"><img src="https://agentmods.dev/badge/rules/nongjun/awesome-harness-engineering/swift/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/nongjun/awesome-harness-engineering/swift"><img src="https://agentmods.dev/badge/rules/nongjun/awesome-harness-engineering/swift.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00000 | $0.01073 |
| Opus 5.5 | $0.00000 | $0.00429 |
| Sonnet 5.5 | $0.00000 | $0.00215 |
| Haiku 4.5 | $0.00000 | $0.00107 |
Grade A, and why
Swift编码风格 scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
What it actually says
Swift 编码风格
本文件以 Swift 特定内容扩展通用编码风格规则。
格式化
- SwiftFormat 用于自动格式化,SwiftLint 用于风格检查
swift-format作为替代方案已内置于 Xcode 16+
不可变性
- 优先使用
let而非var——将所有变量定义为let,仅在编译器要求时改为var - 默认使用具有值语义的
struct;仅在需要标识或引用语义时使用class
命名
遵循 Apple API 设计指南:
- 在使用点保持清晰——省略不必要的词
- 根据角色而非类型命名方法和属性
- 使用
static let定义常量,而非全局常量
错误处理
Swift 6 起使用类型化 throws:在函数签名中写明抛出的具体错误类型,而不是笼统的 Error。解析或读取失败时抛出带上下文的枚举 case;配合 guard 早退与 switch/if case 等模式匹配分支处理,避免笼统捕获后忽略语义。
并发
启用 Swift 6 严格并发检查。优先使用:
- 符合
Sendable的值类型跨隔离边界传递数据 - 用 Actor 封装需要跨任务共享的可变状态
- 结构化并发(
async let、任务组)组织子任务,优于随处派生的非结构化任务
?? 运算符的 autoclosure 陷阱
nil 合并运算符右侧实参按 autoclosure 延迟求值。在非 MainActor 隔离的函数里,若右侧表达式会触及主线程上的全局状态(例如从单例里读当前用户的 Token),会触发并发检查报错。处理方式:异步路径上先用 MainActor 上的闭包把需要的值取到局部再合并;若该同步函数业务上保证始终在主线程调用,则把该函数标为 MainActor 隔离。
跨 Service 的 Token 与同类状态不要在各调用点重复写「默认值来自 AppState」——应在 StorageService(或等价层)提供如获取有效 Token 的 async 封装,统一处理 MainActor 隔离,避免到处内联从 AppState 取 Token 的 nil 合并写法。
macOS 窗口标题栏分隔线消除
macOS 窗口标题栏底部有一条系统绘制的 1px 分隔线,影响扁平化 UI。消除需要两步缺一不可:
第一步:NSWindow 上设置 titlebarAppearsTransparent 为 true、titlebarSeparatorStyle 为 none、并启用 fullSizeContentView。
第二步:每个页面根视图必须是 ScrollView。SwiftUI 的 ScrollView 会与透明标题栏无缝衔接,VStack 根视图不行。固定头部或底部用 safeAreaInset 边沿修饰符实现。
无效方案(踩过的坑):只改分隔线样式、只开透明标题栏、只在主窗口外层包一层滚动视图、用 ZStack 铺底色再叠垂直栈、依赖工具栏基线分隔线开关、用几何读取器再包滚动视图——上述单独或组合均不能可靠消除该线。
| 页面类型 | 做法 |
|---|---|
| 纯内容页 | 以 ScrollView 为根 |
| 固定头部+滚动内容+固定底部 | ScrollView 为根 + 安全区 inset(顶/底) |
| 居中展示页 | ScrollView 为根 + 顶部占位高度模拟垂直居中 |
| 已有滚动视图的子组件 | 将滚动提到最外层作根,其余用安全区 inset |
macOS Keychain 注意事项
ad-hoc 签名的应用重新编译后,二进制签名变化会导致 Keychain ACL(访问控制列表)失效,系统不再信任新二进制对已有 Keychain 条目的访问权限,需要用户重新授权。开发调试阶段频繁编译时会反复遇到此问题。正式分发应使用 Developer ID 签名,签名身份稳定即可避免 ACL 反复失效。
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3mo ago First seen · 66 lines · 0 tokens per session scan A bbc3a32035f6
Swift编码风格 is a cursor rule published in the GitHub repository nongjun/awesome-harness-engineering (2 stars, last pushed 8mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,073 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Swift编码风格 compared with cursor rules from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| Swift编码风格nongjun/awesome-harness-engineering | Cursor rule | 2 | 8mo ago | MIT | A | 0 | Cursor |
| gradlesanjeed5/awesome-cursor-rules-mdc | Cursor rule | 3.6k | 9d ago | CC0-1.0 | A | 1,896 | Cursor |
| kotlin-springboot-rulesholtwood/awesome-cursorrules-zh | Cursor rule | 244 | 1mo ago | MIT | A | 0 | Cursor |
| trove-swiftbravew/trove | Cursor rule | 11 | today | MIT | A | 477 | Cursor |
| swift-5-9-development-standards-continuedbeettlle/pi-spine | Cursor rule | 3 | yesterday | MIT | A | 0 | Cursor |
| android-viewmodelbaijum/ukulele-companion | Cursor rule | 14 | 27d ago | MIT | A | 0 | Cursor |
| kotlin-rulesbeel-collab/presets.dev | Cursor rule | 3 | 8d ago | MIT | A | 0 | Cursor |