prr-kit 1.1.2 → 1.2.0

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 (173) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +260 -235
  3. package/docs/assets/banner.svg +33 -165
  4. package/docs/assets/how-it-works.svg +87 -0
  5. package/package.json +60 -60
  6. package/src/core/agents/prr-master.agent.yaml +18 -7
  7. package/src/core/tasks/clear.md +140 -0
  8. package/src/core/tasks/help.md +15 -13
  9. package/src/core/workflows/clear/workflow.md +6 -0
  10. package/src/core/workflows/help/workflow.md +6 -0
  11. package/src/core/workflows/party-mode/steps/step-01-load-reviewers.md +35 -24
  12. package/src/core/workflows/party-mode/steps/step-02-discussion.md +45 -25
  13. package/src/core/workflows/party-mode/workflow.md +2 -2
  14. package/src/prr/agents/architecture-reviewer.agent.yaml +65 -45
  15. package/src/prr/agents/business-reviewer.agent.yaml +66 -0
  16. package/src/prr/agents/general-reviewer.agent.yaml +64 -48
  17. package/src/prr/agents/performance-reviewer.agent.yaml +65 -45
  18. package/src/prr/agents/security-reviewer.agent.yaml +67 -43
  19. package/src/prr/config-template.yaml +97 -0
  20. package/src/prr/data/stacks/actix.md +55 -0
  21. package/src/prr/data/stacks/alpine.md +47 -0
  22. package/src/prr/data/stacks/android.md +53 -0
  23. package/src/prr/data/stacks/angular.md +96 -0
  24. package/src/prr/data/stacks/ansible.md +55 -0
  25. package/src/prr/data/stacks/apollo.md +54 -0
  26. package/src/prr/data/stacks/astro.md +48 -0
  27. package/src/prr/data/stacks/aws-cdk.md +55 -0
  28. package/src/prr/data/stacks/axum.md +56 -0
  29. package/src/prr/data/stacks/babylonjs.md +55 -0
  30. package/src/prr/data/stacks/bash.md +53 -0
  31. package/src/prr/data/stacks/bevy.md +53 -0
  32. package/src/prr/data/stacks/bootstrap.md +52 -0
  33. package/src/prr/data/stacks/bun.md +55 -0
  34. package/src/prr/data/stacks/cpp.md +57 -0
  35. package/src/prr/data/stacks/csharp.md +95 -0
  36. package/src/prr/data/stacks/css.md +55 -0
  37. package/src/prr/data/stacks/cypress.md +53 -0
  38. package/src/prr/data/stacks/d3.md +53 -0
  39. package/src/prr/data/stacks/deno.md +49 -0
  40. package/src/prr/data/stacks/django.md +92 -0
  41. package/src/prr/data/stacks/docker.md +79 -0
  42. package/src/prr/data/stacks/drizzle.md +54 -0
  43. package/src/prr/data/stacks/dynamodb.md +55 -0
  44. package/src/prr/data/stacks/electron.md +44 -0
  45. package/src/prr/data/stacks/elixir.md +53 -0
  46. package/src/prr/data/stacks/expo.md +53 -0
  47. package/src/prr/data/stacks/expressjs.md +82 -0
  48. package/src/prr/data/stacks/fastapi.md +88 -0
  49. package/src/prr/data/stacks/fastify.md +60 -0
  50. package/src/prr/data/stacks/fiber.md +55 -0
  51. package/src/prr/data/stacks/firebase.md +43 -0
  52. package/src/prr/data/stacks/flask.md +46 -0
  53. package/src/prr/data/stacks/flutter.md +75 -0
  54. package/src/prr/data/stacks/gin.md +57 -0
  55. package/src/prr/data/stacks/github-actions.md +71 -0
  56. package/src/prr/data/stacks/go.md +88 -0
  57. package/src/prr/data/stacks/godot.md +56 -0
  58. package/src/prr/data/stacks/graphql.md +76 -0
  59. package/src/prr/data/stacks/grpc.md +56 -0
  60. package/src/prr/data/stacks/haskell.md +48 -0
  61. package/src/prr/data/stacks/helm.md +54 -0
  62. package/src/prr/data/stacks/hono.md +54 -0
  63. package/src/prr/data/stacks/htmx.md +38 -0
  64. package/src/prr/data/stacks/java.md +87 -0
  65. package/src/prr/data/stacks/jest-vitest.md +87 -0
  66. package/src/prr/data/stacks/jquery.md +50 -0
  67. package/src/prr/data/stacks/junit.md +53 -0
  68. package/src/prr/data/stacks/kotlin.md +89 -0
  69. package/src/prr/data/stacks/kubernetes.md +148 -0
  70. package/src/prr/data/stacks/langchain.md +56 -0
  71. package/src/prr/data/stacks/laravel.md +56 -0
  72. package/src/prr/data/stacks/libgdx.md +46 -0
  73. package/src/prr/data/stacks/lit.md +49 -0
  74. package/src/prr/data/stacks/love2d.md +51 -0
  75. package/src/prr/data/stacks/lua.md +51 -0
  76. package/src/prr/data/stacks/mobx.md +54 -0
  77. package/src/prr/data/stacks/mongodb.md +85 -0
  78. package/src/prr/data/stacks/monogame.md +51 -0
  79. package/src/prr/data/stacks/mysql.md +57 -0
  80. package/src/prr/data/stacks/nestjs.md +95 -0
  81. package/src/prr/data/stacks/nextjs.md +88 -0
  82. package/src/prr/data/stacks/nginx.md +55 -0
  83. package/src/prr/data/stacks/node.md +56 -0
  84. package/src/prr/data/stacks/nuxtjs.md +91 -0
  85. package/src/prr/data/stacks/openai-api.md +54 -0
  86. package/src/prr/data/stacks/opengl.md +54 -0
  87. package/src/prr/data/stacks/phaser.md +54 -0
  88. package/src/prr/data/stacks/phoenix.md +55 -0
  89. package/src/prr/data/stacks/php.md +56 -0
  90. package/src/prr/data/stacks/playwright.md +86 -0
  91. package/src/prr/data/stacks/postgresql.md +60 -0
  92. package/src/prr/data/stacks/prisma.md +81 -0
  93. package/src/prr/data/stacks/pygame.md +52 -0
  94. package/src/prr/data/stacks/pytest.md +53 -0
  95. package/src/prr/data/stacks/python.md +94 -0
  96. package/src/prr/data/stacks/pytorch.md +54 -0
  97. package/src/prr/data/stacks/qwik.md +50 -0
  98. package/src/prr/data/stacks/rails.md +48 -0
  99. package/src/prr/data/stacks/react-native.md +77 -0
  100. package/src/prr/data/stacks/react.md +104 -0
  101. package/src/prr/data/stacks/redis.md +76 -0
  102. package/src/prr/data/stacks/redux.md +107 -0
  103. package/src/prr/data/stacks/remix.md +51 -0
  104. package/src/prr/data/stacks/rust.md +88 -0
  105. package/src/prr/data/stacks/sass.md +51 -0
  106. package/src/prr/data/stacks/scala.md +50 -0
  107. package/src/prr/data/stacks/scikit-learn.md +53 -0
  108. package/src/prr/data/stacks/sequelize.md +54 -0
  109. package/src/prr/data/stacks/socket-io.md +54 -0
  110. package/src/prr/data/stacks/solidity.md +53 -0
  111. package/src/prr/data/stacks/solidjs.md +45 -0
  112. package/src/prr/data/stacks/spring-boot.md +92 -0
  113. package/src/prr/data/stacks/sql.md +85 -0
  114. package/src/prr/data/stacks/sqlite.md +55 -0
  115. package/src/prr/data/stacks/styled-components.md +51 -0
  116. package/src/prr/data/stacks/supabase.md +57 -0
  117. package/src/prr/data/stacks/svelte.md +77 -0
  118. package/src/prr/data/stacks/sveltekit.md +54 -0
  119. package/src/prr/data/stacks/swift.md +61 -0
  120. package/src/prr/data/stacks/tailwindcss.md +10 -0
  121. package/src/prr/data/stacks/tanstack-query.md +48 -0
  122. package/src/prr/data/stacks/tauri.md +52 -0
  123. package/src/prr/data/stacks/terraform.md +53 -0
  124. package/src/prr/data/stacks/three.md +53 -0
  125. package/src/prr/data/stacks/trpc.md +49 -0
  126. package/src/prr/data/stacks/typeorm.md +40 -0
  127. package/src/prr/data/stacks/typescript.md +83 -0
  128. package/src/prr/data/stacks/unity.md +61 -0
  129. package/src/prr/data/stacks/unreal.md +58 -0
  130. package/src/prr/data/stacks/vite.md +48 -0
  131. package/src/prr/data/stacks/vue3.md +95 -0
  132. package/src/prr/data/stacks/vulkan.md +53 -0
  133. package/src/prr/data/stacks/wasm.md +49 -0
  134. package/src/prr/data/stacks/webpack.md +48 -0
  135. package/src/prr/data/stacks/zig.md +51 -0
  136. package/src/prr/data/stacks/zustand.md +56 -0
  137. package/src/prr/workflows/1-discover/select-pr/steps/step-05-confirm.md +1 -0
  138. package/src/prr/workflows/1-discover/select-pr/workflow.md +1 -1
  139. package/src/prr/workflows/2-analyze/collect-pr-context/steps/step-01-analyze-files.md +334 -0
  140. package/src/prr/workflows/2-analyze/collect-pr-context/steps/step-02-collect-sources.md +451 -0
  141. package/src/prr/workflows/2-analyze/collect-pr-context/steps/step-03-build-knowledge-base.md +337 -0
  142. package/src/prr/workflows/2-analyze/collect-pr-context/workflow.md +123 -0
  143. package/src/prr/workflows/2-analyze/describe-pr/steps/step-02-classify.md +12 -6
  144. package/src/prr/workflows/2-analyze/describe-pr/steps/step-03-walkthrough.md +59 -1
  145. package/src/prr/workflows/3-review/architecture-review/checklist.md +4 -0
  146. package/src/prr/workflows/3-review/architecture-review/instructions.xml +32 -4
  147. package/src/prr/workflows/3-review/architecture-review/workflow.yaml +17 -18
  148. package/src/prr/workflows/3-review/business-review/checklist.md +27 -0
  149. package/src/prr/workflows/3-review/business-review/instructions.xml +153 -0
  150. package/src/prr/workflows/3-review/business-review/workflow.yaml +17 -0
  151. package/src/prr/workflows/3-review/general-review/checklist.md +5 -1
  152. package/src/prr/workflows/3-review/general-review/instructions.xml +39 -8
  153. package/src/prr/workflows/3-review/general-review/workflow.yaml +17 -18
  154. package/src/prr/workflows/3-review/performance-review/checklist.md +3 -1
  155. package/src/prr/workflows/3-review/performance-review/instructions.xml +10 -3
  156. package/src/prr/workflows/3-review/performance-review/workflow.yaml +17 -18
  157. package/src/prr/workflows/3-review/security-review/checklist.md +2 -1
  158. package/src/prr/workflows/3-review/security-review/instructions.xml +8 -3
  159. package/src/prr/workflows/3-review/security-review/workflow.yaml +18 -19
  160. package/src/prr/workflows/4-improve/improve-code/workflow.yaml +17 -18
  161. package/src/prr/workflows/6-report/generate-report/steps/step-01-collect.md +9 -2
  162. package/src/prr/workflows/6-report/generate-report/steps/step-02-organize.md +28 -7
  163. package/src/prr/workflows/6-report/generate-report/steps/step-03-write.md +6 -4
  164. package/src/prr/workflows/6-report/generate-report/templates/review-report.template.md +124 -78
  165. package/src/prr/workflows/6-report/post-comments/steps/step-01-format.md +104 -13
  166. package/src/prr/workflows/6-report/post-comments/steps/step-02-post.md +92 -21
  167. package/src/prr/workflows/6-report/post-comments/workflow.md +6 -0
  168. package/src/prr/workflows/quick/workflow.md +138 -32
  169. package/src/prr/workflows/0-setup/collect-project-context/steps/step-01-scan-configs.md +0 -106
  170. package/src/prr/workflows/0-setup/collect-project-context/steps/step-02-extract-rules.md +0 -131
  171. package/src/prr/workflows/0-setup/collect-project-context/steps/step-03-ask-context.md +0 -194
  172. package/src/prr/workflows/0-setup/collect-project-context/steps/step-04-save-context.md +0 -161
  173. package/src/prr/workflows/0-setup/collect-project-context/workflow.md +0 -58
