vvkit-swift-swift-style
Use when creating or editing a Swift type — member ordering, file layout, and choosing between guard and if.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- vvkit-swift-swift-style
- description
- Use when creating or editing a Swift type — member ordering, file layout, and choosing between guard and if.
03 SKILL.md 正文
Swift style
REQUIRED BACKGROUND: $vvkit-writing-comments — comment limits and doc-comment rules.
Codex runtime
Load referenced skills by reading their SKILL.md. Surveyor, reviewer and runner
skills are role instructions, not registered agent types or enforced tool allowlists.
Use a generic subagent only when delegation is available and permitted; otherwise
perform the role inline. Follow the active session's model, context and permission
rules. User authorization takes precedence over imported workflow approval gates.
Claude hooks and plugin commands are not active in this package. Existing
.claude/context/ paths refer to project documents, not Codex configuration.
Where the project has a convention, follow the project. A diff that reorders existing members to a house style the file never used is noise. What follows is the default for new code.
Member order
- File header comment, then imports
- File-private free-standing helpers — error enums, option sets, small structs (optional)
- The type declaration, with a type-level
///overview - Nested types — private enums and structs for internal state
- Injected dependencies —
private let, assigned ininit— beforeinit init, thendeinit- Private stored state — caches, flags, counters — after
init - Public methods and public computed properties
- Private methods
- Extensions at the bottom, one per protocol conformance
- The relative order is the hard rule.
// MARK: -dividers on any non-trivial type. - Dependencies precede
init, working state follows it: the top shows what the type was handed, belowinitwhat it built for itself.
Example
//
// ExampleService.swift
//
import Foundation
/// Owns example fetching and caching for a single session.
/// A type-level overview may run several lines to orient the reader.
final class ExampleService: ExampleServicing {
// MARK: - Types
private enum State {
case idle
case loading
}
// MARK: - Dependencies
private let api: ExampleAPI
private let clock: Clock
// MARK: - Init
init(api: ExampleAPI, clock: Clock) {
self.api = api
self.clock = clock
}
// MARK: - State
private var state: State = .idle
private var cache: [String: ExampleItem] = [:]
// MARK: - Public Methods
func start() async {
state = .loading
await fetch()
}
var itemCount: Int {
cache.count
}
// MARK: - Private Methods
private func fetch() async {
// ...
}
}
// MARK: - ExampleFeedListener
extension ExampleService: ExampleFeedListener {
func feedDidUpdate(_ items: [ExampleItem]) {
// ...
}
}
Sections and extensions
- Labels:
Types·Dependencies(orProperties) ·Init·State·Public Methods(orPublic API) ·Private Methods·Configuration·Debug. - Suffix by topic as a file grows:
// MARK: - Private Methods - Queue Management. - One
extensionper conformance, at the bottom, labelled// MARK: - <ProtocolName>. The primary defining protocol may sit on the type signature; secondary delegate conformances go in extensions.
guard or if
if/elseat the top of a function when both branches carry real logic — both read at the same indentation. Same inside small closures with two return arms.guard let x else { … }for optional unwraps.if letpyramids are worse.- Sequential
if condition { return value }cascades are fine — a pseudo-switch; do not force anelse-iftree.
Formatting
- Multi-line bodies over one-liners.
if/guard/elsebodies on their own lines; do not collapse{ return x }. - Indentation and line length are project settings.
Carve-outs
- Singletons:
static let sharedandprivate init() {}at the very top of the body. - Static-namespace types with no dependencies or
init: group static members logically with MARKs.
04 同仓库更多 Skills
no-heading
Use when proving that the validator rejects a body with no H1 and a force-loading @-link.
wrong-name-does-not-match-dir
Dispatches a subagent per task and reviews between each one.
writing-tests
Use when adding or changing behavior, fixing a bug, or judging whether an existing or generated test earns its place.
writing-skills
Use when authoring or editing a skill, agent, command or hook for this kit, or when deciding whether a piece of guidance belongs in a skill at all.
writing-project-instructions
Use when creating or editing a CLAUDE.md or AGENTS.md, when it has grown long, or when a rule in it also exists in an installed skill.
writing-logs
Use when adding or reviewing log statements, or when deciding what level a message belongs at.