@mrciphersmith/keryx 0.4.29 → 0.4.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/cli.js +2446 -1391
  2. package/dist/core.js +90 -27
  3. package/dist/keryx-general-worker-entry.js +82 -25
  4. package/package.json +1 -1
  5. package/src/gdskills/bundled/install-manifest.json +2 -0
  6. package/src/gdskills/bundled/rules/core/api-contracts.mdc +21 -136
  7. package/src/gdskills/bundled/rules/core/async-patterns.mdc +18 -171
  8. package/src/gdskills/bundled/rules/core/clean-architecture.mdc +21 -3
  9. package/src/gdskills/bundled/rules/core/cli-interface-design.mdc +63 -194
  10. package/src/gdskills/bundled/rules/core/code-style-patterns.mdc +36 -49
  11. package/src/gdskills/bundled/rules/core/concurrency-patterns.mdc +32 -0
  12. package/src/gdskills/bundled/rules/core/database-patterns.mdc +26 -148
  13. package/src/gdskills/bundled/rules/core/error-handling.mdc +7 -8
  14. package/src/gdskills/bundled/rules/core/frontend-assistant.mdc +14 -29
  15. package/src/gdskills/bundled/rules/core/layout-rendering.mdc +51 -0
  16. package/src/gdskills/bundled/rules/core/mobx-store-template.mdc +69 -511
  17. package/src/gdskills/bundled/rules/core/nestjs-dto.mdc +18 -36
  18. package/src/gdskills/bundled/rules/core/playwright-testing.mdc +35 -308
  19. package/src/gdskills/bundled/rules/core/security-baseline.mdc +18 -140
  20. package/src/gdskills/bundled/rules/core/solid-principles.mdc +31 -7
  21. package/src/gdskills/bundled/rules/core/storybook-guidelines.mdc +20 -22
  22. package/src/gdskills/bundled/rules/core/tdd-workflow.mdc +37 -74
  23. package/src/gdskills/bundled/rules/core/ui-anti-slop.mdc +48 -37
  24. package/src/gdskills/bundled/skills/quality/deprecation-path/SKILL.md +1 -1
  25. package/src/gdskills/bundled/skills/review/review-architecture/SKILL.md +24 -60
  26. package/src/gdskills/bundled/skills/review/review-backend/SKILL.md +13 -65
  27. package/src/gdskills/bundled/skills/review/review-clean-code/SKILL.md +22 -35
  28. package/src/gdskills/bundled/skills/review/review-frontend/SKILL.md +16 -309
  29. package/src/gdskills/bundled/skills/review/review-frontend-conventions/SKILL.md +7 -21
  30. package/src/gdskills/bundled/skills/review/review-highload/SKILL.md +83 -227
  31. package/src/gdskills/bundled/skills/review/review-layout/SKILL.md +22 -28
  32. package/src/gdskills/bundled/skills/review/review-logic/SKILL.md +8 -8
  33. package/src/gdskills/bundled/skills/review/review-performance/SKILL.md +15 -37
  34. package/src/gdskills/bundled/skills/review/review-security-code/SKILL.md +7 -7
  35. package/src/gdskills/bundled/skills/review/review-style/SKILL.md +31 -66
  36. package/src/gdskills/bundled/skills/review/review-testing-practices/SKILL.md +21 -39
  37. package/src/gdskills/bundled/skills/review/review-ui-ux/SKILL.md +42 -82
  38. package/src/gdskills/bundled/stacks/angular/rules/coding-style.mdc +15 -57
  39. package/src/gdskills/bundled/stacks/angular/rules/patterns.mdc +16 -60
  40. package/src/gdskills/bundled/stacks/angular/rules/security.mdc +11 -49
  41. package/src/gdskills/bundled/stacks/angular/rules/testing.mdc +13 -52
  42. package/src/gdskills/bundled/stacks/c-cpp/rules/coding-style.mdc +33 -57
  43. package/src/gdskills/bundled/stacks/c-cpp/rules/patterns.mdc +35 -62
  44. package/src/gdskills/bundled/stacks/c-cpp/rules/security.mdc +35 -62
  45. package/src/gdskills/bundled/stacks/c-cpp/rules/testing.mdc +34 -54
  46. package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/patterns.mdc +27 -56
  47. package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/security.mdc +51 -119
  48. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/coding-style.mdc +42 -74
  49. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/patterns.mdc +45 -84
  50. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/security.mdc +34 -59
  51. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/testing.mdc +33 -62
  52. package/src/gdskills/bundled/stacks/django/rules/coding-style.mdc +15 -56
  53. package/src/gdskills/bundled/stacks/django/rules/patterns.mdc +16 -68
  54. package/src/gdskills/bundled/stacks/django/rules/security.mdc +13 -71
  55. package/src/gdskills/bundled/stacks/django/rules/testing.mdc +16 -62
  56. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/coding-style.mdc +30 -53
  57. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/patterns.mdc +20 -56
  58. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/security.mdc +52 -122
  59. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/testing.mdc +23 -42
  60. package/src/gdskills/bundled/stacks/fastapi/rules/coding-style.mdc +13 -47
  61. package/src/gdskills/bundled/stacks/fastapi/rules/patterns.mdc +18 -81
  62. package/src/gdskills/bundled/stacks/fastapi/rules/security.mdc +13 -75
  63. package/src/gdskills/bundled/stacks/fastapi/rules/testing.mdc +14 -58
  64. package/src/gdskills/bundled/stacks/flutter-dart/rules/coding-style.mdc +36 -74
  65. package/src/gdskills/bundled/stacks/flutter-dart/rules/patterns.mdc +30 -66
  66. package/src/gdskills/bundled/stacks/flutter-dart/rules/security.mdc +33 -67
  67. package/src/gdskills/bundled/stacks/flutter-dart/rules/testing.mdc +41 -73
  68. package/src/gdskills/bundled/stacks/go/rules/coding-style.mdc +36 -57
  69. package/src/gdskills/bundled/stacks/go/rules/patterns.mdc +27 -42
  70. package/src/gdskills/bundled/stacks/go/rules/security.mdc +26 -43
  71. package/src/gdskills/bundled/stacks/go/rules/testing.mdc +23 -41
  72. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/coding-style.mdc +18 -37
  73. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/patterns.mdc +26 -43
  74. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/security.mdc +25 -37
  75. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/testing.mdc +34 -50
  76. package/src/gdskills/bundled/stacks/kotlin-android/rules/coding-style.mdc +28 -65
  77. package/src/gdskills/bundled/stacks/kotlin-android/rules/patterns.mdc +34 -78
  78. package/src/gdskills/bundled/stacks/kotlin-android/rules/security.mdc +35 -68
  79. package/src/gdskills/bundled/stacks/kotlin-android/rules/testing.mdc +34 -68
  80. package/src/gdskills/bundled/stacks/mobx/rules/coding-style.mdc +18 -64
  81. package/src/gdskills/bundled/stacks/mobx/rules/patterns.mdc +13 -66
  82. package/src/gdskills/bundled/stacks/mobx/rules/security.mdc +8 -35
  83. package/src/gdskills/bundled/stacks/mobx/rules/testing.mdc +10 -39
  84. package/src/gdskills/bundled/stacks/nestjs/rules/coding-style.mdc +32 -45
  85. package/src/gdskills/bundled/stacks/nestjs/rules/patterns.mdc +40 -60
  86. package/src/gdskills/bundled/stacks/nestjs/rules/security.mdc +30 -50
  87. package/src/gdskills/bundled/stacks/nestjs/rules/testing.mdc +27 -47
  88. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/coding-style.mdc +14 -48
  89. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/patterns.mdc +15 -67
  90. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/security.mdc +12 -50
  91. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/testing.mdc +11 -43
  92. package/src/gdskills/bundled/stacks/php-laravel/rules/coding-style.mdc +17 -58
  93. package/src/gdskills/bundled/stacks/php-laravel/rules/patterns.mdc +15 -56
  94. package/src/gdskills/bundled/stacks/php-laravel/rules/security.mdc +13 -50
  95. package/src/gdskills/bundled/stacks/php-laravel/rules/testing.mdc +14 -55
  96. package/src/gdskills/bundled/stacks/python/rules/coding-style.mdc +13 -41
  97. package/src/gdskills/bundled/stacks/python/rules/patterns.mdc +20 -61
  98. package/src/gdskills/bundled/stacks/python/rules/security.mdc +15 -57
  99. package/src/gdskills/bundled/stacks/python/rules/testing.mdc +16 -50
  100. package/src/gdskills/bundled/stacks/react/rules/coding-style.mdc +14 -40
  101. package/src/gdskills/bundled/stacks/react/rules/patterns.mdc +15 -55
  102. package/src/gdskills/bundled/stacks/react/rules/security.mdc +13 -49
  103. package/src/gdskills/bundled/stacks/react/rules/testing.mdc +10 -37
  104. package/src/gdskills/bundled/stacks/ruby-rails/rules/coding-style.mdc +12 -45
  105. package/src/gdskills/bundled/stacks/ruby-rails/rules/patterns.mdc +18 -67
  106. package/src/gdskills/bundled/stacks/ruby-rails/rules/security.mdc +11 -60
  107. package/src/gdskills/bundled/stacks/ruby-rails/rules/testing.mdc +14 -65
  108. package/src/gdskills/bundled/stacks/rust/rules/coding-style.mdc +39 -65
  109. package/src/gdskills/bundled/stacks/rust/rules/patterns.mdc +33 -60
  110. package/src/gdskills/bundled/stacks/rust/rules/security.mdc +35 -57
  111. package/src/gdskills/bundled/stacks/rust/rules/testing.mdc +29 -52
  112. package/src/gdskills/bundled/stacks/sql-db/rules/coding-style.mdc +12 -48
  113. package/src/gdskills/bundled/stacks/sql-db/rules/patterns.mdc +22 -113
  114. package/src/gdskills/bundled/stacks/sql-db/rules/security.mdc +11 -56
  115. package/src/gdskills/bundled/stacks/sql-db/rules/testing.mdc +14 -59
  116. package/src/gdskills/bundled/stacks/swift-ios/rules/coding-style.mdc +29 -65
  117. package/src/gdskills/bundled/stacks/swift-ios/rules/patterns.mdc +41 -88
  118. package/src/gdskills/bundled/stacks/swift-ios/rules/security.mdc +28 -53
  119. package/src/gdskills/bundled/stacks/swift-ios/rules/testing.mdc +32 -65
  120. package/src/gdskills/bundled/stacks/vue/rules/coding-style.mdc +17 -52
  121. package/src/gdskills/bundled/stacks/vue/rules/patterns.mdc +17 -63
  122. package/src/gdskills/bundled/stacks/vue/rules/security.mdc +11 -41
  123. package/src/gdskills/bundled/stacks/vue/rules/testing.mdc +16 -48
