[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7B3AYDVP6E8EMDGF6HRBFH5":3,"skill-same:01M7B3AYDVP6E8EMDGF6HRBFH5":45},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":27,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M7B3AYDVP6E8EMDGF6HRBFH5","vvkit-swift-swift-concurrency",null,"Use when writing or reviewing Swift code that shares state across threads, queues, or isolation domains — locks, lazy properties, mutable statics, caches, or a state store.","vadimvitvickiy\u002Fvv-agent-kit","vadimvitvickiy","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F5019512?v=4","01M7B3ABRYF7KHBCDW6GB2XH0C","Vadim Vitvitskii","01M7B3ABSZYG9MXP1CC7BQYM25",0,"MIT","https:\u002F\u002Fgithub.com\u002Fvadimvitvickiy\u002Fvv-agent-kit\u002Fblob\u002Fmain\u002Fcodex\u002Fplugins\u002Fvvkit-swift\u002Fskills\u002Fvvkit-swift-swift-concurrency\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: vvkit-swift-swift-concurrency\ndescription: \"Use when writing or reviewing Swift code that shares state across threads, queues, or isolation domains \\u2014 locks, lazy properties, mutable statics, caches, or a state store.\"\n---\n\n# Swift concurrency pitfalls\n\n**REQUIRED BACKGROUND:** `$vvkit-writing-tests` for when a test is required. Test shapes for these\nhazards: `$vvkit-swift-swift-testing` → `references\u002Fconcurrency.md`.\n\n## Codex runtime\n\nLoad referenced skills by reading their SKILL.md. Surveyor, reviewer and runner\nskills are role instructions, not registered agent types or enforced tool allowlists.\nUse a generic subagent only when delegation is available and permitted; otherwise\nperform the role inline. Follow the active session's model, context and permission\nrules. User authorization takes precedence over imported workflow approval gates.\nClaude hooks and plugin commands are not active in this package. Existing\n`.claude\u002Fcontext\u002F` paths refer to project documents, not Codex configuration.\n\nMistakes that shipped. Each is invisible from the file in front of you, and each has a measured cost.\n\n## `lazy var` is not atomic\n\n- Swift's `lazy` has **no synchronisation**. Threads racing first access each run the initialiser and\n  can get *different* instances.\n- Measured: 200 owners under contention produced **209 initialisations and 201 distinct objects** —\n  shipped as a second timer and a reference count that never converged.\n- Plain `lazy` only where every first-access path is provably single-threaded; elsewhere an atomic\n  one-shot initialiser.\n- **The window closes after first access**, which makes the obvious test useless — the first-access\n  trap in `$vvkit-swift-swift-testing`.\n\n## A mutable `static var` is shared by every thread\n\n- A bare `next += 1` reached from several initialisers handed out **duplicate ids**. Lock it, or make\n  it immutable.\n- Check-then-act is the same race:\n\n  ```swift\n  if let existing = Self.cached { return existing }\n  Self.cached = make()          \u002F\u002F two threads both get here, and both construct\n  return Self.cached!\n  ```\n\n## Per-field locking does not compose\n\n- Fields describing **one thing** go in one struct behind one lock or store — never a lock each.\n  Per-field atomics served one rotation item to two consumers, and paired a nil user id with the\n  previous user's session id.\n- **A store makes each transition atomic, not a caller's sequence.** Two getters are two reads.\n  Callers needing several fields coherently get **one** accessor that reads state once.\n- **A transition never calls out** — a database read, a delegate, a subscription, or releasing the last\n  reference to something whose teardown re-enters the store self-deadlocks a non-recursive lock.\n  Resolve outside, write the result in. Two threads both resolving is usually the cheaper correct\n  trade — comment it, so nobody pulls the call back inside.\n\n## Read-modify-write is not one operation\n\n`value = value + 1` on a shared subject, relay or property has a gap. Use a lock-protected box or an\natomic for counters.\n\n## What counts as concurrency\n\n- A lock, or a serial\u002Fbarrier queue guarding state\n- `Thread`, `DispatchGroup`, `DispatchSemaphore`\n- `actor`, `nonisolated(unsafe)`, `@unchecked Sendable`, `Task.detached`\n- A reactive chain observing or subscribing on a non-main scheduler\n- State mutated from a timer, KVO, a notification, or a network or delegate callback not pinned to\n  main\n\n**Not** by itself: a chain created, observed and disposed on main. The trigger is cross-domain\nreachability.\n\n## `@unchecked Sendable` is a claim to justify\n\nIt silences the compiler; it makes nothing safe. Every use carries a comment naming the invariant —\nwhich lock, which queue, which single-writer discipline. Cannot name it: the conformance is wrong.\n","# Swift concurrency pitfalls\n\n**REQUIRED BACKGROUND:** `$vvkit-writing-tests` for when a test is required. Test shapes for these\nhazards: `$vvkit-swift-swift-testing` → `references\u002Fconcurrency.md`.\n\n## Codex runtime\n\nLoad referenced skills by reading their SKILL.md. Surveyor, reviewer and runner\nskills are role instructions, not registered agent types or enforced tool allowlists.\nUse a generic subagent only when delegation is available and permitted; otherwise\nperform the role inline. Follow the active session's model, context and permission\nrules. User authorization takes precedence over imported workflow approval gates.\nClaude hooks and plugin commands are not active in this package. Existing\n`.claude\u002Fcontext\u002F` paths refer to project documents, not Codex configuration.\n\nMistakes that shipped. Each is invisible from the file in front of you, and each has a measured cost.\n\n## `lazy var` is not atomic\n\n- Swift's `lazy` has **no synchronisation**. Threads racing first access each run the initialiser and\n  can get *different* instances.\n- Measured: 200 owners under contention produced **209 initialisations and 201 distinct objects** —\n  shipped as a second timer and a reference count that never converged.\n- Plain `lazy` only where every first-access path is provably single-threaded; elsewhere an atomic\n  one-shot initialiser.\n- **The window closes after first access**, which makes the obvious test useless — the first-access\n  trap in `$vvkit-swift-swift-testing`.\n\n## A mutable `static var` is shared by every thread\n\n- A bare `next += 1` reached from several initialisers handed out **duplicate ids**. Lock it, or make\n  it immutable.\n- Check-then-act is the same race:\n\n  ```swift\n  if let existing = Self.cached { return existing }\n  Self.cached = make()          \u002F\u002F two threads both get here, and both construct\n  return Self.cached!\n  ```\n\n## Per-field locking does not compose\n\n- Fields describing **one thing** go in one struct behind one lock or store — never a lock each.\n  Per-field atomics served one rotation item to two consumers, and paired a nil user id with the\n  previous user's session id.\n- **A store makes each transition atomic, not a caller's sequence.** Two getters are two reads.\n  Callers needing several fields coherently get **one** accessor that reads state once.\n- **A transition never calls out** — a database read, a delegate, a subscription, or releasing the last\n  reference to something whose teardown re-enters the store self-deadlocks a non-recursive lock.\n  Resolve outside, write the result in. Two threads both resolving is usually the cheaper correct\n  trade — comment it, so nobody pulls the call back inside.\n\n## Read-modify-write is not one operation\n\n`value = value + 1` on a shared subject, relay or property has a gap. Use a lock-protected box or an\natomic for counters.\n\n## What counts as concurrency\n\n- A lock, or a serial\u002Fbarrier queue guarding state\n- `Thread`, `DispatchGroup`, `DispatchSemaphore`\n- `actor`, `nonisolated(unsafe)`, `@unchecked Sendable`, `Task.detached`\n- A reactive chain observing or subscribing on a non-main scheduler\n- State mutated from a timer, KVO, a notification, or a network or delegate callback not pinned to\n  main\n\n**Not** by itself: a chain created, observed and disposed on main. The trigger is cross-domain\nreachability.\n\n## `@unchecked Sendable` is a claim to justify\n\nIt silences the compiler; it makes nothing safe. Every use carries a comment naming the invariant —\nwhich lock, which queue, which single-writer discipline. Cannot name it: the conformance is wrong.\n",{"name":5,"description":7},"main","cc22a222a76add5759a2df5fadf231a758691db5","codex\u002Fplugins\u002Fvvkit-swift\u002Fskills\u002Fvvkit-swift-swift-concurrency","https:\u002F\u002Fgithub.com\u002Fvadimvitvickiy\u002Fvv-agent-kit","https:\u002F\u002Fgithub.com\u002Fvadimvitvickiy","Senior iOS engineer. Architecture, SDKs and apps for iOS, tvOS and watchOS.","2026-11-13 19:10:29",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add vadimvitvickiy\u002Fvv-agent-kit --skill vvkit-swift-swift-concurrency",{"tool":37,"command":38},"bunx","bunx skills add vadimvitvickiy\u002Fvv-agent-kit --skill vvkit-swift-swift-concurrency",{"tool":40,"command":41},"pnpm","pnpm dlx skills add vadimvitvickiy\u002Fvv-agent-kit --skill vvkit-swift-swift-concurrency","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fvadimvitvickiy\u002Fvv-agent-kit\u002Fblob\u002Fmain\u002Fcodex\u002Fplugins\u002Fvvkit-swift\u002Fskills\u002Fvvkit-swift-swift-concurrency\u002FSKILL.md",true,[],[46,53,60,67,74,81],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":19},"01M7B3JN7VG0YJ4JB8RP6HYZSJ","no-heading","Use when proving that the validator rejects a body with no H1 and a force-loading @-link.","https:\u002F\u002Fgithub.com\u002Fvadimvitvickiy\u002Fvv-agent-kit\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskills\u002Fno-heading\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M7B3JJMEW4E710ZG6HYJ7BWV","wrong-name-does-not-match-dir","Dispatches a subagent per task and reviews between each one.","https:\u002F\u002Fgithub.com\u002Fvadimvitvickiy\u002Fvv-agent-kit\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskills\u002Fbroken-skill\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M7B3JGE9MFT1HRP41YRVKN97","writing-tests","Use when adding or changing behavior, fixing a bug, or judging whether an existing or generated test earns its place.","https:\u002F\u002Fgithub.com\u002Fvadimvitvickiy\u002Fvv-agent-kit\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-tests\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M7B3JD5X32VEBDBN7HB8E17Z","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.","https:\u002F\u002Fgithub.com\u002Fvadimvitvickiy\u002Fvv-agent-kit\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-skills\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M7B3J992MZH2QVZRED0DRPD9","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.","https:\u002F\u002Fgithub.com\u002Fvadimvitvickiy\u002Fvv-agent-kit\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-project-instructions\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7B3J55C5WPWN20QXP9ET848","writing-logs","Use when adding or reviewing log statements, or when deciding what level a message belongs at.","https:\u002F\u002Fgithub.com\u002Fvadimvitvickiy\u002Fvv-agent-kit\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-logs\u002FSKILL.md",[],[]]