@mrciphersmith/keryx 0.4.29 → 0.4.30

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 +2408 -1369
  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,82 +7,46 @@ metadata:
7
7
 
8
8
  # Flutter/Dart patterns
9
9
 
10
- Narrows `core-common-rules`' stack-agnostic design guidance to Flutter's
11
- widget lifecycle, state handling, and async patterns. Applies only to
12
- `*.dart` files. Flutter has no single mandated state-management story —
13
- `Provider`, `Riverpod`, `Bloc`, and plain `StatefulWidget` all appear
14
- across real projects — so this rule gives lifecycle-correct guidance that
15
- applies regardless of which the project has chosen; match whichever one is
16
- already in use rather than introducing a second approach.
10
+ Narrows `core-common-rules`' design guidance to Flutter's widget lifecycle, state handling and async patterns. The rules apply whichever of `Provider`, `Riverpod`, `Bloc` or plain `StatefulWidget` the project uses; match the one already in use, do not introduce a second.
17
11
 
18
12
  ## Widget lifecycle correctness
19
13
 
20
14
  - `initState()` is for one-time setup that needs `this` (subscribing to a
21
- controller, starting a timer, reading an inherited widget via
22
- `context.dependOnInheritedWidgetOfExactType` is not yet safe here — use
23
- `didChangeDependencies()` for that); it must call `super.initState()`
24
- first.
25
- - `dispose()` releases everything `initState()` (or a later lifecycle
26
- method) acquired: cancel every `StreamSubscription`, call `.dispose()`
27
- on every `TextEditingController`/`AnimationController`/`FocusNode`/
28
- `ScrollController` the `State` created, and call `super.dispose()` last,
29
- not first. A controller created in `initState` and never disposed leaks
30
- its underlying resources for the life of the app.
31
- - `didUpdateWidget(oldWidget)` is where a `StatefulWidget` reacts to a
32
- changed constructor parameter from its parent (e.g. re-subscribing to a
33
- different id) — comparing `oldWidget.someId != widget.someId` there,
34
- not inside `build()`, keeps that reaction from re-running on every
35
- rebuild.
15
+ controller, starting a timer); it calls `super.initState()` first. Read an
16
+ inherited widget in `didChangeDependencies()`, not `initState()`.
17
+ - `dispose()` releases everything acquired: cancel every `StreamSubscription`,
18
+ call `.dispose()` on every `TextEditingController`/`AnimationController`/
19
+ `FocusNode`/`ScrollController` the `State` created, and call `super.dispose()` last.
20
+ - React to a changed constructor parameter in `didUpdateWidget(oldWidget)`
21
+ (`oldWidget.someId != widget.someId`), not in `build()`.
36
22
 
37
23
  ## setState and BuildContext after an async gap
38
24
 