@@ -0,0 +1,61 @@
1
+ # Unity — Stack-Specific Review Rules
2
+
3
+ > Applies to: GR · SR · PR · AR · BR
4
+ > Detection signals: `*.cs` in Unity project, `UnityEngine`, `MonoBehaviour`, `using UnityEngine`, `Assets/`, `ProjectSettings/`, `.unity` scenes, `Awake()`, `Start()`, `Update()`
5
+
6
+ ---
7
+
8
+ ## Security
9
+ - **[CRITICAL]** Deserializing untrusted data with `BinaryFormatter` → arbitrary code execution; replace with `JsonUtility` or a safe serializer and validate schemas before deserialization.
10
+ - **[HIGH]** Downloading and executing AssetBundles from unverified URLs → malicious asset injection at runtime; verify bundle URLs against an allowlist and validate bundle hashes after download.
11
+ - **[HIGH]** Storing sensitive data (auth tokens, purchase receipts) in `PlayerPrefs` → written as plaintext to disk and registry; use encrypted storage or OS keychain APIs instead.
12
+ - **[HIGH]** Trusting client-reported game state without server-side validation → cheating via memory editors; authoritative game server must validate all state transitions.
13
+ - **[HIGH]** WebGL builds exposing full game logic to browser DevTools → JavaScript decompilation trivial; obfuscate builds and never embed secrets in client code.
14
+ - **[MEDIUM]** Sensitive save data written to `Application.persistentDataPath` without encryption → readable by any process with file access; encrypt with `AES` before writing.
15
+ - **[MEDIUM]** Hardcoded API keys or credentials committed in C# scripts → exposed in version history and decompiled assemblies; load from environment or encrypted config at runtime.
16
+
17
+ ---
18
+
19
+ ## Performance
20
+ - **[CRITICAL]** Heavy logic (physics queries, pathfinding, string operations) in `Update()` instead of event-driven patterns or coroutines → CPU overhead every frame at 60+ Hz; move to events, coroutines, or throttled polling.
21
+ - **[HIGH]** `GameObject.Find()` or `FindObjectOfType()` called in `Update()` → O(n) linear scene search every frame; cache references in `Awake()` or `Start()`.
22
+ - **[HIGH]** Frequent `Instantiate()`/`Destroy()` cycles for projectiles, particles, or enemies → GC pressure and frame spikes; implement an Object Pooling system.
23
+ - **[HIGH]** Textures not compressed with platform-appropriate formats (DXT on Windows, ETC2 on Android, ASTC on iOS) → excessive VRAM usage and slower GPU sampling.
24
+ - **[HIGH]** Component references retrieved via `GetComponent<T>()` every frame instead of cached `[SerializeField]` fields → repeated reflection-based lookups; cache in `Awake()`.
25
+ - **[MEDIUM]** `Camera.main` accessed in `Update()` → performs an O(n) tag search each call; cache the camera reference in `Awake()`.
26
+ - **[MEDIUM]** String concatenation or `string.Format()` in `Update()` → heap allocation every frame causing GC spikes; use `StringBuilder` or cached strings.
27
+ - **[MEDIUM]** `FixedUpdate` rate not tuned for game type → too high wastes CPU, too low makes physics feel loose; set `Project Settings > Time > Fixed Timestep` appropriately.
28
+ - **[LOW]** Release builds using Mono scripting backend instead of IL2CPP → lower runtime performance and easier decompilation; switch to IL2CPP for all shipping builds.
29
+
30
+ ---
31
+
32
+ ## Architecture
33
+ - **[HIGH]** MonoBehaviour acting as a God Object handling input, AI, physics, UI, and networking → untestable and unresusable; decompose into focused components and use composition.
34
+ - **[HIGH]** Inter-object communication via `Find`/`FindObjectOfType` instead of events, interfaces, or ScriptableObject channels → tight coupling that breaks on scene changes; use UnityEvents or ScriptableObject event channels.
35
+ - **[HIGH]** Game state stored in static fields → impossible to reset cleanly without a full restart; use a dedicated game state class, ScriptableObjects, or a scene-reload strategy.
36
+ - **[MEDIUM]** Shared configuration and data not using `ScriptableObject` assets → duplicated magic numbers across prefabs; centralize into ScriptableObject data containers.
37
+ - **[MEDIUM]** Game logic tightly coupled to Unity lifecycle methods → cannot be unit tested outside the editor; separate pure logic into plain C# classes called from MonoBehaviours.
38
+ - **[MEDIUM]** Large open-world scenes loaded as a single scene → long load times and no streaming; use additive scene loading with async `LoadSceneMode.Additive`.
39
+ - **[LOW]** Legacy Input Manager still used (`Input.GetKey`) → deprecated path with no rebinding support; migrate to the new Input System package.
40
+
41
+ ---
42
+
43
+ ## Code Quality
44
+ - **[HIGH]** Null checks using `if (component != null)` on destroyed GameObjects → Unity overrides `==` operator; a destroyed object is `== null` but not `is null`; use Unity's `==` and avoid `is null` or `?.` on UnityObjects.
45
+ - **[HIGH]** Coroutines started with `StartCoroutine()` but never stopped → run indefinitely after the owning object is disabled or the scene changes; always pair with `StopCoroutine()` or stop on `OnDisable()`/`OnDestroy()`.
46
+ - **[MEDIUM]** Layer mask indices and Animator parameter names as magic integers/strings → silent breakage on project changes; define named constants or use `Animator.StringToHash()`.
47
+ - **[MEDIUM]** Missing `[RequireComponent(typeof(T))]` attribute when a MonoBehaviour always depends on another component → runtime NullReference when component is absent; declare the dependency explicitly.
48
+ - **[MEDIUM]** Editor-only debugging code not wrapped in `#if UNITY_EDITOR` → shipped in builds and potentially crashing; guard all editor utilities.
49
+ - **[LOW]** Public fields used for Inspector exposure instead of `[SerializeField] private` → breaks encapsulation; prefer `[SerializeField]` with private backing fields.
50
+
51
+ ---
52
+
53
+ ## Common Bugs & Pitfalls
54
+ - **[CRITICAL]** Accessing a MonoBehaviour's properties or methods after `Destroy()` on the same frame → the object is destroyed at end-of-frame but references remain; null-check with Unity's `==` before access.
55
+ - **[HIGH]** Starting a Coroutine on a disabled or inactive GameObject → Unity silently refuses to start it and no warning is shown; ensure the GameObject is active, or use a persistent manager object.
56
+ - **[HIGH]** Event subscriptions (C# events, UnityEvents) added in `OnEnable()` not removed in `OnDisable()` or `OnDestroy()` → memory leaks and NullReferenceException callbacks after object destruction.
57
+ - **[HIGH]** `Awake()` and `Start()` execution order between objects not controlled → initialization race conditions when object A depends on object B's `Awake()` having run; use Script Execution Order settings or deferred initialization.
58
+ - **[MEDIUM]** Movement or animation speed not multiplied by `Time.deltaTime` → frame-rate dependent behaviour; always scale per-frame changes by `Time.deltaTime`.
59
+ - **[MEDIUM]** `DontDestroyOnLoad` manager objects duplicated when reloading the scene that created them → multiple singletons fighting; enforce singleton pattern with scene-existence check in `Awake()`.
60
+ - **[MEDIUM]** Physics queries (`Raycast`, `OverlapSphere`) using wrong layer masks → hitting unintended objects or missing targets; always specify a layer mask.
61
+ - **[LOW]** Hot `Vector3` arithmetic in tight loops creating intermediate structs → excessive stack pressure; use `ref`-parameter overloads or operate on components directly for hot paths.
@@ -0,0 +1,58 @@
1
+ # Unreal Engine — Stack-Specific Review Rules
2
+
3
+ > Applies to: GR · SR · PR · AR · BR
4
+ > Detection signals: `*.cpp`/`*.h` in Unreal project, `UCLASS()`, `UPROPERTY()`, `UFUNCTION()`, `AGameMode`, `UObject`, `FString`, `TArray`, `GEngine`, `.uproject`
5
+
6
+ ---
7
+
8
+ ## Security
9
+ - **[HIGH]** Server RPC (`UFUNCTION(Server, Reliable)`) executing game-state changes without authority check → clients can call any server RPC arbitrarily; always verify `HasAuthority()` at the start of every server RPC.
10
+ - **[HIGH]** Unvalidated client-reported game state accepted by server → cheating via modified clients; keep authoritative logic on server and treat all client input as untrusted.
11
+ - **[HIGH]** Serialized save game data loaded without schema validation → malformed or tampered saves can crash the server or client; validate all fields before use after `LoadGameFromSlot`.
12
+ - **[MEDIUM]** Server URLs, API keys, or backend endpoints hardcoded in Blueprint or C++ → visible in packaged builds via asset extraction; load secrets from server-side config or use backend relay.
13
+ - **[MEDIUM]** UE_LOG calls and console commands (e.g., `cheats`, `showdebug`) accessible in Shipping builds → information leakage and cheat enablement; strip debug commands with `UE_BUILD_SHIPPING` guards.
14
+ - **[MEDIUM]** `UFUNCTION(Client, Reliable)` used to send sensitive data from server to a specific client without ownership check → data sent to wrong client; verify `GetOwner() == PC` before client RPCs.
15
+ - **[LOW]** Blueprint bytecode not protected in packaged build → decompilable with community tools; move security-critical logic to C++.
16
+
17
+ ---
18
+
19
+ ## Performance
20
+ - **[CRITICAL]** `AActor::Tick` enabled on actors that do not need per-frame updates → unnecessary CPU cost for every actor in the scene; set `PrimaryActorTick.bCanEverTick = false` in constructor for non-ticking actors.
21
+ - **[HIGH]** Garbage Collection hitches from large numbers of `UObject`-derived objects being allocated and released rapidly → GC pause spikes; pool objects and avoid frequent construction/destruction of UObjects.
22
+ - **[HIGH]** Static meshes without LOD levels in complex scenes → excessive polygon count at distance; set up LOD groups or use Nanite (UE5) for static geometry.
23
+ - **[HIGH]** Synchronous HTTP requests or blocking disk I/O executed on the game thread → frame stutter; use async task graph or UE's `FHttpModule` with async callbacks.
24
+ - **[HIGH]** Blueprint VM executing hot-path logic (AI, physics math, per-tick calculations) → Blueprint is 10-100x slower than native C++; move performance-critical code to C++ and expose via `BlueprintCallable`.
25
+ - **[MEDIUM]** Replication not gated by `NetUpdateFrequency` and `MinNetUpdateFrequency` → flooding the network with unnecessary updates; tune per-actor replication rates.
26
+ - **[MEDIUM]** Shader complexity not profiled with `viewmode shadercomplexity` → overdraw and expensive materials going undetected; budget material instruction counts.
27
+ - **[LOW]** Nanite not enabled for high-polygon static assets in UE5 → missed opportunity for virtualized geometry; enable Nanite on eligible meshes.
28
+
29
+ ---
30
+
31
+ ## Architecture
32
+ - **[HIGH]** Game logic implemented in Blueprints that would benefit from C++ for performance and testability → Blueprint-only codebases are hard to refactor and slow at runtime; use C++ base classes with Blueprint subclasses for data.
33
+ - **[HIGH]** Monolithic Actor classes handling movement, AI, UI, inventory, and audio → violates single responsibility; decompose into `UActorComponent` subclasses.
34
+ - **[MEDIUM]** Not following Unreal's GameMode / GameState / PlayerState / PlayerController / Pawn separation → game rules and per-player data mixed into Actor classes; respect the intended roles of each framework class.
35
+ - **[MEDIUM]** Hard references between assets (`UPROPERTY(EditAnywhere) UTexture2D*`) causing full asset load chains → large memory spikes; use `TSoftObjectPtr` and async loading for non-critical assets.
36
+ - **[MEDIUM]** Global services implemented as static methods or global variables instead of Unreal Subsystems → difficult to test and replace; use `UGameInstanceSubsystem`, `UWorldSubsystem`, or `UEngineSubsystem`.
37
+ - **[LOW]** Not using Unreal's Enhanced Input system (legacy `InputComponent` bindings deprecated in UE5) → missing rebinding and context-layered input support.
38
+
39
+ ---
40
+
41
+ ## Code Quality
42
+ - **[HIGH]** Raw C++ pointers to `UObject`-derived objects stored without `UPROPERTY()` → Unreal GC does not see the reference and may collect the object → dangling pointer crash; always mark UObject pointers with `UPROPERTY()` or use `TWeakObjectPtr`.
43
+ - **[HIGH]** `Cast<T>()` return value used without null check → returns `nullptr` on type mismatch; always null-check before dereferencing cast results.
44
+ - **[HIGH]** Not using `IsValid()` before accessing a `UObject` pointer → object may be pending kill; use `IsValid(Ptr)` instead of `Ptr != nullptr`.
45
+ - **[MEDIUM]** `FString` used for identifiers and map keys where `FName` is appropriate → FName is hashed and interned; use `FName` for asset names and identifiers, `FText` for display strings.
46
+ - **[MEDIUM]** `TArray` modified (elements added/removed) while iterating with range-for → iterator invalidation and undefined behaviour; iterate a copy or use index-based loops with care.
47
+ - **[LOW]** Unreal naming conventions not followed (prefix `A` for Actors, `U` for UObjects, `F` for structs, `I` for interfaces, `E` for enums) → reduces readability and breaks tooling assumptions.
48
+
49
+ ---
50
+
51
+ ## Common Bugs & Pitfalls
52
+ - **[CRITICAL]** `UObject` pointer not marked with `UPROPERTY()` → Garbage Collector silently frees the object → crash on next access; add `UPROPERTY()` to every UObject pointer member.
53
+ - **[HIGH]** Calling Blueprint-callable functions or virtual functions from a `UObject` constructor → object not fully initialized at construction time; defer initialization to `BeginPlay()` or `PostInitializeComponents()`.
54
+ - **[HIGH]** Server RPC called from client code without the `Server` UFUNCTION specifier → call silently dropped; always pair `Server` specifier with `_Implementation` and `_Validate` methods.
55
+ - **[HIGH]** `BeginPlay()` execution order across Actors not guaranteed → initialization dependencies between actors can fail silently; use deferred initialization or `PostBeginPlay` ordering.
56
+ - **[MEDIUM]** Delegates and dynamic multicast delegates not unbound in `EndPlay()` or `BeginDestroy()` → stale references firing after object destruction.
57
+ - **[MEDIUM]** Replication of a `TArray` relying on element-level delta → Unreal replicates the whole array on any change; use `FFastArraySerializer` for large replicated arrays.
58
+ - **[LOW]** Hot Reload breaking native class changes (added/removed member variables) → corrupted class layout; always do a full compile after structural class changes.
@@ -0,0 +1,48 @@
1
+ # Vite — Stack-Specific Review Rules
2
+
3
+ > Applies to: GR · SR · PR · AR · BR
4
+ > Detection signals: `vite.config.*`, `from 'vite'`, `import.meta.env`, `import.meta.hot`, `defineConfig` from vite
5
+
6
+ ---
7
+
8
+ ## Security
9
+ - **[CRITICAL]** Any variable prefixed with `VITE_` is automatically embedded in the client bundle → ALL such values are publicly visible. Never store API keys, secrets, or credentials in `VITE_` variables; use server-side env vars for secrets.
10
+ - **[CRITICAL]** `import.meta.env.VITE_API_KEY` used as an authentication secret → secret exposed to every browser visitor. Move secret usage to a backend proxy; expose only a public endpoint URL to the client.
11
+ - **[HIGH]** `define` plugin option replacing `process.env.SECRET` in the bundle → inlined plaintext secret shipped to clients. Remove secret values from `define`; use runtime server-side configuration instead.
12
+ - **[HIGH]** `server.fs.allow` set to `/` or overly broad path → dev server can serve any file on the system including `/etc/passwd`. Restrict `fs.allow` to the project root or specific necessary directories.
13
+ - **[MEDIUM]** No Content Security Policy configured for the production build → XSS attacks not mitigated by browser. Add CSP headers via the hosting layer or a Vite plugin (e.g. `vite-plugin-csp`).
14
+
15
+ ---
16
+
17
+ ## Performance
18
+ - **[HIGH]** `build.rollupOptions.output.manualChunks` not configured for large applications → single monolithic bundle with poor cache efficiency. Define `manualChunks` to separate vendor, framework, and feature code into cacheable chunks.
19
+ - **[HIGH]** Dynamic `import()` not used for route-level or feature-level code splitting → entire app JS loaded on first page visit. Wrap route components and large features in `import('...')` for lazy loading.
20
+ - **[HIGH]** Loading entire utility libraries (lodash, moment) without tree-shaking → dead code bloat. Import named exports from tree-shakeable equivalents (`lodash-es`, `date-fns`) or use specific subpath imports.
21
+ - **[MEDIUM]** `build.sourcemap: true` in production config → large `.map` files deployed alongside bundles. Set `sourcemap: false` or `sourcemap: 'hidden'` for production to avoid exposing source to users.
22
+ - **[MEDIUM]** No compression plugin configured → uncompressed JS/CSS served, missing 60-80% size reduction. Add `vite-plugin-compression` for gzip/brotli output or configure compression at the CDN/server layer.
23
+ - **[LOW]** `optimizeDeps.exclude` incorrectly listing packages that should be pre-bundled → slow dev server cold starts and waterfall module requests. Only exclude packages that are truly incompatible with pre-bundling (e.g. those using `require.resolve`).
24
+
25
+ ---
26
+
27
+ ## Architecture
28
+ - **[HIGH]** Plugins not ordered correctly in the `plugins` array → transform conflicts (e.g. TypeScript plugin must run before framework plugin). Review each plugin's documented order requirement; check plugin `enforce: 'pre'/'post'` settings.
29
+ - **[HIGH]** `resolve.alias` overriding paths inside `node_modules` → breaks the package's own internal imports and causes hard-to-debug resolution errors. Only alias your own source paths (e.g. `@/` → `src/`); never alias into `node_modules`.
30
+ - **[MEDIUM]** Single `vite.config.ts` handling all environments without using the `mode` parameter → environment-specific config mixed together, risk of dev-only settings leaking to production. Use `mode` to conditionally apply plugins: `if (mode === 'production') { ... }`.
31
+ - **[MEDIUM]** Dev-only plugins (e.g. mock server, inspector) not guarded with `apply: 'serve'` → dev tooling included in production build. Add `apply: 'serve'` to all development-only plugins.
32
+
33
+ ---
34
+
35
+ ## Code Quality
36
+ - **[MEDIUM]** Missing `/// <reference types="vite/client" />` in `vite-env.d.ts` → `import.meta.env`, `import.meta.hot`, and asset imports are untyped. Add the triple-slash reference to enable Vite's built-in type definitions.
37
+ - **[MEDIUM]** `import.meta.glob()` used without explicit typing → returned module map is `Record<string, unknown>`. Type the glob call: `import.meta.glob<{ default: Component }>('./routes/*.tsx')`.
38
+ - **[MEDIUM]** HMR custom handlers (`import.meta.hot.accept(...)`) written without checking `import.meta.hot` guard → fails in production build where HMR is stripped. Always guard: `if (import.meta.hot) { import.meta.hot.accept(...) }`.
39
+ - **[LOW]** `defineConfig` used without TypeScript, relying on plain JS config without type checking → mistyped config options silently ignored. Rename config to `vite.config.ts` and use TypeScript for type-checked configuration.
40
+
41
+ ---
42
+
43
+ ## Common Bugs & Pitfalls
44
+ - **[HIGH]** `process.env.VAR` used in client code (React/Vue habit from CRA/webpack) → `process` is undefined in Vite's browser environment; build fails or returns `undefined`. Replace all client-side `process.env` references with `import.meta.env.VITE_VAR`.
45
+ - **[HIGH]** SSR build missing `resolve.conditions: ['node']` or `ssr: true` in build options → wrong package entry points resolved, browser bundles used on server. Configure separate SSR build with `build.ssr` and proper resolve conditions.
46
+ - **[MEDIUM]** Relative imports breaking after changing the `base` config option → asset URLs and router base paths misalign. Audit all hardcoded `/` paths and use `import.meta.env.BASE_URL` for dynamic base-relative URLs.
47
+ - **[MEDIUM]** CSS Modules class name collisions because `generateScopedName` not configured → two modules produce the same hashed class. Configure `css.modules.generateScopedName` with a pattern that includes the filename for uniqueness.
48
+ - **[MEDIUM]** Files in `publicDir` served without content hash in filename → CDN or browser caches stale version after update. Files in `publicDir` are never hashed by Vite; use `src/assets/` with `import` for hash-fingerprinted assets.
@@ -0,0 +1,95 @@
1
+ # Vue 3 — Stack-Specific Review Rules
2
+
3
+ > Applies to: GR · SR · PR · AR · BR
4
+ > Detection signals: `*.vue` files, `from 'vue'`, `<script setup>`, `defineComponent`, `vite.config.*` with vue plugin, `pinia` or `vuex` in deps, `defineProps`, `defineEmits`
5
+
6
+ ---
7
+
8
+ ## Security
9
+
10
+ - **[CRITICAL]** `v-html` with user-controlled data → stored/reflected XSS. Use `{{ }}` text interpolation. If HTML required, sanitize with DOMPurify first.
11
+ - **[CRITICAL]** Dynamic `:is` binding with user-controlled string → arbitrary component injection. Only allow from known safe component map.
12
+ - **[CRITICAL]** Server-side template injection in SSR (Nuxt) via user-controlled template strings.
13
+ - **[HIGH]** `href` bound to user input without URL validation → `javascript:` protocol injection. Validate protocol allowlist.
14
+ - **[HIGH]** Missing `@submit.prevent` on forms calling APIs → unintended page reloads bypassing client validation.
15
+ - **[HIGH]** `eval()` / `new Function()` in component logic with user input → code injection.
16
+ - **[HIGH]** Pinia store persisted to localStorage via `pinia-plugin-persistedstate` with sensitive data → plaintext exposure.
17
+ - **[MEDIUM]** Sensitive store state (tokens, passwords) exposed in template → visible in Vue DevTools. Keep server-side.
18
+ - **[MEDIUM]** Missing CSRF protection with cookie-based auth on mutations.
19
+ - **[MEDIUM]** `useRoute().query` used without sanitization in templates.
20
+ - **[LOW]** Vue DevTools enabled in production build → state and component tree exposed.
21
+
22
+ ---
23
+
24
+ ## Performance
25
+
26
+ - **[HIGH]** `watchEffect` / `watch` starting async without `onCleanup` → memory leak and race condition on unmount mid-flight.
27
+ - **[HIGH]** `v-for` on large lists without virtual scrolling (vue-virtual-scroller) → DOM overload at 500+ items.
28
+ - **[HIGH]** `computed` depending on entire store object (`todoStore`) instead of specific fields → re-runs on any store change.
29
+ - **[HIGH]** `watch` with `deep: true` on large nested objects → expensive deep traversal every change; use targeted watchers.
30
+ - **[HIGH]** Component not using `v-once` for truly static content → re-evaluates on every render.
31
+ - **[HIGH]** `reactive()` used for large arrays with frequent push → Vue 3 tracks every index.
32
+ - **[MEDIUM]** `v-for` using array index as `:key` → broken reconciliation on reorder/delete; use stable unique IDs.
33
+ - **[MEDIUM]** Missing `:key` on `v-for` entirely → Vue warns, falls back to index behavior.
34
+ - **[MEDIUM]** Heavy computation directly in template expressions → runs on every render; move to `computed`.
35
+ - **[MEDIUM]** `shallowRef` not used for large read-only data blobs → Vue tracks deep reactivity unnecessarily.
36
+ - **[MEDIUM]** `onMounted` doing expensive synchronous work → UI freeze on first render; use async with loading state.
37
+ - **[MEDIUM]** `defineAsyncComponent` not used for heavy components → included in initial bundle.
38
+ - **[MEDIUM]** `v-show` vs `v-if` misuse: `v-if` on frequently toggled elements → DOM destroy/recreate overhead.
39
+ - **[LOW]** `provide`/`inject` at root for frequently changing values → all descendants potentially affected.
40
+ - **[LOW]** Unnecessarily large `watch` source (full array) when only length matters.
41
+
42
+ ---
43
+
44
+ ## Architecture
45
+
46
+ - **[HIGH]** Direct store state mutation outside action: `store.items.push(...)` → bypasses Pinia devtools and action tracking.
47
+ - **[HIGH]** `useStore()` called outside `setup()` (module scope, plain function) → loses reactivity context.
48
+ - **[HIGH]** Props mutation inside child component (`props.value = x`) → violates one-way data flow, Vue warning.
49
+ - **[HIGH]** `defineExpose()` leaking internal reactive refs to parent without intent → tight coupling.
50
+ - **[HIGH]** Business logic (API calls, transformation) in template or event handlers → move to store actions or composables.
51
+ - **[HIGH]** Pinia store importing another store's internals directly → cross-store coupling; use store actions.
52
+ - **[HIGH]** Composable modifying global state without clearly documented side effects.
53
+ - **[MEDIUM]** Monolithic component >400 lines → decompose into container + presentational.
54
+ - **[MEDIUM]** `provide/inject` without TypeScript injection keys → no type safety, silent undefined at runtime.
55
+ - **[MEDIUM]** Async component loading without `<Suspense>` boundary → unhandled loading/error states.
56
+ - **[MEDIUM]** Composable not returning reactive refs → consumers lose reactivity after destructuring.
57
+ - **[MEDIUM]** Router navigation guard doing data fetching → use `onBeforeRouteUpdate` inside component or store action.
58
+ - **[LOW]** Missing `defineOptions({ name: 'ComponentName' })` → harder debugging in Vue DevTools.
59
+ - **[LOW]** Global event bus (`mitt`) used for parent-child communication → use props/emits; bus for truly global events only.
60
+
61
+ ---
62
+
63
+ ## Code Quality
64
+
65
+ - **[HIGH]** `defineProps` without TypeScript types or runtime validators → silent prop misuse.
66
+ - **[HIGH]** Missing `defineEmits` declaration → uncaught typo event names, no IDE support.
67
+ - **[HIGH]** `defineProps` with required prop not having default and not checked → undefined access crash.
68
+ - **[MEDIUM]** Mixing Options API with Composition API in same component → confusing, lint may miss issues.
69
+ - **[MEDIUM]** `ref()` vs `reactive()` inconsistency across codebase → pick one convention and document.
70
+ - **[MEDIUM]** `<script setup>` importing unused components → increases bundle size.
71
+ - **[MEDIUM]** `v-model` without explicit `:modelValue` / `@update:modelValue` contract on custom component.
72
+ - **[MEDIUM]** Template ref (`ref="el"`) typed as `any` in TypeScript → defeats type safety.
73
+ - **[MEDIUM]** Async composable not handling error state → calling component has no error boundary.
74
+ - **[LOW]** Single-word component name (`<Header>`) → conflicts with native HTML elements.
75
+ - **[LOW]** Missing default value for optional props → runtime undefined access.
76
+ - **[LOW]** `defineProps` `withDefaults` not used when defaults needed → verbose manual checking.
77
+
78
+ ---
79
+
80
+ ## Common Bugs & Pitfalls
81
+
82
+ - **[HIGH]** `async setup()` rendering before data resolves without `<Suspense>` → UI flash with undefined data.
83
+ - **[HIGH]** `reactive()` object destructured into local variables → reactivity lost silently (`const { name } = reactive(obj)`).
84
+ - **[HIGH]** `toRef` / `toRefs` not used when extracting from `reactive` → stale values after store changes.
85
+ - **[HIGH]** `watch` source is a reactive object property accessed directly → watch not triggered (`watch(obj.prop, ...)` vs `watch(() => obj.prop, ...)`).
86
+ - **[HIGH]** Pinia action not awaited → dependent UI renders before state updated.
87
+ - **[HIGH]** `onUnmounted` cleanup not added for `setInterval`/`setTimeout` → leak on route change.
88
+ - **[HIGH]** `watchEffect` running before DOM is ready → access to template refs returns null.
89
+ - **[MEDIUM]** `watch` missing `immediate: true` when logic should run on mount.
90
+ - **[MEDIUM]** `computed` with setter missing → silently fails on two-way binding.
91
+ - **[MEDIUM]** `nextTick` not awaited before DOM-dependent logic after state change → stale DOM.
92
+ - **[MEDIUM]** `v-for` over Pinia store array → `v-for` on reactive proxy — mutations outside actions break reactivity.
93
+ - **[MEDIUM]** `<Teleport>` target not existing in DOM when component mounts → silent fail.
94
+ - **[LOW]** `onActivated`/`onDeactivated` hooks not used with `<KeepAlive>` → side effects not managed on cache toggle.
95
+ - **[LOW]** `$attrs` fallthrough not disabled when manually forwarding → double attribute application.
@@ -0,0 +1,53 @@
1
+ # Vulkan — Stack-Specific Review Rules
2
+
3
+ > Applies to: GR · SR · PR · AR · BR
4
+ > Detection signals: `vulkan`, `vk::`, `VkInstance`, `VkDevice`, `vkCreateInstance`, `vulkan.h`, `VK_`, SPIR-V, `*.spv`
5
+
6
+ ---
7
+
8
+ ## Security
9
+ - **[HIGH]** Validation layers disabled in debug builds to "improve performance" → API misuse, undefined behavior, and driver crashes go undetected during development; always enable `VK_LAYER_KHRONOS_validation` in debug and CI builds.
10
+ - **[HIGH]** Persistently mapped buffer memory (`vkMapMemory`) written by the CPU while simultaneously read by the GPU without synchronization → data corruption and undefined behavior; use proper pipeline barriers or semaphores to ensure CPU-GPU ordering before unmapping or flushing.
11
+ - **[MEDIUM]** SPIR-V shader binaries loaded from user-controlled file paths without validation → malformed SPIR-V can crash drivers or trigger undefined behavior; validate with `spirv-val` at build time and load only from bundled, pre-validated binaries.
12
+ - **[LOW]** Debug messenger (`VK_EXT_debug_utils`) not set up during development → Vulkan API misuse produces no diagnostic output; always install a debug messenger callback that logs all validation messages in non-shipping builds.
13
+
14
+ ---
15
+
16
+ ## Performance
17
+ - **[CRITICAL]** One `vkQueueSubmit` call issued per draw call → extreme CPU overhead from queue submission synchronization; record all draw commands into a single command buffer and submit once per frame.
18
+ - **[CRITICAL]** `VkFence` and `VkSemaphore` synchronization used incorrectly (e.g., waiting on a fence that was never signaled, signaling a semaphore that is never waited on) → GPU hangs, CPU deadlock, or undefined frame ordering; follow the canonical acquire-render-present synchronization pattern with per-frame fences and semaphores.
19
+ - **[HIGH]** Pipeline barriers specified with `VK_PIPELINE_STAGE_ALL_COMMANDS_BIT` as source or destination stage → unnecessarily broad barrier stalls the entire GPU pipeline; narrow to the precise pipeline stages that produce and consume the resource.
20
+ - **[HIGH]** Device memory allocated individually per resource with `vkAllocateMemory()` → drivers have a hard limit on allocation count (often 4096); use a GPU memory allocator library (VMA — Vulkan Memory Allocator) to suballocate from large blocks.
21
+ - **[HIGH]** Tile-based GPU architecture (mobile) not using render pass subpasses for on-chip framebuffer operations → intermediate render targets written to and read back from main memory; use `vkCmdNextSubpass` with input attachments to keep data on-chip.
22
+ - **[MEDIUM]** Descriptor sets allocated individually per frame per object → descriptor pool fragmentation and allocation overhead; pre-allocate descriptor sets for the maximum number of objects and rotate through them per frame.
23
+ - **[MEDIUM]** Command buffers re-recorded every frame for static scene geometry → unnecessary CPU work; pre-record static geometry command buffers once and only re-record when scene state changes.
24
+ - **[LOW]** Small per-draw-call data (model matrix, material index) passed via descriptor sets instead of push constants → unnecessary descriptor set update overhead; use `vkCmdPushConstants` for data up to 128 bytes that changes per draw call.
25
+
26
+ ---
27
+
28
+ ## Architecture
29
+ - **[HIGH]** Vulkan objects (Instance, Device, Swapchain, RenderPass) created without a clear ownership and lifecycle policy → objects destroyed in wrong order or leaked; establish a deterministic teardown order that is the reverse of creation order.
30
+ - **[HIGH]** Validation layers treated as optional rather than mandatory for development → bugs caught only by production GPU crashes on customer hardware; treat validation layer warnings as build-breaking errors in CI.
31
+ - **[MEDIUM]** Swapchain recreation on window resize not implemented → resize causes `VK_ERROR_OUT_OF_DATE_KHR` return from `vkQueuePresentKHR`, which crashes the application; handle `VK_ERROR_OUT_OF_DATE_KHR` and `VK_SUBOPTIMAL_KHR` by recreating the swapchain.
32
+ - **[MEDIUM]** Raw Vulkan API calls not abstracted behind a renderer interface → every backend detail exposed to application code; wrap in a renderer class that exposes high-level operations (beginFrame, drawMesh, endFrame).
33
+ - **[LOW]** Queue family indices hardcoded as `0` instead of queried from `vkGetPhysicalDeviceQueueFamilyProperties()` → code breaks on GPUs where graphics and present queues are different families; always query and select queue families by capability.
34
+
35
+ ---
36
+
37
+ ## Code Quality
38
+ - **[CRITICAL]** Return values of Vulkan API calls not checked against `VK_SUCCESS` → failures produce invalid handles that cause crashes or corruption far from the error site; check every Vulkan return code and handle or propagate errors immediately.
39
+ - **[HIGH]** `srcAccessMask` / `dstAccessMask` or `srcStageMask` / `dstStageMask` in `VkImageMemoryBarrier` / `VkBufferMemoryBarrier` set incorrectly → memory hazards where GPU reads stale data or races with writes; consult the Vulkan synchronization table and set exact access and stage masks.
40
+ - **[HIGH]** `VK_NULL_HANDLE` not checked after object creation → using a null handle crashes the driver; verify every created handle is non-null before storing or using it.
41
+ - **[MEDIUM]** SPIR-V shader binaries not validated with `spirv-val` before inclusion in the build → invalid SPIR-V silently rejected by some drivers, crashes others; add `spirv-val` as a build step for all shader binaries.
42
+ - **[MEDIUM]** Frame-in-flight count not matched between swapchain image count and synchronization primitive arrays → out-of-bounds access into fence/semaphore arrays; derive all per-frame array sizes from the swapchain image count.
43
+ - **[LOW]** Viewport and scissor not set as dynamic state before draw calls when `VK_DYNAMIC_STATE_VIEWPORT` / `VK_DYNAMIC_STATE_SCISSOR` is used in the pipeline → validation error and undefined draw behavior; always call `vkCmdSetViewport` and `vkCmdSetScissor` before every draw that uses dynamic state.
44
+
45
+ ---
46
+
47
+ ## Common Bugs & Pitfalls
48
+ - **[CRITICAL]** Vulkan object used after the corresponding `vkDestroy*` or `vkFree*` call → use-after-free crash, often deferred until the next GPU submission; enforce strict RAII ownership so destruction is automatic and sequenced correctly.
49
+ - **[HIGH]** Image layout transition not performed before using an image in a render pass or shader → validation error and undefined sampling or attachment behavior; always transition image layout with a barrier to the correct `VkImageLayout` before first use.
50
+ - **[HIGH]** Framebuffer created referencing swapchain image views that are then recreated on resize without recreating the framebuffer → framebuffer holds stale image view handles → crash on next render; recreate framebuffers whenever the swapchain is recreated.
51
+ - **[MEDIUM]** Semaphore signaled by `vkQueueSubmit` but never waited on by a subsequent submit or present → Vulkan requires every signal operation to have a matching wait; track all semaphore signal/wait pairs to ensure they are balanced.
52
+ - **[MEDIUM]** Depth/stencil image layout not transitioned from `VK_IMAGE_LAYOUT_UNDEFINED` before first render pass use → contents undefined, depth test produces garbage results; include an initial layout transition in the render pass `VkAttachmentDescription.initialLayout` or a preceding barrier.
53
+ - **[LOW]** `vkDeviceWaitIdle()` called every frame to avoid synchronization complexity → serializes CPU and GPU completely, destroying all parallelism; use per-frame fences with `vkWaitForFences` for proper double/triple buffering.
@@ -0,0 +1,49 @@
1
+ # WebAssembly (WASM) — Stack-Specific Review Rules
2
+
3
+ > Applies to: GR · SR · PR · AR · BR
4
+ > Detection signals: `*.wasm`, `*.wat`, `WebAssembly`, `wasm-pack`, `wasm-bindgen`, `emscripten`, `#[wasm_bindgen]`, `wasm32-unknown-unknown`
5
+
6
+ ---
7
+
8
+ ## Security
9
+ - **[HIGH]** User-supplied WASM modules executed without sandboxing → sandbox escape via WASI filesystem or network capabilities. Validate modules with `WebAssembly.validate()` and restrict WASI capabilities to the minimum required set.
10
+ - **[HIGH]** WASM linear memory directly accessible from JavaScript → JS can read and write all WASM heap memory including sensitive data. Keep secrets in WASM-side memory only when necessary, zero them after use, and never expose the raw `memory` export to untrusted JS.
11
+ - **[HIGH]** WASM module loaded from untrusted CDN without a Subresource Integrity hash → module swapped for malicious payload. Add `integrity="sha384-..."` to all `<script>` tags and `fetch` calls that load WASM.
12
+ - **[HIGH]** Secrets hardcoded in WASM binary → extractable via `wasm-decompile` or `wasm2wat`. Store secrets server-side and pass them as runtime parameters; never embed them in the binary.
13
+ - **[MEDIUM]** Cross-origin WASM loading without CORP/COEP headers when using `SharedArrayBuffer` → `SharedArrayBuffer` unavailable or cross-origin data leaks. Set `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp` on all pages using shared memory.
14
+ - **[MEDIUM]** WASM module not validated with `WebAssembly.validate()` before instantiation → malformed module causes unhandled exception. Always validate untrusted WASM bytes before calling `WebAssembly.instantiate()`.
15
+
16
+ ---
17
+
18
+ ## Performance
19
+ - **[HIGH]** Large WASM binaries served without gzip or brotli compression → slow initial load on every visit. Enable brotli compression at the CDN/server level; a 1 MB WASM binary typically compresses to ~250 KB.
20
+ - **[HIGH]** JS–WASM boundary crossed too frequently in tight loops → per-call overhead accumulates to measurable latency. Batch work on the WASM side and exchange results in bulk; prefer passing typed arrays over individual calls.
21
+ - **[HIGH]** WASM binary not compiled with optimization (`-O3` / `wasm-opt -O3`) → 2–5× larger and slower than optimized output. Always run `wasm-opt -O3` as a post-build step and set `-C opt-level=3` in Rust/Zig builds.
22
+ - **[HIGH]** Not using `SharedArrayBuffer` and Web Workers for parallel WASM execution → single-threaded throughput ceiling. Use `wasm-bindgen-rayon` or manual worker pools for data-parallel workloads.
23
+ - **[MEDIUM]** WASM memory not pre-allocated → frequent `memory.grow` operations stall execution. Use `--initial-memory` / `INITIAL_MEMORY` flags to pre-allocate expected working set at startup.
24
+ - **[MEDIUM]** WASM instantiation performed on the main thread → blocks UI during parsing and compilation. Instantiate asynchronously via `WebAssembly.instantiateStreaming()` in a Worker and `postMessage` the exports back.
25
+
26
+ ---
27
+
28
+ ## Architecture
29
+ - **[HIGH]** Many small WASM→JS calls instead of batching work on the WASM side → call overhead dominates execution time. Design APIs that transfer bulk data (typed arrays, shared memory regions) rather than scalar values per call.
30
+ - **[HIGH]** WASM used for operations where JavaScript already performs adequately → added complexity without throughput gain. Reserve WASM for CPU-bound algorithms, codecs, parsers, and cryptography; profile before migrating.
31
+ - **[MEDIUM]** WASM module not cached via Service Worker → full re-download on every cold load. Cache the `.wasm` file with a content-hashed URL and serve from cache on repeat visits.
32
+ - **[LOW]** WASM binary not code-split → entire module loaded even when only a subset is needed. Use dynamic `import()` or lazy `WebAssembly.instantiateStreaming()` to defer loading of optional functionality.
33
+
34
+ ---
35
+
36
+ ## Code Quality
37
+ - **[HIGH]** Manual `malloc`/`free` in C/Emscripten WASM not tracked → heap corruption or leaks invisible to browser dev tools. Use ASAN (`-fsanitize=address`) during development and run `valgrind`-equivalent checks in CI.
38
+ - **[MEDIUM]** `wasm-bindgen` types not properly annotated with `#[wasm_bindgen]` → JS type coercion produces unexpected `undefined` or wrong values. Annotate all public FFI types and verify with `wasm-pack test --headless`.
39
+ - **[MEDIUM]** Not using `wasm-pack test` for browser-side WASM tests → logic tested only in native mode, missing WASM-specific bugs. Run `wasm-pack test --headless --chrome` in CI to catch binding and memory issues.
40
+ - **[LOW]** WASM binary not stripped of debug symbols for production → binary 3–10× larger than necessary. Use `wasm-strip` or `wasm-opt --strip-debug` in the production build pipeline.
41
+
42
+ ---
43
+
44
+ ## Common Bugs & Pitfalls
45
+ - **[HIGH]** Stack overflow in WASM (default 1 MB stack) → cryptic `unreachable` trap with no useful stack trace. Increase the stack via `-z stack-size` for recursive algorithms or rewrite as iterative with an explicit stack.
46
+ - **[HIGH]** `i64` values passed between WASM and JavaScript → JS `Number` can only represent 53-bit integers exactly, silently truncating larger values. Use `BigInt` on the JS side and `wasm-bindgen`'s `#[wasm_bindgen]` `i64` support.
47
+ - **[MEDIUM]** Pointer passed to JS becomes invalid after `memory.grow` detaches the underlying `ArrayBuffer` → stale typed array views cause silent reads of zeroed memory. Re-create JS views of WASM memory after every `memory.grow` operation.
48
+ - **[MEDIUM]** WASM function table not large enough for indirect function pointer calls → trap at runtime during `call_indirect`. Set `--table-base` / initial table size to cover all function pointer targets.
49
+ - **[LOW]** `WebAssembly.instantiateStreaming()` `await`ed incorrectly → race conditions accessing exports before the module is ready. Always `await` the full `instantiateStreaming()` promise before accessing `instance.exports`.
@@ -0,0 +1,48 @@
1
+ # Webpack — Stack-Specific Review Rules
2
+
3
+ > Applies to: GR · SR · PR · AR · BR
4
+ > Detection signals: `webpack.config.*`, `from 'webpack'`, `module.exports` with `entry`/`output`, `loader:`, `HtmlWebpackPlugin`
5
+
6
+ ---
7
+
8
+ ## Security
9
+ - **[CRITICAL]** `devtool: 'eval'` or `devtool: 'eval-source-map'` used in production build → full source code exposed via `eval()` strings in the bundle. Set `devtool: false` or `devtool: 'source-map'` for production; use `eval` only in development.
10
+ - **[CRITICAL]** `require()` called with user-controlled path input → path traversal allowing arbitrary file reads from the server filesystem. Never pass user input to `require()`; use a whitelist map for dynamic module loading.
11
+ - **[HIGH]** Secrets inlined via `DefinePlugin` with `process.env.SECRET` → secrets embedded as plaintext in the client bundle. Only inline non-sensitive build-time constants; load secrets at runtime from a server endpoint.
12
+ - **[HIGH]** `externals` loading libraries from a CDN without Subresource Integrity (SRI) hashes → CDN compromise injects malicious code. Add SRI `integrity` and `crossorigin` attributes to all CDN `<script>` tags.
13
+ - **[MEDIUM]** `devServer.proxy` forwarding requests without stripping or validating auth headers → credentials forwarded to unintended upstream services. Configure proxy to only forward necessary headers; validate target URLs.
14
+
15
+ ---
16
+
17
+ ## Performance
18
+ - **[HIGH]** `optimization.splitChunks` not configured → everything bundled into a single file, no cache reuse across deploys. Configure `splitChunks: { chunks: 'all' }` and define `cacheGroups` for vendor separation.
19
+ - **[HIGH]** `TerserPlugin` not used in production (`mode: 'production'` does this automatically, but custom configs may omit it) → unminified output, 3-5x larger bundle. Ensure `optimization.minimize: true` with `TerserPlugin` in all production configs.
20
+ - **[HIGH]** Tree-shaking disabled because packages not marked `sideEffects: false` in `package.json` → dead code included in bundle. Mark your app's `package.json` with `"sideEffects": false` and use ES module imports.
21
+ - **[HIGH]** Entire lodash imported (`import _ from 'lodash'`) instead of tree-shakeable `lodash-es` or per-method imports → ~70KB dead weight. Replace with `import { debounce } from 'lodash-es'` or `import debounce from 'lodash/debounce'`.
22
+ - **[MEDIUM]** `babel-loader` without `cacheDirectory: true` → Babel re-transpiles every file on every rebuild. Add `options: { cacheDirectory: true }` to `babel-loader` to persist transpile cache between builds.
23
+
24
+ ---
25
+
26
+ ## Architecture
27
+ - **[HIGH]** Single monolithic `webpack.config.js` mixing development and production configuration → dev-only settings risk leaking to production. Split into `webpack.common.js`, `webpack.dev.js`, `webpack.prod.js` and merge with `webpack-merge`.
28
+ - **[HIGH]** Circular dependencies between modules not detected → subtle initialization order bugs and failed tree-shaking. Add `circular-dependency-plugin` to the build and fix or document any true circular dependencies.
29
+ - **[HIGH]** Hardcoded absolute or relative paths instead of `path.resolve(__dirname, '...')` → config breaks when run from a different working directory. Use `path.resolve(__dirname, 'src')` for all path resolution in config.
30
+ - **[MEDIUM]** Loaders and plugins not organized with comments or grouping by concern → config becomes unreadable as it grows. Group by: asset loaders, style loaders, script loaders, optimization plugins, with section comments.
31
+ - **[LOW]** Webpack config not committed to version control or `.gitignore`d → team members use different build settings. Commit all config variants; use environment variables only for secrets.
32
+
33
+ ---
34
+
35
+ ## Code Quality
36
+ - **[MEDIUM]** Deprecated `require.ensure` used for code splitting instead of dynamic `import()` → `require.ensure` is legacy, not supported in ESM or modern bundlers. Replace with `import('path/to/module').then(...)` for dynamic splitting.
37
+ - **[MEDIUM]** Inline loader syntax (`require('style-loader!css-loader!./style.css')`) in source files → couples application code to build tooling. Configure all loaders exclusively in `module.rules`; never use inline loader strings in source.
38
+ - **[MEDIUM]** `module.rules` with overly broad `test` regex matching unintended file types → files processed by wrong loader silently. Make `test` patterns precise and add `include`/`exclude` to constrain loader scope.
39
+ - **[LOW]** Config lacks comments explaining non-obvious plugin options or loader combinations → next developer cannot understand intent. Add inline comments for any non-default configuration decision.
40
+
41
+ ---
42
+
43
+ ## Common Bugs & Pitfalls
44
+ - **[HIGH]** `output.publicPath` misconfigured or missing → asset URLs in the HTML resolve to wrong paths, causing 404s for JS/CSS/images. Set `output.publicPath` to the CDN base URL in production or `'/'` for root-relative serving.
45
+ - **[HIGH]** `HotModuleReplacementPlugin` included in the production build (common when config is not split) → HMR runtime added to production bundle, unnecessary code and overhead. Guard `HotModuleReplacementPlugin` with `if (isDev)` or remove from shared/production config.
46
+ - **[HIGH]** Loader order reversed in `module.rules` `use` array (webpack processes right-to-left) → CSS not processed correctly, e.g. `css-loader` running before `sass-loader`. Order loaders right-to-left: `['style-loader', 'css-loader', 'sass-loader']`.
47
+ - **[MEDIUM]** `resolve.extensions` missing file extensions commonly used in the project → imports without extensions fail or resolve to wrong file. List all used extensions: `resolve: { extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'] }`.
48
+ - **[MEDIUM]** CSS ordering non-deterministic when `mini-css-extract-plugin` extracts styles from multiple async chunks → visual inconsistencies across deploys. Set `optimization.moduleIds: 'deterministic'` and review CSS import order for consistency.
@@ -0,0 +1,51 @@
1
+ # Zig — Stack-Specific Review Rules
2
+
3
+ > Applies to: GR · SR · PR · AR · BR
4
+ > Detection signals: `*.zig`, `const std = @import("std")`, `pub fn main()`, `@allocator`, `comptime`, `zig build`, `build.zig`
5
+
6
+ ---
7
+
8
+ ## Security
9
+ - **[CRITICAL]** `@ptrCast` without bounds validation → memory safety violation that bypasses Zig's safety checks. Always validate pointer alignment and bounds before casting; prefer safe alternatives like `std.mem.bytesAsValue`.
10
+ - **[HIGH]** `undefined` values used without initialization before first read → undefined behavior in ReleaseFast; reads garbage data in Debug. Initialize all values explicitly or use `std.mem.zeroes()`.
11
+ - **[HIGH]** Allocator errors not handled → unhandled `error.OutOfMemory` causes a panic or silent data corruption. Always propagate or handle allocator errors with `try` or explicit `catch`.
12
+ - **[HIGH]** C interop via `@cImport` with unsafe C APIs without bounds checking → buffer overflows from C side invisible to Zig's safety. Wrap all C calls in a safe Zig layer that validates sizes and return values.
13
+ - **[MEDIUM]** Integer overflow not using `@addWithOverflow` or checked math → wraps silently in ReleaseFast, panics in Debug. Use `std.math.add` or `@addWithOverflow` for arithmetic on external data.
14
+ - **[MEDIUM]** Unsafe type punning via `@bitCast` on incompatible types → undefined behavior when alignment or size mismatches. Use `std.mem.bytesAsValue` with explicit alignment checks.
15
+
16
+ ---
17
+
18
+ ## Performance
19
+ - **[HIGH]** Allocator calls inside hot loops instead of fixed buffers or arena allocators → per-iteration syscall overhead and fragmentation. Use a stack buffer (`var buf: [N]u8 = undefined`) or `std.heap.ArenaAllocator` for loop-scoped allocations.
20
+ - **[HIGH]** Comptime-known computations not evaluated at `comptime` → runtime overhead for constants. Annotate with `comptime` to move computation to compile time.
21
+ - **[HIGH]** Heap allocation where stack allocation suffices → unnecessary allocator pressure and pointer indirection. Prefer local arrays and slices; reserve heap for runtime-sized or long-lived data.
22
+ - **[MEDIUM]** Not using `@Vector` for data-parallel operations on numeric arrays → leaving SIMD throughput unused. Use `@Vector(N, T)` and let the backend auto-vectorize.
23
+ - **[MEDIUM]** Untagged union field accessed for the wrong active tag → misinterpretation of bit patterns with no runtime check. Use tagged unions (`union(enum)`) and switch exhaustively on the tag.
24
+ - **[LOW]** Build mode not set to `ReleaseFast` or `ReleaseSafe` for production → unnecessary safety overhead or missed optimizations. Set `optimize` in `build.zig` explicitly and document the choice.
25
+
26
+ ---
27
+
28
+ ## Architecture
29
+ - **[HIGH]** Error handling not using Zig's error union (`!T`) pattern consistently → callers must guess whether a function can fail. Return `!T` for all fallible functions and propagate with `try`.
30
+ - **[HIGH]** `defer` not used for resource cleanup → resources leaked on early returns or errors. Add `defer resource.deinit()` immediately after successful acquisition.
31
+ - **[MEDIUM]** Custom allocators not used for subsystem memory isolation → one subsystem's leak affects global heap. Pass allocators explicitly and use arena or fixed-buffer allocators to scope lifetimes.
32
+ - **[MEDIUM]** `comptime` overused for logic that varies at runtime → code harder to follow and debug. Reserve `comptime` for type-level generics and compile-time constants; document non-obvious uses.
33
+ - **[LOW]** Not using Zig's build system (`build.zig`) for cross-platform builds → relying on shell scripts that break on Windows or non-standard targets. Express all build steps in `build.zig`.
34
+
35
+ ---
36
+
37
+ ## Code Quality
38
+ - **[HIGH]** `unreachable` in code paths that can actually be reached → illegal behavior in ReleaseFast, panic in Debug. Replace with an explicit `else` branch that returns an error or asserts loudly in tests.
39
+ - **[HIGH]** Ignoring error union by discarding with `_ = try expr` without handling → silent swallowing of errors. Explicitly handle or log the error; use `catch |err| std.log.err(...)` pattern.
40
+ - **[MEDIUM]** Slice bounds not checked before indexing → potential panic or out-of-bounds access. Assert `index < slice.len` or use `slice[index..]` range checks explicitly.
41
+ - **[MEDIUM]** Not using `std.testing` module for unit tests → missing coverage and no integration with `zig test`. Write tests in `test` blocks and run them with `zig build test`.
42
+ - **[LOW]** Not following Zig naming conventions → camelCase for functions/variables, PascalCase for types, SCREAMING_SNAKE for comptime constants. Inconsistency impedes readability; enforce via code review.
43
+
44
+ ---
45
+
46
+ ## Common Bugs & Pitfalls
47
+ - **[HIGH]** Pointer to stack-allocated memory returned from a function → dangling pointer after frame unwinds. Never return pointers to local variables; heap-allocate or pass a caller-owned buffer.
48
+ - **[HIGH]** Slice created from pointer with incorrect length → buffer over-read or under-read. Always derive length from the same source as the pointer; prefer passing slices (`[]T`) over raw pointers.
49
+ - **[MEDIUM]** Optional (`?T`) unwrapped with `.?` without prior null check → panic in safe modes, undefined in unsafe. Use `if (opt) |val|` or `orelse` to handle the null case explicitly.
50
+ - **[MEDIUM]** Integer type mismatch in arithmetic → unexpected truncation or sign extension. Use explicit casts (`@intCast`, `@truncate`) with documented intent rather than implicit coercion.
51
+ - **[LOW]** `@field(obj, comptime_str)` with a string not validated at comptime → compile error surfaced at the call site with a confusing message. Validate field names with `std.meta.fields` and provide a clear comptime error.
@@ -0,0 +1,56 @@
1
+ # Zustand — Stack-Specific Review Rules
2
+
3
+ > Applies to: GR · SR · PR · AR · BR
4
+ > Detection signals: `from 'zustand'`, `create()`, `useStore`, `persist` middleware, `immer` middleware, `zustand/middleware`
5
+
6
+ ---
7
+
8
+ ## Security
9
+ - **[CRITICAL]** Persisting sensitive data (tokens, passwords) to localStorage via `persist` middleware without encryption → credentials readable by any script on the page. Encrypt before persisting or store in httpOnly cookies.
10
+ - **[HIGH]** Store reference exported and accessed globally outside React context → no access control, any module can read or mutate state. Expose only hooks, not the raw store object.
11
+ - **[HIGH]** Derived actions not validating input before mutating state → malformed data enters store and propagates to all subscribers. Add input validation at action boundaries.
12
+ - **[MEDIUM]** `devtools` middleware enabled in production builds → full state history exposed via Redux DevTools browser extension. Gate behind `process.env.NODE_ENV !== 'production'`.
13
+ - **[MEDIUM]** Shared store state across SSR requests in server environments → one user's data leaks into another's response. Use request-scoped store instances on the server.
14
+ - **[LOW]** Store actions accepting raw event objects → unintentional data captured if `event.target.value` extraction is skipped. Extract primitives before passing to actions.
15
+
16
+ ---
17
+
18
+ ## Performance
19
+ - **[HIGH]** Subscribing to entire store with `const state = useStore()` instead of a selector → component re-renders on every store change regardless of relevance. Use `useStore(s => s.specificField)`.
20
+ - **[HIGH]** Inline selector functions `useStore(s => s.items.filter(...))` returning new reference every render → triggers re-render loop. Memoize with `useMemo` or use `useShallow` for shallow comparison.
21
+ - **[HIGH]** `useShallow` not used when selector returns an object or array → structural equality not checked, re-renders on every state change even when values are identical.
22
+ - **[MEDIUM]** Large arrays stored in Zustand without normalization (keyed map) → O(n) scans on every selector call. Normalize to `{ ids: [], entities: {} }` shape.
23
+ - **[MEDIUM]** Not using `subscribeWithSelector` middleware for external (non-React) subscriptions → manual subscription does not support granular field tracking.
24
+ - **[MEDIUM]** Single massive store with no slice separation → any action update triggers all selectors to re-evaluate. Split into domain slices combined at root.
25
+ - **[LOW]** Storing derived/computed values in state instead of computing in selectors → stale derived data when dependencies change. Keep store minimal, derive in selectors.
26
+
27
+ ---
28
+
29
+ ## Architecture
30
+ - **[HIGH]** Async logic (`fetch`, `axios`) inside actions without error handling or loading state → promise rejection silently ignored, UI stuck in loading. Handle `try/catch` and set error state explicitly.
31
+ - **[HIGH]** Mixing UI state (modal open, tab index) and server/async state in the same store → cache invalidation and loading logic collide. Use TanStack Query or SWR for server state.
32
+ - **[MEDIUM]** Monolithic store file with all state and actions in one object → hard to test and maintain. Apply the slices pattern: `create<StoreType>()((...a) => ({ ...authSlice(...a), ...cartSlice(...a) }))`.
33
+ - **[MEDIUM]** Store action directly importing and calling another store's `getState()` → tight coupling between stores. Compose at the component or service layer instead.
34
+ - **[MEDIUM]** Not using `immer` middleware for nested state updates → verbose and error-prone manual spread chains. Add `immer` middleware and mutate draft directly in actions.
35
+ - **[LOW]** Store file exporting multiple unrelated stores → implicit coupling and unclear ownership. One store per domain concern, one file per store.
36
+
37
+ ---
38
+
39
+ ## Code Quality
40
+ - **[HIGH]** Store typed as `any` or without an explicit interface → no TypeScript safety on state shape or action signatures. Define and apply a store interface: `create<StoreState & StoreActions>()`.
41
+ - **[HIGH]** Actions mutating state by directly modifying the object outside `set()` → bypasses Zustand's update mechanism, subscribers not notified. All mutations must go through `set()` or `immer` draft.
42
+ - **[MEDIUM]** Async actions reading store state via closure rather than `getState()` → stale closure captures old state snapshot. Use `get()` (second argument to store creator) inside async actions.
43
+ - **[MEDIUM]** Selectors not co-located with the store → business logic for data shape scattered across components. Export named selector functions from the store file.
44
+ - **[LOW]** `persist` configuration missing `name` field → defaults to generic key, collides across apps on the same domain. Always set an explicit, namespaced storage key.
45
+ - **[LOW]** Store file exporting the raw `useStore` hook without aliased named hooks → consumers must know internal structure. Export named hooks like `useCount`, `useUser`.
46
+
47
+ ---
48
+
49
+ ## Common Bugs & Pitfalls
50
+ - **[HIGH]** Selector returning a new object or array literal on every call `useStore(s => ({ a: s.a, b: s.b }))` → infinite re-render loop. Use `useShallow` or restructure to return primitives.
51
+ - **[HIGH]** `persist` with `partialize` not excluding non-serializable values (functions, class instances, Sets, Maps) → JSON serialization fails silently or corrupts stored state. Explicitly filter non-serializable fields in `partialize`.
52
+ - **[HIGH]** Async action not setting error state on failure → store stuck in `loading: true` with no way to recover. Always set `loading: false` and an `error` field in the catch block.
53
+ - **[MEDIUM]** `immer` producer both mutating the draft and returning a new value → undefined behavior, Zustand ignores one. Either mutate draft in place or return a new state object, never both.
54
+ - **[MEDIUM]** `devtools` middleware placement in middleware chain → `devtools` must be the outermost wrapper; placing it inside `persist` or `immer` breaks time-travel debugging.
55
+ - **[MEDIUM]** Hydration mismatch in SSR when `persist` rehydrates from localStorage after server render → causes React hydration errors. Use `onRehydrateStorage` callback and delay rendering until rehydrated.
56
+ - **[LOW]** Missing version field in `persist` config → schema changes cause corrupt old data to be loaded. Add `version` and a `migrate` function to handle upgrades.
@@ -42,6 +42,7 @@ Recommended reviews for this PR:
42
42
  [SR] Security Review — if auth/API/user data touched
43
43
  [PR] Performance Review — if DB/async/frontend affected
44
44
  [AR] Architecture Review — if new patterns/structure added
45
+ [BR] Business Review — for feature PRs, data migrations, or any high-risk change
45
46
  ```
46
47
 
47
48
  ### 2. Write PR Context File
@@ -29,7 +29,7 @@ This uses **step-file architecture** with sequential orchestration:
29
29
 
30
30
  Load config from `{main_config}` and resolve:
31
31
  - `project_name`, `target_repo`, `user_name`, `communication_language`
32
- - `review_output`, `github_repo`, `date` (system-generated)
32
+ - `review_output`, `platform_repo`, `date` (system-generated)
33
33
 
34
34
  ## EXECUTION
35
35