@@ -7,86 +7,50 @@ metadata:
7
7
 
8
8
  # Swift/iOS coding style
9
9
 
10
- Narrows `core-common-rules`' stack-agnostic style rules to modern Swift
11
- (6.x) and SwiftUI idiom. Applies only to `*.swift` files — everything not
12
- Swift-specific still comes from the common rules this file `extends`.
10
+ Narrows `core-common-rules`' style rules to the Swift API Design Guidelines (Swift 6.x) and SwiftUI idiom.
13
11
 
14
12
  ## Naming and structure
15
13
 
16
- - Types (`struct`, `class`, `enum`, `protocol`) are `UpperCamelCase`;
17
- properties, methods, and cases are `lowerCamelCase` — never
18
- `snake_case` for either.
19
- - Protocol names read as a capability (`Fetchable`, `Cacheable`) or a
20
- role noun (`DataSource`, `Delegate`); do not suffix a protocol with
21
- `Protocol`.
22
- - An identifier's name shrinks with its scope: a tight closure parameter
23
- can be `$0`/a one-letter name, a public API member gets a full
24
- descriptive name.
25
- - File name matches the primary type it declares (`OrderService.swift`
26
- declares `OrderService`); one primary type per file for anything
27
- public.
14
+ - No `Protocol` suffix on a protocol name; name it as a capability (`Fetchable`)
15
+ or role noun (`DataSource`).
16
+ - File name matches the primary type it declares; one primary type per file for
17
+ anything public.
28
18
 