39
- - After any `await` inside a `State` method, check `mounted` (the
40
- `State`'s own property) before calling `setState()` — a `State` can be
41
- disposed while the `Future` was pending, and calling `setState()` on a
42
- disposed `State` throws.
43
- - After any `await` inside a callback that holds a `BuildContext` (a
44
- button's `onPressed`, a `Future` continuation), check `context.mounted`
45
- before using that `context` again — for showing a dialog/SnackBar,
46
- reading `Theme.of(context)`/`Navigator.of(context)`, or anything else —
47
- never assume the widget that owns it is still in the tree just because
48
- the `Future` completed. This applies whether the context came from a
49
- `StatefulWidget`'s own `State` or from a `StatelessWidget`'s `build`
50
- parameter.
51
- - An early-return `if` check on `context.mounted` (or `mounted` inside
52
- `State`) immediately after the `await`, before the first subsequent use
53
- of `context`/`setState`, is the fix — not a `try`/`catch` around the
54
- eventual error, and not skipping the check because the async call
55
- "usually" resolves quickly.
25
+ - After any `await` in a `State` method, check `mounted` before `setState()`.
26
+ - After any `await` in a callback holding a `BuildContext` (`onPressed`, a
27
+ `Future` continuation), check `context.mounted` before using it, whether the
28
+ context came from a `State` or a `StatelessWidget`'s `build` parameter.
29
+ - The fix is an early-return `if` on `context.mounted`/`mounted` immediately
30
+ after the `await`, not a `try`/`catch` around the error and not skipping the
31
+ check because the call "usually" resolves quickly.
56
32
 
57
33
  ## Async patterns
58
34
 
59
- - Prefer `async`/`await` over chained `.then()` for anything beyond a
60
- single continuation — sequential `await` reads top-to-bottom and
61
- composes with `try`/`catch` the same way synchronous code does.
62
- - For a value that arrives over time rather than once, use a `Stream` and
63
- a `StreamBuilder` (or the state-management approach's own stream/async
64
- listener), not a `Future` polled on a timer.
65
- - Cancel a `StreamSubscription` created outside `StreamBuilder` (i.e. one
66
- the `State` subscribes to manually) in `dispose()` — `StreamBuilder`
67
- itself manages its subscription's lifecycle and needs no manual cancel.
68
- - Guard a `FutureBuilder`/`StreamBuilder`'s `snapshot.connectionState`
69
- before reading `snapshot.data` — a `ConnectionState.waiting` or
70
- `.none` snapshot with a stale or null `data` rendered as if it were
71
- ready is a common source of a flashed empty/error state on first frame.
35
+ - Prefer `async`/`await` over chained `.then()` beyond a single continuation.
36
+ - For a value arriving over time, use a `Stream` with `StreamBuilder` (or the
37
+ state-management approach's own listener), not a `Future` polled on a timer.
38
+ - Cancel a manually subscribed `StreamSubscription` in `dispose()`;
39
+ `StreamBuilder` manages its own.
40
+ - Guard `snapshot.connectionState` in a `FutureBuilder`/`StreamBuilder` before
41
+ reading `snapshot.data`.
72
42
 
73
43
  ## Anti-patterns to flag
74
44
 
75
- - A `TextEditingController`/`AnimationController`/`StreamSubscription`/
76
- `FocusNode` created in `initState` with no matching release in
77
- `dispose()`.
78
- - `BuildContext` or `setState()` used after an `await` with no
79
- `context.mounted`/`mounted` check immediately before that use.
80
- - Business logic (network calls, parsing, validation) written directly
81
- inside a `build()` method instead of a controller/view-model/state
82
- object the widget merely reads from — `build()` can be called many
83
- times for reasons unrelated to data changing, so anything with a side
84
- effect or real cost does not belong there.
85
- - Mixing state-management approaches in the same feature (e.g. a
86
- `Riverpod` provider read via `ref` next to an ad hoc
87
- `InheritedWidget`/`setState` for the same piece of state) instead of
88
- following whichever one the project has already standardized on.
45
+ - A `TextEditingController`/`AnimationController`/`StreamSubscription`/`FocusNode`
46
+ created in `initState` with no matching release in `dispose()`.
47
+ - `BuildContext` or `setState()` used after an `await` with no `context.mounted`/
48
+ `mounted` check immediately before.
49
+ - Business logic (network calls, parsing, validation) inside `build()` instead of
50
+ a controller/view-model/state object.
51
+ - Mixing state-management approaches in one feature (a `Riverpod` provider read
52
+ via `ref` next to an ad hoc `InheritedWidget`/`setState` for the same state).
@@ -7,85 +7,51 @@ metadata:
7
7
 
8
8
  # Flutter/Dart security
9
9
 
10
- Narrows `core-common-rules`' stack-agnostic security rules to Flutter/Dart-
11
- specific risks and the safe APIs to use instead. Applies only to `*.dart`
12
- files.
10
+ Narrows `core-common-rules`' security rules to Flutter/Dart risks (OWASP Mobile Top 10) and the safe API for each.
13
11
 
14
12
  ## Secret and credential storage
15
13
 
16
- - Store a token, session cookie, refresh token, or any other credential in
17
- `flutter_secure_storage` (backed by Keychain on iOS, the Android
18
- Keystore on Android — check the plugin's current backing implementation
19
- rather than assuming `EncryptedSharedPreferences`, which has known
20
- reliability issues and is no longer recommended by Google for new
21
- Android code), never in `shared_preferences` — `SharedPreferences`
22
- persists as an unencrypted plist/XML file on disk that any process with
23
- filesystem access (a rooted device, a backup extraction) can read
24
- directly.
25
- - `shared_preferences` remains fine for genuinely non-sensitive
26
- preferences (a theme choice, a "seen onboarding" flag) — the rule is
27
- about what the value *is*, not a blanket ban on the package.
28
- - Never hard-code an API key, client secret, or signing credential as a
29
- Dart string literal compiled into the app — every string in a release
30
- build is recoverable from the compiled binary with straightforward
31
- reverse-engineering tools. `--dart-define`/a build-time `.env` file is
32
- NOT a way to keep a secret server-side — both are compiled into the
33
- binary at build time exactly like a string literal and are just as
34
- recoverable from the shipped artifact; they only avoid committing the
35
- secret to source control, which is a different property. For a value
36
- that must actually stay off the device, fetch it at runtime from a
37
- backend-issued short-lived token or a secrets manager reached over an
38
- authenticated network call — never bake it into the build at all.
14
+ - Store a token, session cookie, refresh token or other credential in
15
+ `flutter_secure_storage` (Keychain on iOS, Android Keystore on Android; check
16
+ the plugin's current backing implementation rather than assuming
17
+ `EncryptedSharedPreferences`, which Google no longer recommends for new Android
18
+ code), never in `shared_preferences`.
19
+ - `shared_preferences` stays fine for non-sensitive preferences (a theme choice,
20
+ a "seen onboarding" flag).
21
+ - Never hard-code an API key, client secret or signing credential as a Dart string
22
+ literal. `--dart-define` and a build-time `.env` file are compiled into the
23
+ binary like a literal; they only keep the secret out of source control. A value
24
+ that must stay off the device is fetched at runtime from a backend-issued
25
+ short-lived token or a secrets manager over an authenticated call.
39
26
 
40
27
  ## Network calls and certificate pinning
41
28
 
42
- - Use `https://` for every network call that carries user data,
43
- credentials, or tokens; a plaintext `http://` endpoint is trivially
44
- interceptable on a shared or compromised network.
45
- - For a call carrying especially sensitive data (payment, health,
46
- authentication) where the project has decided the risk of a
47
- compromised/misissued CA in the platform trust store is worth guarding
48
- against, use certificate pinning (`HttpClient.badCertificateCallback`
49
- validated against a known pin, or a package such as
50
- `http_certificate_pinning`/platform-native pinning) — but treat this as
51
- a deliberate, project-level decision with a rotation plan, not a default
52
- to apply to every request, since a mishandled pin update can lock out
53
- legitimate traffic when a certificate rotates.
54
- - Never override `badCertificateCallback` (or an equivalent HTTP client
55
- hook) to unconditionally return `true` — that disables certificate
56
- validation entirely for that client, the same failure class as Go's
57
- `InsecureSkipVerify: true`, and is never appropriate outside a
58
- short-lived local test.
29
+ - Use `https://` for every network call carrying user data, credentials or tokens.
30
+ - Certificate pinning (`HttpClient.badCertificateCallback` validated against a
31
+ known pin, `http_certificate_pinning`, or platform-native pinning) is a
32
+ deliberate project-level decision with a rotation plan for especially sensitive
33
+ data (payment, health, authentication), not a default for every request.
34
+ - Never override `badCertificateCallback` (or an equivalent hook) to return
35
+ `true` unconditionally, outside a short-lived local test.
59
36
 
60
37
  ## Platform channel and input validation
61
38
 
62
- - Validate and sanitize any value crossing a `MethodChannel`/
63
- `EventChannel` in either direction — a payload from native code is
64
- external input from the Dart side's perspective, and a payload from
65
- Dart is external input from the native side's perspective; do not trust
66
- a channel argument's shape or range without checking it, especially
67
- before using it to index a collection, build a file path, or construct
68
- a query.
69
- - Encode structured data crossing a platform channel with the codec the
70
- channel already uses (the default standard codec, or an explicit
71
- `MessageCodec`) rather than hand-rolling string concatenation/parsing
72
- across the channel boundary, which reintroduces the same injection and
73
- parsing-ambiguity risks as building a query string by hand.
39
+ - Validate and sanitize any value crossing a `MethodChannel`/`EventChannel` in
40
+ either direction before using it to index a collection, build a file path or
41
+ construct a query.
42
+ - Encode structured data crossing a channel with the channel's codec (the
43
+ standard codec or an explicit `MessageCodec`), not hand-rolled string
44
+ concatenation/parsing.
74
45
 
75
46
  ## Local storage and logging
76
47
 
77
- - Never write a secret, token, or PII value to `debugPrint`/`print` or any
78
- logging sink that a release build still ships with enabled — a log
79
- statement written for local debugging has a way of surviving into a
80
- shipped build and into crash-reporting payloads.
81
- - A `WebView` rendering any content that includes user-controlled or
82
- externally-fetched HTML must not run with JavaScript enabled on
83
- untrusted content unless the content is sanitized first — the same XSS
84
- risk class as an unescaped web template, just inside a native app.
48
+ - Never write a secret, token or PII value to `debugPrint`/`print` or any logging
49
+ sink that a release build ships enabled.
50
+ - A `WebView` rendering user-controlled or externally-fetched HTML must not run
51
+ JavaScript on untrusted content unless it is sanitized first.
85
52
 
86
53
  ## Dependency hygiene
87
54
 
88
- - Run `flutter pub outdated` and review a dependency's changelog/CVE
89
- history before a major-version bump, and prefer `dart pub deps` to
90
- understand what a new transitive dependency actually pulls in before
91
- adding it.
55
+ - Run `flutter pub outdated` and review the changelog/CVE history before a
56
+ major-version bump; use `dart pub deps` to see what a new transitive dependency
57
+ pulls in before adding it.
@@ -7,95 +7,63 @@ metadata:
7
7
 
8
8
  # Flutter/Dart testing
9
9
 
10
- Narrows `core-common-rules`' stack-agnostic testing rules to
11
- `flutter_test`'s widget-test framework and `package:test`'s unit-test
12
- conventions. Applies only to `*.dart` files.
10
+ Narrows `core-common-rules`' testing rules to `flutter_test` widget tests and `package:test` unit tests.
13
11
 
14
12
  ## Layout and naming
15
13
 
16
- - Unit and widget tests live under `test/`, mirroring `lib/`'s structure
17
- (`lib/order/order_service.dart` → `test/order/order_service_test.dart`)
18
- — no separate ad hoc fixture tree.
19
- - A widget test file's `testWidgets('<behavior it verifies>', (tester)
20
- async { ... })` description names the observable behavior under test,
21
- not the widget's implementation detail — `'shows an error banner when
22
- submit fails'`, not `'calls setState'`.
23
- - `group('OrderService', () { ... })` to cluster related cases for one
24
- class/widget, matching whatever the project's existing suite already
25
- does.
14
+ - Tests live under `test/`, mirroring `lib/`
15
+ (`lib/order/order_service.dart` -> `test/order/order_service_test.dart`); no
16
+ separate ad hoc fixture tree.
17
+ - A `testWidgets('<behavior it verifies>', ...)` description names observable
18
+ behavior (`'shows an error banner when submit fails'`), not an implementation
19
+ detail (`'calls setState'`).
20
+ - `group('OrderService', () { ... })` clusters cases for one class/widget,
21
+ matching the project's existing suite.
26
22
 
27
23
  ## Widget tests
28
24
 
29
- - Build the widget under test with `tester.pumpWidget(...)`, wrapped in
30
- whatever ancestor widgets it actually needs to render (a `MaterialApp`/
31
- `CupertinoApp`, a `Localizations` scope, a state-management provider) —
32
- matching the app's real widget tree shape, not an arbitrary bare
33
- wrapper.
34
- - Locate widgets with `find.byType`, `find.text`, `find.byKey`, or
35
- `find.byIcon` — prefer `find.byKey` for a widget identified by role
36
- rather than by its current text/type when either could plausibly change
25
+ - Build the widget with `tester.pumpWidget(...)` wrapped in the ancestors it
26
+ needs (`MaterialApp`/`CupertinoApp`, a `Localizations` scope, a
27
+ state-management provider), matching the app's real tree.
28
+ - Locate with `find.byType`, `find.text`, `find.byKey`, `find.byIcon`; prefer
29
+ `find.byKey` for a widget identified by role when its text/type could change
37
30
  without the behavior changing.
38
- - Use `tester.pump()` to advance exactly one frame (a single `setState`
39
- or a fixed-duration animation step) and `tester.pumpAndSettle()` when
40
- waiting for an animation, page transition, or async operation to fully
41
- finish before asserting — but do not reach for `pumpAndSettle()` by
42
- default for everything: a widget under a `Timer.periodic` or another
43
- never-ending animation makes `pumpAndSettle()` time out waiting for a
44
- frame that never stops changing, so a bounded `pump(Duration(...))` is
45
- the correct tool there instead.
46
- - Interact with `tester.tap(finder)`, `tester.enterText(finder, '...')`,
47
- `tester.drag(finder, offset)`, each followed by a `pump()`/
48
- `pumpAndSettle()` appropriate to what the interaction triggers, before
49
- asserting on the result.
31
+ - `tester.pump()` advances one frame; `tester.pumpAndSettle()` waits for an
32
+ animation, transition or async operation to finish. Not `pumpAndSettle()` by
33
+ default: under a `Timer.periodic` or other endless animation it times out; use a
34
+ bounded `pump(Duration(...))` there.
35
+ - Interact with `tester.tap`, `tester.enterText`, `tester.drag`, each followed by
36
+ the `pump()`/`pumpAndSettle()` the interaction needs before asserting.
50
37
 
51
38
  ## Mocking the boundary, not the internals
52
39
 
53
- - Mock at the external boundary a widget/class depends on — a repository,
54
- an HTTP client, a platform-channel wrapper — defined as an interface (an
55
- abstract class) the real implementation and a test double both satisfy,
56
- using `mocktail` (no code generation, works with sound null safety) or
57
- `mockito` (code-generation based) to build that double.
58
- - Never mock a class's own internal collaborator that exists purely to
59
- implement its behavior (a private helper, a widget's own internal
60
- state) — mocking one layer too deep tests that the implementation calls
61
- itself in a particular way, not that the widget/class actually produces
62
- the right externally-observable behavior, and it breaks on every
63
- internal refactor even when the behavior is unchanged.
64
- - Verify a mocked dependency's interaction (`verify(() =>
65
- mockRepository.fetchOrders()).called(1)`) only for calls that matter to
66
- the behavior under test — do not over-verify every incidental call,
67
- which turns the test into a change-detector for implementation details.
40
+ - Mock at the external boundary (repository, HTTP client, platform-channel
41
+ wrapper) defined as an abstract class, using `mocktail` (no code generation) or
42
+ `mockito` (code generation).
43
+ - Never mock a class's own internal collaborator (a private helper, a widget's
44
+ internal state).
45
+ - Verify a mocked interaction (`verify(() => mockRepository.fetchOrders()).called(1)`)
46
+ only for calls that matter to the behavior; do not over-verify incidental calls.
68
47
 
69
48
  ## Async state in widget tests
70
49
 
71
- - When a widget's state depends on a `Future` (a repository call behind a
72
- loading spinner), pump through the states explicitly: `pump()` once to
73
- render the loading state, then `pump()`/`pumpAndSettle()` again after
74
- the mocked `Future` resolves, asserting the loading indicator is gone
75
- and the real content is present — asserting only on the state
76
- immediately after `pumpWidget()` misses the loading-to-loaded
77
- transition entirely.
78
- - Never use `Future.delayed`/a real `Duration` wait inside a test to give
79
- a mocked async call "enough time" to resolve — control the mock's
80
- `Future` directly (a `Completer` the test completes explicitly, or a
81
- mock configured to resolve immediately) and drive time forward with
82
- `pump()`/`pumpAndSettle()`/`tester.pump(duration)` instead, so the test
83
- is deterministic rather than timing-dependent.
50
+ - For state depending on a `Future`, `pump()` once for the loading state, then
51
+ `pump()`/`pumpAndSettle()` after the mocked `Future` resolves, asserting the
52
+ loading indicator is gone and the content is present.
53
+ - Never use `Future.delayed` or a real `Duration` wait in a test; control the
54
+ mock's `Future` (a `Completer` the test completes, or an immediately resolving
55
+ mock) and advance time with `pump()`/`pumpAndSettle()`/`tester.pump(duration)`.
84
56
 
85
57
  ## Fixtures and golden tests
86
58
 
87
- - `testWidgets` fixtures (sample model instances, mock repository
88
- responses) live in a `test/fixtures/` or per-feature helper file,
89
- matching whatever the project already uses — do not invent a second
90
- fixture convention alongside an existing one.
91
- - A golden-image test (`matchesGoldenFile`) is opt-in per project; only
92
- add one where the project already has a golden-test setup and baseline
93
- images checked in, and regenerate baselines deliberately (`flutter test
94
- --update-goldens`), not as a side effect of an unrelated change.
59
+ - Fixtures (sample models, mock repository responses) live in `test/fixtures/` or
60
+ a per-feature helper file, matching the project; no second fixture convention.
61
+ - A golden-image test (`matchesGoldenFile`) is opt-in: add one only where the
62
+ project already has a golden setup and checked-in baselines, and regenerate
63
+ with `flutter test --update-goldens` deliberately, not as a side effect.
95
64
 
96
65
  ## Running and coverage
97
66
 
98
- - Run `flutter test` (or `flutter test --coverage` when the project
99
- tracks coverage) before reporting a testing task done; fix a failing
100
- test by correcting the test or the fixture it depends on, not by
101
- weakening its `expect`/`find` assertion to make it pass.
67
+ - Run `flutter test` (`--coverage` when the project tracks coverage) before
68
+ reporting a testing task done; fix a failing test by correcting the test or its
69
+ fixture, not by weakening its `expect`/`find` assertion.
@@ -8,78 +8,57 @@ metadata:
8
8
  # Go coding style
9
9
 
10
10
  Narrows `core-common-rules`' stack-agnostic style rules to modern Go
11
- (1.23-1.25) idiom. Applies only to `*.go` files — everything not
12
- Go-specific still comes from the common rules this file `extends`.
11
+ (1.23-1.25) idiom, following Effective Go and the Go Code Review Comments.
12
+ Applies only to `*.go` files.
13
13
 
14
14
  ## Naming and structure
15
15
 
16
- - Package names are short, lowercase, no underscores or `mixedCaps`
17
- (`user`, not `user_service` or `userService`); do not stutter the package
18
- name in exported identifiers (`user.User`, not `user.UserAccount`).
19
- - `MixedCaps`/`mixedCaps`, never `snake_case`, for identifiers — exported
20
- starts with an uppercase letter, unexported with lowercase.
21
- - Keep `main` thin: business logic lives in packages under `internal/` (or
22
- a library's own top-level packages), `cmd/<binary>/main.go` only wires
23
- flags/config and calls into them.
24
- - An identifier's name shrinks with its scope: a loop index is `i`, a
25
- package-level exported function gets a full descriptive name.
16
+ - Package names are short, lowercase, no underscores; do not stutter the
17
+ package name in exported identifiers (`user.User`, not `user.UserAccount`).
18
+ - Keep `main` thin: logic lives in packages under `internal/`,
19
+ `cmd/<binary>/main.go` only wires flags/config.
26
20
 
27
21
  ## Interfaces and structs
28
22
 
29
- - Accept interfaces, return structs: a function parameter should be the
30
- narrowest interface the callee needs; a constructor returns the concrete
31
- `*Thing`, not an interface, so callers get the full method set and the
32
- compiler catches a missing method at the definition site.
33
- - Define an interface at the consumer (the package that calls through it),
34
- not the producer (the package that implements it) — `io.Reader`-sized:
35
- one or two methods. A producer-side interface with only one
36
- implementation is usually unnecessary indirection.
37
- - Prefer a zero-value-useful struct (`var b bytes.Buffer` works with no
38
- constructor) over requiring `New()` when the zero value is meaningful.
23
+ - Accept interfaces, return structs: parameters take the narrowest interface
24
+ the callee needs; a constructor returns the concrete `*Thing`.
25
+ - Define an interface at the consumer, one or two methods; a producer-side
26
+ interface with one implementation is unnecessary.
27
+ - Prefer a zero-value-useful struct over requiring `New()` when the zero
28
+ value is meaningful.
39
29
 
40
30
  ## Errors
41
31
 
42
- - Every returned `error` is checked or explicitly and visibly discarded
43
- (`_ = f.Close() // best-effort`) — never silently dropped.
44
- - Wrap with context using `fmt.Errorf("doing x: %w", err)`, not `%v`, so
45
- the original error survives for `errors.Is`/`errors.As` up the call
46
- stack. Wrap once per meaningful layer, not at every call site.
47
- - Compare sentinel errors with `errors.Is`, and unwrap typed errors with
48
- `errors.As` — never a string comparison (`err.Error() == "..."` ) or a
49
- bare `==` against a wrapped error.
50
- - A package-level sentinel error is `var ErrNotFound = errors.New("...")`,
51
- named `Err<Reason>`; a custom error type implements `Error() string` and,
52
- when it wraps another error, `Unwrap() error`.
32
+ - Every returned `error` is checked or visibly discarded
33
+ (`_ = f.Close() // best-effort`).
34
+ - Wrap with `fmt.Errorf("doing x: %w", err)`, not `%v`; wrap once per
35
+ meaningful layer, not at every call site.
36
+ - Compare with `errors.Is`/`errors.As`, never `err.Error() == "..."` or bare
37
+ `==` against a wrapped error.
38
+ - Sentinel errors are `var ErrNotFound = errors.New("...")`, named
39
+ `Err<Reason>`; a custom error type that wraps another implements
40
+ `Unwrap() error`.
53
41
 
