agentsclimarketplace

Swift language expert skill

Skill SwiftyJourney/swift-language-expert-skill

Use this skill for non-obvious Swift LANGUAGE and standard-library techniques -- features that make code clearer, safer, or faster but that developers routinely miss. Covers pattern matching (if/guard-case, switch over tuples); functions, closures, and key paths (variadics, autoclosures, rethrows); value semantics and custom types (copy-on-write, ~Copyable, callAsFunction, recursive enums, property wrappers); protocols and generics (associated types, opaque some vs existential any, phantom types); collections (lazy, RangeSet, InlineArray, sorting); strings and Unicode (grapheme-correct iteration, custom interpolation); concurrency and errors (async/await, task groups, AsyncStream, typed throws); and debugging and code organization (assertions, dump, enum namespaces, directives). Trigger for "how do I do X in Swift" and idiomatic refactors. Do NOT use for SwiftUI (swiftui-expert), app architecture or actor isolation in a layered app (ios-architecture-expert), or Swift Testing syntax (swift-testing-expert).From its SKILL.md

Install
npx -y skills add SwiftyJourney/swift-language-expert-skill

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

7.0 KB, ~1.4k tokens by cl100k_base, as published. Nobody here has run it

Swift Language Expert

Non-obvious Swift language and standard-library techniques. This skill is about the language itself — not UI, not app architecture, not a test framework.

Agent Behavior Contract

When this skill is active, follow these rules strictly:

  1. Language & stdlib only. SwiftUI → defer to swiftui-expert; app architecture / composition / where actor isolation goes in a layered app → ios-architecture-expert; Swift Testing (@Test/#expect) syntax → swift-testing-expert.
  2. Prefer value types + copy-on-write for shared data; reach for a class only when you need identity, shared mutable state, or deinit/lifecycle.
  3. Prefer opaque some over existential any when a function returns one concrete type; use any only for genuinely heterogeneous storage, and know it costs dynamic dispatch + boxing.
  4. Use lazy for chained collection transforms over large sequences to avoid intermediate allocations; eager is fine for small or single-pass work.
  5. Respect Unicode. Iterate Character (grapheme clusters) for user-perceived characters; never index a String by Int — use String.Index.
  6. Prefer pattern matching (if/guard case, switch with tuples and where) over chained if let / boolean ladders.
  7. Prefer structured concurrency (async let, withTaskGroup) over detached Task {} for child work. Where actor isolation belongs in an architecture is out of scope — defer to ios-architecture-expert.
  8. Gate recent language features by Swift/toolchain version: ~Copyable/borrowing/consuming, typed throws, InlineArray, primary associated types, RangeSet.

Swift Technique Diagnostic Table

Symptom / goalReach forDeep dive
Pyramid of nested if let / boolean laddersguard/if case, optional patterns, switch over tuplesreferences/pattern-matching-and-control-flow.md
An argument is evaluated even when unused (e.g. assert, log)@autoclosure (+ @escaping where needed)references/functions-closures-keypaths.md
Passing "which property" around as datakey-path expressions (\.name), key-path-as-functionreferences/functions-closures-keypaths.md
A class used only to share/mutate a valuevalue type + copy-on-write (isKnownUniquelyReferenced)references/custom-types.md
A type that must never be copied (handle, lock, token)~Copyable + consuming/borrowingreferences/custom-types.md
String-typed IDs of different kinds get mixed upphantom types (a generic tag parameter)references/protocols-and-generics.md
any Protocol everywhere / dynamic-dispatch costsome (opaque) vs any (existential); primary associated typesreferences/protocols-and-generics.md
filter + map over a huge collection allocates twice.lazy; RangeSet/DiscontiguousSlice for non-contiguous selectionreferences/collections.md
Splitting/counting a string gives wrong results on emoji/accentsgrapheme-cluster iteration, String.Index, normalizationreferences/strings.md
Hand-rolled pluralization / building strings with +custom StringInterpolation, raw stringsreferences/strings.md
Fan out concurrent work and collect resultsasync let, withTaskGroup / withThrowingTaskGroupreferences/concurrency-and-errors.md
Bridge a delegate/callback API to asyncAsyncStream, withCheckedContinuationreferences/concurrency-and-errors.md
catch can't enumerate the errors a function throwstyped throwsreferences/concurrency-and-errors.md
Global let constants polluting the namespacecaseless enum namespace, type subscriptsreferences/debugging-and-organization.md

Guardrails

  • Do not use a class where a struct (+ copy-on-write if needed) suffices — reach for reference types only for identity/shared-mutable-state/lifecycle
  • Do not return any P when one concrete type is returned — use some P
  • Do not index String by integer offsets — use String.Index; iterate Character for user-perceived characters
  • Do not chain if let ladders where a guard case/switch reads clearer
  • Do not spawn unstructured Task {} for child work that should be async let / a task group
  • Do not solve SwiftUI, app architecture, or Swift Testing problems here — defer to the sibling skills
  • Do not use bleeding-edge syntax without gating it by Swift/toolchain version

Reference Router

Open the smallest reference that matches the question:

  • Control flow & functions
  • Types
    • custom-types.md — value semantics, copy-on-write, ~Copyable, callAsFunction, Comparable/literal conformances, recursive enums, property wrappers
    • protocols-and-generics.md — associated types, Self, some vs any, primary associated types, phantom types, constraints
  • Data
    • collections.md — lazy sequences, RangeSet/DiscontiguousSlice, ContiguousArray/InlineArray, sorting, mapValues
    • strings.mdString.Index, grapheme/Unicode handling, normalization, raw strings, custom interpolation
  • Concurrency & errors
  • Tooling

Keep looking

Skills are one crate of 326,286. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.