29
19
  ## Value types vs reference types
30
20
 
31
- - Default to `struct` (and `enum` for closed sets of cases) for model and
32
- state types — value semantics mean a copy cannot be mutated out from
33
- under another owner, which is what SwiftUI's data flow assumes.
34
- - Reach for `class` only when you need reference semantics on purpose:
35
- shared mutable state across owners, identity that must be preserved
36
- (`===`), or Objective-C interop. Justify a `class` model type in review
37
- rather than defaulting to it out of habit from other languages.
38
- - A `class` used as SwiftUI-observed state is marked `@Observable` (see
39
- `patterns.mdc`) and, when its mutable state is touched from view code,
40
- isolated to `@MainActor`.
21
+ - Default to `struct` (and `enum` for closed sets) for model and state types.
22
+ - `class` only for deliberate reference semantics: shared mutable state across
23
+ owners, identity (`===`), or Objective-C interop; justify a `class` model type in review.
24
+ - A `class` used as SwiftUI-observed state is `@Observable` (see `patterns.mdc`)
25
+ and `@MainActor` when view code touches its mutable state.
41
26
 
42
27
  ## Guard for early exit
43
28
 
44
- - Use `guard let`/`guard` with an early `return`/`continue`/`throw` to
45
- unwrap a precondition and keep the "happy path" unindented, rather than
46
- nesting the whole function body inside an `if let`.
47
- - Prefer a single `guard` with multiple comma-separated conditions over a
48
- pyramid of nested `if let`s when several optionals must all be present
49
- before the function can proceed.
29
+ - Use `guard` with an early `return`/`continue`/`throw` to keep the happy path
30
+ unindented, not an `if let` wrapping the function body.
31
+ - One `guard` with comma-separated conditions over a pyramid of nested `if let`.
50
32
 
51
33
  ## Optionals
52
34
 
53
- - Treat `!` (force-unwrap) and `try!` (force-try) as a last resort, not a
54
- convenience — reserve them for a value whose absence is a genuine
55
- programmer error that should crash in development (an `IBOutlet` wired
56
- in a storyboard, a compile-time-guaranteed non-nil literal), never for
57
- network responses, decoded JSON, user input, or anything else that can
58
- legitimately be nil or throw in production.
59
- - Prefer `guard let`/`if let`, nil-coalescing (`??`) with a real default,
60
- or `try`/`try?` with explicit handling. Use `#require(...)` (Swift
61
- Testing) or `XCTUnwrap` in tests instead of `!` when a test needs to
62
- unwrap and fail with a clear message if the value is missing.
63
- - Chain optional access with `?.`/optional chaining rather than
64
- force-unwrapping an intermediate step in a chain.
35
+ - `!` and `try!` only for a value whose absence is a programmer error that
36
+ should crash in development (a storyboard `IBOutlet`, a compile-time-guaranteed
37
+ literal); never for network responses, decoded JSON or user input.
38
+ - Prefer `guard let`/`if let`, `??` with a real default, or `try`/`try?` with
39
+ explicit handling; in tests use `#require(...)` or `XCTUnwrap` instead of `!`.
40
+ - Use `?.` chaining, not a force-unwrapped intermediate step.
65
41
 
66
42
  ## @Observable vs legacy ObservableObject
67
43
 
68
- - For code targeting iOS 17+, model types that drive SwiftUI view
69
- updates use the `@Observable` macro, not the legacy
70
- `ObservableObject`/`@Published` combination — `@Observable` tracks
71
- property-level access automatically, so a view only re-renders for the
72
- properties it actually reads, where `@Published` re-renders on any
73
- change to the whole object.
74
- - Mark an `@Observable` class `@MainActor` unless the project has set a
75
- module-wide default actor isolation to `MainActor` — this keeps its
76
- mutable state confined to the main actor by construction (see
77
- `patterns.mdc` for the concurrency implications).
78
- - Only reach for `ObservableObject`/`@Published`/`@StateObject`/
79
- `@ObservedObject` when the project's minimum deployment target
80
- predates iOS 17, or an existing codebase has not yet migrated; do not
81
- introduce the legacy pattern in new code on a project that already
82
- targets iOS 17+.
44
+ - For iOS 17+ targets, use `@Observable`, not `ObservableObject`/`@Published`.
45
+ - Mark an `@Observable` class `@MainActor` unless the project sets a module-wide
46
+ default actor isolation of `MainActor`.
47
+ - Use `ObservableObject`/`@Published`/`@StateObject`/`@ObservedObject` only when
48
+ the minimum deployment target predates iOS 17 or the codebase has not migrated;
49
+ never introduce it in new code on an iOS 17+ project.
83
50
 
84
51
  ## Formatting and linting
85
52
 