54
42
  ## Concurrency and context
55
43
 
56
- - `context.Context` is always the first parameter, named `ctx`, and is
57
- never stored on a struct field — thread it through call chains instead.
58
- - Every goroutine a function starts has an explicit owner that knows when
59
- it exits: joined with `sync.WaitGroup` (or `WaitGroup.Go` on a toolchain
60
- that has it), bounded by `errgroup.Group`, or cancelled through the
61
- `ctx` it was given. A goroutine with no join point and no cancellation
62
- path is a leak, not fire-and-forget.
63
- - Check `ctx.Err()` / respect `ctx.Done()` in any loop or blocking call
64
- that should stop when the caller cancels.
44
+ - `context.Context` is the first parameter, named `ctx`, never stored on a
45
+ struct field.
46
+ - Every goroutine has an owner that knows when it exits: `sync.WaitGroup`
47
+ (or `WaitGroup.Go`), `errgroup.Group`, or the `ctx` it was given.
48
+ - Respect `ctx.Done()`/`ctx.Err()` in any loop or blocking call that should
49
+ stop on cancel.
65
50
 
66
51
  ## Generics and modern idiom
67
52
 
68
- - Reach for a type parameter only when it removes real duplication (a
69
- container, a generic algorithm over `constraints.Ordered`-like sets) —
70
- do not generify a function with one concrete call site "for the future".
71
- - Use `log/slog` for structured logging in new code, not `log.Printf` or a
72
- bespoke logger, unless the project has already standardized on
73
- something else.
74
- - A `range-over-func` iterator (`func(yield func(T) bool)`) is fine for a
75
- package's own lazy sequence API on Go 1.23+; do not introduce it purely
76
- to look modern when a plain slice-returning function reads more clearly.
53
+ - A type parameter only when it removes real duplication; do not generify a
54
+ function with one concrete call site.
55
+ - `log/slog` for structured logging in new code, unless the project has
56
+ standardized on something else.
57
+ - A `range-over-func` iterator only for a package's own lazy sequence API on
58
+ Go 1.23+, not where a slice-returning function reads more clearly.
77
59
 
78
60
  ## Formatting and imports
79
61
 
80
- - Format with `gofmt`/`goimports` before finishing a change; do not
81
- hand-format around a formatter that is already configured (CI enforces
82
- `gofmt -l` in most Go repos).
83
- - Group imports stdlib / third-party / local with a blank line between
84
- groups — `goimports` does this automatically; run it instead of
85
- hand-ordering.
62
+ - Format with `gofmt`/`goimports`; do not hand-format around a configured
63
+ formatter.
64
+ - Imports grouped stdlib / third-party / local.
@@ -8,58 +8,43 @@ metadata:
8
8
  # Go patterns
9
9
 
10
10
  Narrows `core-common-rules`' stack-agnostic design guidance to idiomatic
11
- Go design and its common anti-patterns. Applies only to `*.go` files.
11
+ Go design (Effective Go, Go Proverbs). Applies only to `*.go` files.
12
12
 
13
13
  ## Module and package layout
14
14
 
15
- - `cmd/<binary>/` holds one `main` package per executable; `internal/`
16
- holds packages this module's own code may import but nothing outside
17
- the module can — put anything not meant as a public API surface there.
18
- - A package should have a clear, single responsibility; a package that
19
- only holds shared types with no behavior ("models", "types", "common")
20
- invites import cycles as the project grows — prefer colocating a type
21
- with the package that owns its behavior.
22
- - Avoid import cycles by depth, not by breaking them with an `internal`
23
- workaround package — if package A needs package B's type and B needs
24
- A's, one of the two owns too much; extract the shared piece into a
25
- third package both depend on.
15
+ - `cmd/<binary>/` holds one `main` package per executable; anything not a
16
+ public API surface goes under `internal/`.
17
+ - No shared-types-only packages ("models", "types", "common"); colocate a
18
+ type with the package that owns its behavior.
19
+ - Break an import cycle by extracting the shared piece into a third package,
20
+ not with an `internal` workaround package.
26
21
 