86
- - Format with the project's configured formatter (`swift-format` or
87
- `swiftformat`) before finishing a change; do not hand-format around a
88
- formatter that is already configured in the project.
89
- - Fix a SwiftLint finding at its root cause; do not silence it with a
90
- blanket `// swiftlint:disable` covering more than the one line it
91
- actually applies to, and never disable a rule repository-wide to clear
92
- one finding.
53
+ - Format with the project's configured formatter (`swift-format` or `swiftformat`);
54
+ do not hand-format around it.
55
+ - Fix a SwiftLint finding at its root cause; no `// swiftlint:disable` covering
56
+ more than the one line, and no repository-wide rule disable to clear one finding.
@@ -7,106 +7,59 @@ metadata:
7
7
 
8
8
  # Swift/iOS patterns
9
9
 
10
- Narrows `core-common-rules`' stack-agnostic design guidance to idiomatic
11
- Swift concurrency and SwiftUI state ownership. Applies only to `*.swift`
12
- files.
10
+ Narrows `core-common-rules`' design guidance to Swift concurrency (Swift 6 data-race safety) and SwiftUI state ownership.
13
11
 
14
12
  ## Swift concurrency: async/await and structured concurrency
15
13
 
16
- - Prefer `async`/`await` over completion-handler callbacks for new
17
- asynchronous code — it reads linearly and composes with structured
18
- concurrency instead of nesting closures.
19
- - Start concurrent child work with `async let` (a small, fixed number of
20
- parallel tasks) or `TaskGroup`/`withThrowingTaskGroup` (a dynamic or
21
- unbounded set of child tasks); both guarantee every child task is
22
- awaited or cancelled before the parent scope exits, unlike a bare
23
- unstructured `Task {}` with no owner to join it. (`Task {}` is
24
- "unstructured" — it inherits the creating context's actor and priority
25
- but nothing tracks its lifetime; `Task.detached {}` is a stronger,
26
- rarely-needed form that inherits neither — do not use the two names
27
- interchangeably.)
28
- - SwiftUI's `.task { }` modifier closure is already async — it is the
29
- boundary, not a place to wrap another `Task {}` inside it. Reach for a
30
- bare `Task {}` only at a genuine synchronous-to-async boundary with no
31
- async closure already available (a button action's `Void`-returning
32
- handler, a delegate callback); give it an explicit reason it does not
33
- need to be joined. Prefer `.task { }` directly on a SwiftUI view over a
34
- manually created `Task` when the work should be tied to the view's
35
- lifetime (it is cancelled automatically when the view disappears).
36
- - Respect cancellation in long-running async work: check
37
- `Task.isCancelled`/call `try Task.checkCancellation()` in a loop, so a
38
- cancelled parent actually stops the child's work instead of running to
39
- completion regardless.
14
+ - Prefer `async`/`await` over completion handlers for new asynchronous code.
15
+ - Use `async let` (small fixed number of tasks) or `TaskGroup`/`withThrowingTaskGroup`
16
+ (dynamic set) for concurrent child work, not a bare unstructured `Task {}`.
17
+ `Task.detached {}` is a distinct, rarely needed form; do not use the two names
18
+ interchangeably.
19
+ - SwiftUI's `.task { }` closure is already async: do not wrap another `Task {}`
20
+ in it. A bare `Task {}` only at a synchronous-to-async boundary with no async
21
+ closure available (a `Void` button action, a delegate callback), with an
22
+ explicit reason it need not be joined. Prefer `.task { }` when the work is
23
+ tied to the view's lifetime.
24
+ - Long-running async work checks `Task.isCancelled` or calls
25
+ `try Task.checkCancellation()` in a loop.
40
26
 
41
27
  ## Actors and @MainActor
42
28
 
43
- - Use `actor` to protect mutable state that multiple tasks touch
44
- concurrently — its methods are implicitly isolated, so the compiler
45
- (not a convention) prevents unsynchronized access, the same guarantee
46
- a manual lock only provides by discipline.
47
- - Since the iOS 18 SDK, `View` conformance is itself `@MainActor`-isolated
48
- — a view's own `body` and any `@State`/`@Binding` kept directly on the
49
- view struct are already main-actor-isolated automatically, with no
50
- explicit annotation needed. That isolation does NOT extend to a
51
- SEPARATE type: mark any standalone type whose state SwiftUI reads or
52
- mutates `@MainActor` explicitly — view models, `@Observable` stores, or
53
- any other type outside the `View` struct itself that a `body` touches.
54
- Isolate at the type level (`@MainActor final class ...`) rather than
55
- sprinkling `@MainActor` on individual methods, unless only some of the
56
- type's methods genuinely need main-actor isolation.
57
- - Cross an actor boundary explicitly with `await`; do not reach for
58
- `@unchecked Sendable` or `nonisolated(unsafe)` to make a boundary
59
- error disappear — either the type's state genuinely needs no
60
- isolation (make that case explicitly, with a comment), or it needs a
61
- real actor/lock, not a suppression.
29
+ - Use `actor` to protect mutable state touched by multiple tasks.
30
+ - Since the iOS 18 SDK, `View` is `@MainActor`-isolated, which does not extend to
31
+ a separate type: mark any standalone type whose state SwiftUI reads or mutates
32
+ (view models, `@Observable` stores) `@MainActor` explicitly, at the type level
33
+ (`@MainActor final class ...`), not per method, unless only some methods need it.
34
+ - Cross an actor boundary with `await`; no `@unchecked Sendable` or
35
+ `nonisolated(unsafe)` to make a boundary error disappear. Either the state needs
36
+ no isolation (say so in a comment) or it needs a real actor/lock.
62
37
 
63
38
  ## Sendable conformance
64
39
 