27
22
  ## Idiomatic concurrency patterns
28
23
 
29
- - Fan-out/fan-in: bound the number of concurrent workers (a worker pool or
30
- `golang.org/x/sync/errgroup`'s `SetLimit`), never spawn one goroutine per
31
- input item on an unbounded input source.
32
- - Use `errgroup.Group` when a set of goroutines shares one cancellation
33
- and you need the first error; use a plain `sync.WaitGroup` when you only
34
- need to know they finished and errors are handled another way.
35
- - Prefer channels for signaling and handoff, mutexes for protecting shared
36
- state — do not build a hand-rolled semaphore out of a channel when
37
- `sync.Mutex` (or `errgroup.SetLimit`) already says what you mean.
38
- - Close a channel only from the sender, never the receiver, and only
39
- once; a `nil` channel blocks forever on send/receive, which is
40
- occasionally the correct way to disable a `select` case.
24
+ - Fan-out/fan-in: bound concurrent workers (worker pool or
25
+ `errgroup`'s `SetLimit`); never one goroutine per item on an unbounded
26
+ source.
27
+ - `errgroup.Group` when goroutines share one cancellation and you need the
28
+ first error; plain `sync.WaitGroup` when you only need completion.
29
+ - Channels for signaling and handoff, mutexes for shared state; no
30
+ hand-rolled channel semaphore where `sync.Mutex` or `errgroup.SetLimit`
31
+ fits.
32
+ - Close a channel only from the sender, only once; a `nil` channel is a valid
33
+ way to disable a `select` case.
41
34
 
42
35
  ## Composition over inheritance
43
36
 
44
- - Use struct embedding to reuse behavior only when the embedding type
45
- genuinely "is-a" superset of the embedded one's API; prefer an explicit
46
- field plus delegation when you would otherwise promote methods the
47
- caller should not see.
37
+ - Struct embedding only when the embedding type is a true superset of the
38
+ embedded one's API; otherwise an explicit field plus delegation.
48
39
  - Functional options (`func WithTimeout(d time.Duration) Option`) for a
49
- constructor with many optional parameters, instead of a boolean-heavy
50
- positional signature or a half-filled config struct.
40
+ constructor with many optional parameters.
51
41
 
52
42
  ## Anti-patterns to flag
53
43
 
54
- - A large `interface{}`/`any`-typed function signature where a generic
55
- type parameter or a smaller concrete interface would give compile-time
56
- safety back.
57
- - A "god package" (`utils`, `helpers`, `common`) that accumulates
58
- unrelated functions — split by what the code actually does.
59
- - Returning a pointer to a struct solely to allow a `nil` "not found"
60
- value where a `(T, bool)` or a named error (`ErrNotFound`) return is
61
- clearer and avoids nil-pointer-dereference risk at the call site.
62
- - Panic used for ordinary control flow (a missing map key, a failed
63
- lookup); reserve `panic` for programmer errors that should crash during
64
- development (a violated invariant, an unreachable `default` case), and
65
- return an `error` for everything a caller could reasonably handle.
44
+ - A large `interface{}`/`any`-typed signature where a type parameter or
45
+ smaller concrete interface fits.
46
+ - A "god package" (`utils`, `helpers`, `common`).
47
+ - Returning a pointer solely to allow a `nil` "not found"; use `(T, bool)` or
48
+ a named error (`ErrNotFound`).
49
+ - `panic` for ordinary control flow; reserve it for violated invariants and
50
+ unreachable `default` cases, return an `error` otherwise.