65
- - A value crossing a concurrency boundary (passed into a `Task`, an
66
- actor method, or a `TaskGroup` child) must be `Sendable`: a `struct`
67
- or `enum` with only `Sendable` members is `Sendable` for free; a
68
- `final class` with only immutable (`let`) stored properties can
69
- declare conformance explicitly.
70
- - Do not slap `@unchecked Sendable` on a class to silence a
71
- strict-concurrency diagnostic without actually auditing and
72
- documenting why its mutable state cannot race — that trades a
73
- compile-time guarantee for an unchecked promise, which is exactly the
74
- class of bug Swift 6's data-race safety exists to catch.
75
- - Under the Swift 6 language mode, treat a "Sendable" or "actor
76
- isolation" compiler error as a real potential data race to fix at the
77
- root (add an actor, make the type immutable, or copy the value before
78
- crossing), not friction to suppress.
40
+ - A value crossing a concurrency boundary (into a `Task`, an actor method, a
41
+ `TaskGroup` child) must be `Sendable`; a `final class` with only immutable
42
+ (`let`) stored properties declares conformance explicitly.
43
+ - No `@unchecked Sendable` on a class to silence a diagnostic without auditing
44
+ and documenting why its mutable state cannot race.
45
+ - Under Swift 6 language mode, fix a "Sendable" or "actor isolation" error at
46
+ the root (add an actor, make the type immutable, copy before crossing).
79
47
 
80
48
  ## SwiftUI state ownership
81
49
 
82
- - `@State` owns a value the view itself creates and is the sole owner
83
- of — a simple value type, or (iOS 17+) an `@Observable` reference type
84
- the view instantiates directly (`@State private var model = Model()`,
85
- not `@StateObject` for `@Observable` types).
86
- - `@Binding` is for a child view that needs to both read and mutate a
87
- value it does not own — the parent passes `$value`, and the child
88
- writes through the binding instead of receiving a copy it cannot
89
- propagate changes from.
90
- - `@Environment` is for values that are ambient to a whole subtree
91
- (theme, a shared service, a feature flag) rather than threaded
92
- explicitly through every initializer; do not reach for it as a
93
- shortcut to avoid passing an explicit dependency that only one or two
94
- views actually need.
95
- - A view that receives an `@Observable` model from a parent and needs to
96
- pass a binding to one of its properties down further uses `@Bindable`,
97
- not a manually reconstructed `Binding(get:set:)`.
50
+ - `@State` owns a value the view itself creates: a value type, or (iOS 17+) an
51
+ `@Observable` reference type (`@State private var model = Model()`, not `@StateObject`).
52
+ - `@Binding` for a child that reads and mutates a value it does not own.
53
+ - `@Environment` for values ambient to a subtree (theme, shared service, feature
54
+ flag); not a shortcut around passing a dependency only one or two views need.
55
+ - A view that receives an `@Observable` model and passes a binding to one of its
56
+ properties uses `@Bindable`, not a hand-built `Binding(get:set:)`.
98
57
 
99
58
  ## Anti-patterns to flag
100
59
 
101
- - A retain cycle from a closure (completion handler, Combine `sink`,
102
- stored callback) that captures `self` strongly when the closure
103
- outlives the call that created it — use `[weak self]` and unwrap, or
104
- `[unowned self]` only when `self`'s lifetime is provably guaranteed to
105
- exceed the closure's.
106
- - Lifting a value into `@State`/`@StateObject` at the view that merely
107
- displays it, when a parent further up actually owns and mutates it —
108
- that duplicates state instead of using `@Binding`/`@Observable`
109
- references, and the two copies drift.
110
- - A massive view or view-model type that owns navigation, networking,
111
- and persistence together — split by responsibility the same way a
112
- "god package"/"god object" is flagged in any other stack.
60
+ - A closure that outlives its creating call (completion handler, Combine `sink`,
61
+ stored callback) capturing `self` strongly: use `[weak self]`, or
62
+ `[unowned self]` only when `self`'s lifetime provably exceeds the closure's.
63
+ - Lifting a value into `@State`/`@StateObject` at a view that only displays it
64
+ when a parent owns and mutates it; use `@Binding`/`@Observable` references.
65
+ - A view or view-model type that owns navigation, networking and persistence together.
@@ -7,72 +7,47 @@ metadata:
7
7
 
8
8
  # Swift/iOS security
9
9
 
10
- Narrows `core-common-rules`' stack-agnostic security rules to
11
- iOS/Apple-platform-specific risks and the safe framework API to use
12
- instead. Applies only to `*.swift` files.
10
+ Narrows `core-common-rules`' security rules to iOS/Apple-platform risks (OWASP Mobile Top 10) and the safe framework API for each.
13
11
 
14
12
  ## Secrets and credential storage
15
13
 
16
- - Store credentials, tokens, and refresh tokens in the Keychain
17
- (`Security` framework, or a thin wrapper around it) — never in
18
- `UserDefaults`, which is unencrypted plist storage readable by
19
- anything with filesystem access to the app's container, and never in a
20
- plain file the app writes itself.
21
- - Never hardcode an API key, client secret, or signing credential as a
22
- string literal in source. Load it from a build-time configuration
23
- (an `.xcconfig` value injected into `Info.plist`, a secrets manager
24
- fetched at runtime) that is excluded from source control, and treat a
25
- literal key found in a diff as a finding, not a style nit.
26
- - Set an appropriate Keychain accessibility level
27
- (`kSecAttrAccessibleWhenUnlockedThisDeviceOnly` or stricter) for
28
- anything sensitive — the default accessibility can survive a device
29
- backup/restore onto different hardware, which is usually not the
30
- intended threat model for a session token.
14
+ - Store credentials, tokens and refresh tokens in the Keychain (`Security`
15
+ framework or a thin wrapper), never in `UserDefaults` or a plain file.
16
+ - Never hardcode an API key, client secret or signing credential as a string
17
+ literal. Load it from build-time configuration (an `.xcconfig` value injected
18
+ into `Info.plist`, or a secrets manager fetched at runtime) excluded from
19
+ source control; a literal key in a diff is a finding, not a style nit.
20
+ - Set Keychain accessibility to `kSecAttrAccessibleWhenUnlockedThisDeviceOnly` or
21
+ stricter for anything sensitive.
31
22
 
32
23
  ## Network security (ATS and transport)
33
24
 
34
- - Leave App Transport Security (ATS) at its default (HTTPS-only,
35
- TLS 1.2+); do not add `NSAllowsArbitraryLoads` or a blanket
36
- `NSExceptionDomains` bypass to `Info.plist` to work around a backend
37
- that is not yet on HTTPS — fix the backend, or scope an ATS exception
38
- to the exact domain and the exact minimum relaxation needed, with a
39
- comment saying why.
40
- - Validate TLS the platform's normal way (`URLSession`'s default trust
41
- evaluation); do not implement a `URLSessionDelegate` that accepts any
42
- server certificate (`.performDefaultHandling` bypassed with
43
- unconditional trust) outside of a short-lived local/test
44
- configuration, and never ship that in production.
25
+ - Leave App Transport Security at its default (HTTPS-only, TLS 1.2+); no
26
+ `NSAllowsArbitraryLoads` or blanket `NSExceptionDomains` bypass in `Info.plist`.
27
+ Scope any exception to the exact domain and minimum relaxation, with a comment.
28
+ - Use `URLSession`'s default trust evaluation; no `URLSessionDelegate` that
29
+ accepts any server certificate outside a short-lived local/test configuration,
30
+ and never shipped.
45
31
 
46
32
  ## Biometric authentication
47
33
 
48
- - Treat a `LAContext` biometric (Face ID/Touch ID) result as a *local
49
- presence* gate, not proof of identity to a remote server on its own —
50
- a successful `evaluatePolicy` unlocks a locally-held secret (a
51
- Keychain item, a locally cached credential); it does not substitute
52
- for a real authentication token when talking to a backend.
34
+ - A `LAContext` biometric result is a local presence gate that unlocks a
35
+ locally-held secret, not proof of identity to a backend.
53
36
  - Check the specific `LAError` case on failure (`.userCancel`,
54
- `.biometryNotAvailable`, `.biometryLockout`, ...) and present a
55
- fallback (passcode, credential re-entry) rather than treating every
56
- failure identically or silently retrying.
57
- - Do not cache "biometric succeeded" as a long-lived boolean flag read
58
- later by unrelated code paths — re-evaluate at the point access is
59
- actually needed, scoped to what that specific action requires.
37
+ `.biometryNotAvailable`, `.biometryLockout`, ...) and present a fallback
38
+ (passcode, credential re-entry); do not treat all failures alike or retry silently.
39
+ - Do not cache "biometric succeeded" as a long-lived boolean; re-evaluate where
40
+ access is needed.
60
41
 
61
42
  ## Input handling and injection-adjacent risks
62
43
 
63
- - Parameterize any `NSPredicate`/Core Data query built from
64
- user-influenced input rather than interpolating the value directly
65
- into the predicate format string — the same injection-shaped risk as
66
- building SQL by string concatenation.
67
- - Validate/sanitize any URL or deep link the app opens
68
- (`UIApplication.open`, a Universal Link handler) before acting on it —
69
- a deep link is untrusted input from outside the process, not a value
70
- to trust and route on directly.
44
+ - Parameterize any `NSPredicate`/Core Data query built from user-influenced input
45
+ rather than interpolating into the predicate format string.
46
+ - Validate any URL or deep link the app opens (`UIApplication.open`, a Universal
47
+ Link handler) before acting on it.
71
48
 
72
49
  ## Logging
73
50
 
74
- - Never log a token, password, or full PII payload at a level that
75
- reaches persistent device logs (`print`, unredacted `os_log`/`Logger`
76
- interpolation) — use `Logger`'s privacy-redaction (`\(value,
77
- privacy: .private)`) for anything sensitive, or omit it from the log
78
- entirely.
51
+ - Never log a token, password or full PII payload to persistent device logs
52
+ (`print`, unredacted `os_log`/`Logger` interpolation); use
53
+ `privacy: .private` or omit it.
@@ -7,84 +7,51 @@ metadata:
7
7
 
8
8
  # Swift/iOS testing
9
9
 
10
- Narrows `core-common-rules`' stack-agnostic testing rules to Swift
11
- Testing (the current default for new test code) and legacy XCTest, where
12
- the project has not yet migrated. Applies only to `*.swift` files.
10
+ Narrows `core-common-rules`' testing rules to Swift Testing (default for new test code) and legacy XCTest where the project has not migrated.
13
11
 
14
12
  ## Swift Testing vs XCTest
15
13
 
16
- - For new test code on a toolchain that supports it, prefer the Swift
17
- Testing framework (`import Testing`, `@Test` functions, `#expect`/
18
- `#require` macros) over XCTest — it gives clearer failure messages
19
- (`#expect` captures the evaluated sub-expressions), native
20
- parameterized tests, and tests run in parallel by default.
21
- - Swift Testing does not yet replace XCTest everywhere: UI automation
22
- (`XCUITest`) and performance tests (`XCTMetric`/`measure`) still run
23
- on XCTest, and an existing XCTest suite does not need a wholesale
24
- rewrite just to adopt Swift Testing — the two frameworks coexist in
25
- the same target. Match whichever the project's existing test target
26
- already uses for a given kind of test; introduce Swift Testing for new
27
- unit-test coverage rather than mixing conventions within one file.
28
- - A Swift Testing function is `@Test func name() async throws { ... }`
29
- (not `test`-prefixed, no `XCTestCase` subclass needed); assert with
30
- `#expect(condition)` for a check that should record a failure and
31
- continue, or `try #require(optional)` for one that must stop the test
32
- immediately if it fails (the Swift Testing equivalent of
33
- `XCTUnwrap`/`XCTAssert...` followed by an early return).
14
+ - For new tests on a toolchain that supports it, prefer Swift Testing
15
+ (`import Testing`, `@Test`, `#expect`/`#require`) over XCTest.
16
+ - `XCUITest` and performance tests (`XCTMetric`/`measure`) stay on XCTest; an
17
+ existing XCTest suite is not rewritten wholesale, and the two coexist in one
18
+ target. Match the target's existing framework per kind of test; add Swift
19
+ Testing for new unit tests, without mixing conventions within one file.
20
+ - A Swift Testing function is `@Test func name() async throws { ... }`: no
21
+ `test` prefix, no `XCTestCase` subclass. `#expect(condition)` records a failure
22
+ and continues; `try #require(optional)` stops the test.
34
23
 
35
24
  ## Structure and naming
36
25
 
37
- - One `@Test` (or `XCTest` method) per behavior being verified; a
38
- descriptive test name (`@Test("returns nil for an empty cart")` or a
39
- method named `test_returnsNil_whenCartIsEmpty`) over `test1`/`test2`.
40
- - Use Swift Testing's `arguments:` parameterization for the same
41
- assertion repeated over several inputs, instead of a hand-rolled loop
42
- inside one test function or several copy-pasted test functions that
43
- differ only by input.
44
- - Group related tests with a `struct`/`enum` namespace and Swift
45
- Testing's `@Suite`, or an `XCTestCase` subclass for legacy code,
46
- matching whatever the target already does.
26
+ - One `@Test` (or XCTest method) per behavior, with a descriptive name
27
+ (`@Test("returns nil for an empty cart")` or `test_returnsNil_whenCartIsEmpty`).
28
+ - Use `arguments:` parameterization for the same assertion over several inputs,
29
+ not a hand-rolled loop or copy-pasted tests.
30
+ - Group with a `struct`/`enum` namespace and `@Suite`, or an `XCTestCase`
31
+ subclass for legacy code, matching the target.
47
32
 
48
33
  ## Mocking at the protocol boundary
49
34
 
50
- - Mock external dependencies — network clients, persistence
51
- (`UserDefaults`, Core Data, a database layer), platform services
52
- (location, notifications) — at a protocol boundary the production code
53
- already depends on, never by mocking the type under test's own
54
- internal collaborators or reaching into its private state.
55
- - Define (or reuse) a narrow protocol for the dependency (`protocol
56
- OrderClient { func fetchOrder(id: String) async throws -> Order }`),
57
- inject a real conforming type in production and a test double
58
- conforming to the same protocol in tests — the type under test never
59
- needs to know it is under test.
60
- - Do not mock one layer too deep (stubbing a private helper method, or
61
- a concrete `URLSession` call inside a class instead of the protocol
62
- that wraps it) — that couples the test to an implementation detail and
63
- breaks on a harmless refactor instead of only on an actual behavior
64
- change.
35
+ - Mock external dependencies (network clients, persistence, platform services) at
36
+ a protocol boundary production code already depends on, never the type under
37
+ test's internal collaborators or private state.
38
+ - Define or reuse a narrow protocol (`protocol OrderClient { func fetchOrder(id: String) async throws -> Order }`),
39
+ inject the real type in production and a test double in tests.
40
+ - Do not mock one layer too deep (a private helper, or a concrete `URLSession`
41
+ call instead of the protocol that wraps it).
65
42
 
66
43
  ## Async and concurrency in tests
67
44
 
68
- - Mark a test `async` and `await` the async call under test directly —
69
- Swift Testing and modern `XCTestCase` both support `async` test
70
- methods natively; do not reach for an `XCTestExpectation`/semaphore to
71
- bridge an `async` API into a synchronous-looking test unless the
72
- project's minimum toolchain predates async test support.
73
- - Never synchronize with a fixed delay (`Thread.sleep`/`Task.sleep` used
74
- as a guess at "enough time") to wait for concurrent work to finish —
75
- `await` the async call, join a `TaskGroup`, or await an
76
- `XCTestExpectation` with a real fulfillment signal instead of a timed
77
- guess.
45
+ - Mark the test `async` and `await` the call directly; no `XCTestExpectation` or
46
+ semaphore to bridge an `async` API unless the minimum toolchain predates async tests.
47
+ - Never synchronize with a fixed delay (`Thread.sleep`/`Task.sleep` as a guess);
48
+ `await` the call, join a `TaskGroup`, or await an `XCTestExpectation` with a
49
+ real fulfillment signal.
78
50
  - Annotate a test `@MainActor` when it exercises `@MainActor`-isolated
79
- view-model/state code, so the test itself runs on the same actor its
80
- subject requires.
51
+ view-model/state code.
81
52
 
82
53
  ## Determinism
83
54
 
84
- - A test must not depend on real network access, the real Keychain, or
85
- wall-clock time; inject a fake/in-memory conforming type at the
86
- protocol boundary and, for time-dependent logic, inject a clock/date
87
- provider instead of calling `Date()` directly inside the code under
88
- test.
89
- - A bug fix gets a regression test that fails before the fix and passes
90
- after; new behavior gets new test coverage in the same change.
55
+ - No dependence on real network access, the real Keychain or wall-clock time;
56
+ inject a fake at the protocol boundary and a clock/date provider instead of
57
+ calling `Date()` in the code under test.
@@ -7,67 +7,32 @@ metadata:
7
7
 
8
8
  # Vue coding style
9
9
 
10
- Narrows `core-common-rules`' stack-agnostic style rules to Vue Single File
11
- Component conventions. Applies only to `*.vue` files -- the `<script>`
12
- block's own TypeScript style still comes from `ts-js-node`'s coding-style
13
- rule, which this file `extends` transitively through the pack's `extends`.
10
+ Narrows `core-common-rules`' style rules to Vue Single File Component
11
+ conventions. Applies only to `*.vue`; the `<script>` block's TypeScript style
12
+ comes from `ts-js-node`'s coding-style rule.
14
13
 
15
14
  ## Script setup and typing
16
15
 
17
- - Use `<script setup lang="ts">` for new components; do not introduce the
18
- Options API or a bare (non-setup) `<script>` block in new files unless the
19
- project has no `<script setup>` components at all yet.
20
- - Declare props with the type-only form, `defineProps<{ ... }>()`, not the
21
- runtime-object form (`defineProps({ foo: String })`), so prop types are
22
- checked against actual usage instead of a separate runtime shape. Use
23
- `withDefaults(defineProps<Props>(), { ... })` for default values rather
24
- than mutating the returned props object.
25
- - Declare emits with the type-only form: `defineEmits<{ change: [id: number]
26
- }>()` (named-tuple syntax) rather than the untyped string-array form
27
- (`defineEmits(['change'])`).
28
- - On Vue 3.5+ projects, destructuring `defineProps()` directly
29
- (`const { title } = defineProps<Props>()`) is reactive and preferred over
30
- a separate `props.title` reference; on pre-3.5 projects, keep the props
31
- object intact (`props.title`, or `toRefs(props)`) since a destructured
32
- prop is a frozen snapshot, not a live binding.
33
- - Type `ref<T>()` explicitly when the initial value's inferred type is
34
- narrower than the eventual type (`ref<string | null>(null)`, not a bare
35
- `ref(null)` that infers `Ref<null>`).
16
+ - Use `<script setup lang="ts">` for new components; no Options API or bare `<script>` in new files unless the project has no `<script setup>` components yet.
17
+ - Declare props type-only, `defineProps<{ ... }>()`, not the runtime-object form; use `withDefaults(defineProps<Props>(), { ... })` for defaults, not mutation of the props object.
18
+ - Declare emits type-only with named-tuple syntax, `defineEmits<{ change: [id: number] }>()`, not the string-array form.
19
+ - Vue 3.5+: destructure `defineProps()` directly (`const { title } = defineProps<Props>()`). Pre-3.5: keep the props object intact (`props.title`, or `toRefs(props)`).
20
+ - Type `ref<T>()` explicitly when the initial value infers narrower than the eventual type (`ref<string | null>(null)`).
36
21
 
37
22
  ## Naming and structure
38
23
 
39
- - Component file and `name` (when set) in `PascalCase`
40
- (`OrderSummary.vue`); composable files and exported function names in
41
- `camelCase` prefixed with `use` (`useOrderTotals.ts`).
42
- - One component per `.vue` file; a template that needs its own local
43
- sub-markup repeated more than once becomes its own child component, not a
44
- `v-for` over inline duplicated markup.
45
- - Order SFC blocks `<script setup>`, `<template>`, `<style>` (or the
46
- project's existing established order) consistently across the codebase;
47
- do not invent a third ordering in new files.
48
- - Multi-word component names (`UserCard`, not `Card`) to avoid clashing
49
- with current and future HTML elements, matching `eslint-plugin-vue`'s
50
- `multi-word-component-names` rule.
24
+ - `PascalCase` component file and `name` (`OrderSummary.vue`); composables `camelCase` prefixed `use` (`useOrderTotals.ts`).
25
+ - One component per `.vue` file; markup repeated within a template becomes a child component, not a `v-for` over inline duplicates.
26
+ - Order SFC blocks `<script setup>`, `<template>`, `<style>` (or the project's established order); no third ordering.
27
+ - Multi-word component names (`UserCard`, not `Card`), per `eslint-plugin-vue`'s `multi-word-component-names`.
51
28
 
52
29
  ## Formatting and imports
53
30
 
54
- - Format with the project's configured formatter (Prettier or the
55
- project's own config); do not hand-format around a formatter that is
56
- already configured.
57
- - Run the project's configured `eslint` (with `eslint-plugin-vue`) instead
58
- of hand-checking template directive order, unused template refs, or
59
- v-for/v-if precedence; fix what it flags rather than adding a blanket
60
- disable comment.
61
- - Prefer auto-imported composables/components only when the project has
62
- `unplugin-auto-import`/`unplugin-vue-components` (or Nuxt) configured;
63
- otherwise import explicitly -- do not assume auto-import is active.
31
+ - Format with the project's configured formatter; do not hand-format around it.
32
+ - Run the project's `eslint` with `eslint-plugin-vue`; fix what it flags, no blanket disable comment.
33
+ - Use auto-imported composables/components only when `unplugin-auto-import`/`unplugin-vue-components` (or Nuxt) is configured; otherwise import explicitly.
64
34
 
65
35
  ## Errors
66
36
 
67
- - Surface a composable or store action's failure to the caller (thrown
68
- error, or a returned error/result shape the caller checks) instead of
69
- swallowing it in a bare `catch` with no rethrow and no user-visible
70
- state change.
71
- - Use Vue's `onErrorCaptured` (component-tree scope) or a top-level
72
- `app.config.errorHandler` (app-wide scope) for error boundaries, not an
73
- ad hoc `try/catch` wrapped around every template-triggered call site.
37
+ - Surface a composable or store action's failure to the caller (thrown error or a returned error/result shape), not a bare `catch` with no rethrow and no user-visible state change.
38
+ - Use `onErrorCaptured` (component-tree scope) or `app.config.errorHandler` (app-wide) for error boundaries, not ad hoc `try/catch` around every template-triggered call.