@mrciphersmith/keryx 0.4.28 → 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.
- package/dist/cli.js +4916 -3655
- package/dist/core.js +91 -28
- package/dist/keryx-general-worker-entry.js +413 -240
- package/package.json +1 -1
- package/src/gdskills/bundled/install-manifest.json +3 -0
- package/src/gdskills/bundled/rules/core/api-contracts.mdc +21 -136
- package/src/gdskills/bundled/rules/core/async-patterns.mdc +18 -171
- package/src/gdskills/bundled/rules/core/clean-architecture.mdc +40 -150
- package/src/gdskills/bundled/rules/core/cli-interface-design.mdc +63 -194
- package/src/gdskills/bundled/rules/core/code-style-patterns.mdc +36 -48
- package/src/gdskills/bundled/rules/core/concurrency-patterns.mdc +32 -0
- package/src/gdskills/bundled/rules/core/database-patterns.mdc +26 -148
- package/src/gdskills/bundled/rules/core/error-handling.mdc +57 -109
- package/src/gdskills/bundled/rules/core/frontend-assistant.mdc +14 -29
- package/src/gdskills/bundled/rules/core/layout-rendering.mdc +51 -0
- package/src/gdskills/bundled/rules/core/mobx-store-template.mdc +69 -511
- package/src/gdskills/bundled/rules/core/nestjs-dto.mdc +18 -36
- package/src/gdskills/bundled/rules/core/playwright-testing.mdc +35 -308
- package/src/gdskills/bundled/rules/core/security-baseline.mdc +18 -140
- package/src/gdskills/bundled/rules/core/skill-authoring.mdc +190 -0
- package/src/gdskills/bundled/rules/core/skills-storage-workflow.mdc +5 -0
- package/src/gdskills/bundled/rules/core/solid-principles.mdc +70 -121
- package/src/gdskills/bundled/rules/core/storybook-guidelines.mdc +20 -22
- package/src/gdskills/bundled/rules/core/tdd-workflow.mdc +37 -74
- package/src/gdskills/bundled/rules/core/ui-anti-slop.mdc +48 -37
- package/src/gdskills/bundled/skills/orchestration/task-implementer/SKILL.md +2 -2
- package/src/gdskills/bundled/skills/quality/deprecation-path/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/quality/tests-creator/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-architecture/SKILL.md +25 -61
- package/src/gdskills/bundled/skills/review/review-backend/SKILL.md +15 -69
- package/src/gdskills/bundled/skills/review/review-clean-code/SKILL.md +84 -418
- package/src/gdskills/bundled/skills/review/review-core-boundaries/SKILL.md +2 -2
- package/src/gdskills/bundled/skills/review/review-degradation/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-flow-graph/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-frontend/SKILL.md +17 -311
- package/src/gdskills/bundled/skills/review/review-frontend-conventions/SKILL.md +8 -22
- package/src/gdskills/bundled/skills/review/review-highload/SKILL.md +84 -228
- package/src/gdskills/bundled/skills/review/review-layout/SKILL.md +22 -28
- package/src/gdskills/bundled/skills/review/review-logic/SKILL.md +9 -10
- package/src/gdskills/bundled/skills/review/review-performance/SKILL.md +16 -38
- package/src/gdskills/bundled/skills/review/review-premise/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-regression/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-security-code/SKILL.md +8 -8
- package/src/gdskills/bundled/skills/review/review-style/SKILL.md +49 -88
- package/src/gdskills/bundled/skills/review/review-testing-practices/SKILL.md +22 -40
- package/src/gdskills/bundled/skills/review/review-ui-ux/SKILL.md +42 -82
- package/src/gdskills/bundled/stacks/angular/rules/coding-style.mdc +15 -57
- package/src/gdskills/bundled/stacks/angular/rules/patterns.mdc +16 -60
- package/src/gdskills/bundled/stacks/angular/rules/security.mdc +11 -49
- package/src/gdskills/bundled/stacks/angular/rules/testing.mdc +13 -52
- package/src/gdskills/bundled/stacks/c-cpp/rules/coding-style.mdc +33 -57
- package/src/gdskills/bundled/stacks/c-cpp/rules/patterns.mdc +35 -62
- package/src/gdskills/bundled/stacks/c-cpp/rules/security.mdc +35 -62
- package/src/gdskills/bundled/stacks/c-cpp/rules/testing.mdc +34 -54
- package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/patterns.mdc +27 -56
- package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/security.mdc +51 -119
- package/src/gdskills/bundled/stacks/csharp-dotnet/rules/coding-style.mdc +42 -74
- package/src/gdskills/bundled/stacks/csharp-dotnet/rules/patterns.mdc +45 -83
- package/src/gdskills/bundled/stacks/csharp-dotnet/rules/security.mdc +34 -59
- package/src/gdskills/bundled/stacks/csharp-dotnet/rules/testing.mdc +33 -62
- package/src/gdskills/bundled/stacks/django/rules/coding-style.mdc +15 -56
- package/src/gdskills/bundled/stacks/django/rules/patterns.mdc +16 -68
- package/src/gdskills/bundled/stacks/django/rules/security.mdc +13 -71
- package/src/gdskills/bundled/stacks/django/rules/testing.mdc +16 -62
- package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/coding-style.mdc +30 -53
- package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/patterns.mdc +20 -56
- package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/security.mdc +52 -122
- package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/testing.mdc +23 -42
- package/src/gdskills/bundled/stacks/fastapi/rules/coding-style.mdc +13 -47
- package/src/gdskills/bundled/stacks/fastapi/rules/patterns.mdc +18 -81
- package/src/gdskills/bundled/stacks/fastapi/rules/security.mdc +13 -75
- package/src/gdskills/bundled/stacks/fastapi/rules/testing.mdc +14 -58
- package/src/gdskills/bundled/stacks/flutter-dart/rules/coding-style.mdc +36 -74
- package/src/gdskills/bundled/stacks/flutter-dart/rules/patterns.mdc +30 -66
- package/src/gdskills/bundled/stacks/flutter-dart/rules/security.mdc +33 -67
- package/src/gdskills/bundled/stacks/flutter-dart/rules/testing.mdc +41 -73
- package/src/gdskills/bundled/stacks/go/rules/coding-style.mdc +36 -57
- package/src/gdskills/bundled/stacks/go/rules/patterns.mdc +27 -42
- package/src/gdskills/bundled/stacks/go/rules/security.mdc +26 -43
- package/src/gdskills/bundled/stacks/go/rules/testing.mdc +23 -41
- package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/coding-style.mdc +21 -40
- package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/patterns.mdc +26 -43
- package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/security.mdc +25 -37
- package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/testing.mdc +34 -50
- package/src/gdskills/bundled/stacks/kotlin-android/rules/coding-style.mdc +28 -65
- package/src/gdskills/bundled/stacks/kotlin-android/rules/patterns.mdc +34 -78
- package/src/gdskills/bundled/stacks/kotlin-android/rules/security.mdc +35 -68
- package/src/gdskills/bundled/stacks/kotlin-android/rules/testing.mdc +34 -68
- package/src/gdskills/bundled/stacks/mobx/rules/coding-style.mdc +18 -64
- package/src/gdskills/bundled/stacks/mobx/rules/patterns.mdc +13 -66
- package/src/gdskills/bundled/stacks/mobx/rules/security.mdc +8 -35
- package/src/gdskills/bundled/stacks/mobx/rules/testing.mdc +10 -39
- package/src/gdskills/bundled/stacks/nestjs/rules/coding-style.mdc +32 -45
- package/src/gdskills/bundled/stacks/nestjs/rules/patterns.mdc +40 -60
- package/src/gdskills/bundled/stacks/nestjs/rules/security.mdc +30 -50
- package/src/gdskills/bundled/stacks/nestjs/rules/testing.mdc +27 -47
- package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/coding-style.mdc +14 -48
- package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/patterns.mdc +15 -67
- package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/security.mdc +12 -50
- package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/testing.mdc +11 -43
- package/src/gdskills/bundled/stacks/php-laravel/rules/coding-style.mdc +17 -58
- package/src/gdskills/bundled/stacks/php-laravel/rules/patterns.mdc +15 -56
- package/src/gdskills/bundled/stacks/php-laravel/rules/security.mdc +13 -50
- package/src/gdskills/bundled/stacks/php-laravel/rules/testing.mdc +14 -55
- package/src/gdskills/bundled/stacks/python/rules/coding-style.mdc +13 -41
- package/src/gdskills/bundled/stacks/python/rules/patterns.mdc +20 -61
- package/src/gdskills/bundled/stacks/python/rules/security.mdc +15 -57
- package/src/gdskills/bundled/stacks/python/rules/testing.mdc +16 -50
- package/src/gdskills/bundled/stacks/react/rules/coding-style.mdc +14 -40
- package/src/gdskills/bundled/stacks/react/rules/patterns.mdc +15 -55
- package/src/gdskills/bundled/stacks/react/rules/security.mdc +13 -49
- package/src/gdskills/bundled/stacks/react/rules/testing.mdc +10 -37
- package/src/gdskills/bundled/stacks/ruby-rails/rules/coding-style.mdc +15 -48
- package/src/gdskills/bundled/stacks/ruby-rails/rules/patterns.mdc +18 -67
- package/src/gdskills/bundled/stacks/ruby-rails/rules/security.mdc +11 -60
- package/src/gdskills/bundled/stacks/ruby-rails/rules/testing.mdc +14 -65
- package/src/gdskills/bundled/stacks/rust/rules/coding-style.mdc +39 -65
- package/src/gdskills/bundled/stacks/rust/rules/patterns.mdc +33 -60
- package/src/gdskills/bundled/stacks/rust/rules/security.mdc +35 -57
- package/src/gdskills/bundled/stacks/rust/rules/testing.mdc +29 -52
- package/src/gdskills/bundled/stacks/sql-db/rules/coding-style.mdc +12 -48
- package/src/gdskills/bundled/stacks/sql-db/rules/patterns.mdc +22 -113
- package/src/gdskills/bundled/stacks/sql-db/rules/security.mdc +11 -56
- package/src/gdskills/bundled/stacks/sql-db/rules/testing.mdc +14 -59
- package/src/gdskills/bundled/stacks/swift-ios/rules/coding-style.mdc +29 -65
- package/src/gdskills/bundled/stacks/swift-ios/rules/patterns.mdc +41 -88
- package/src/gdskills/bundled/stacks/swift-ios/rules/security.mdc +28 -53
- package/src/gdskills/bundled/stacks/swift-ios/rules/testing.mdc +32 -65
- package/src/gdskills/bundled/stacks/vue/rules/coding-style.mdc +17 -52
- package/src/gdskills/bundled/stacks/vue/rules/patterns.mdc +17 -63
- package/src/gdskills/bundled/stacks/vue/rules/security.mdc +11 -41
- package/src/gdskills/bundled/stacks/vue/rules/testing.mdc +16 -48
|
@@ -28,7 +28,7 @@ license: "MIT"
|
|
|
28
28
|
|
|
29
29
|
# Review — Testing Practices
|
|
30
30
|
|
|
31
|
-
Reviewer for local testing discipline. Read project test guides first when present, then apply the neutral baseline below. Its inputs are the reviewer payload only; session memory and earlier conversation are not inputs. It runs the tests only when its payload's `allowed_tools` says `run-tests`, within `exec_budget_s`; otherwise it runs no command, except the read-only `git log`, `git blame` and `git show` where its host gives a read-only child git (keryx shell does not: there the payload supplies the history)
|
|
31
|
+
Reviewer for local testing discipline. Read project test guides first when present, then apply the neutral baseline below. Its inputs are the reviewer payload only; session memory and earlier conversation are not inputs. It runs the tests only when its payload's `allowed_tools` says `run-tests`, within `exec_budget_s`; otherwise it runs no command, except the read-only `git log`, `git blame` and `git show` where its host gives a read-only child git (keryx shell does not: there the payload supplies the history).
|
|
32
32
|
|
|
33
33
|
---
|
|
34
34
|
|
|
@@ -104,26 +104,25 @@ pass, then work the checklist.
|
|
|
104
104
|
|
|
105
105
|
---
|
|
106
106
|
|
|
107
|
-
##
|
|
107
|
+
## The standard
|
|
108
|
+
|
|
109
|
+
These project rules hold what to check and how to rate it. Read each one that applies to the change and rate by its **Review severities** table; this lens does not restate them.
|
|
108
110
|
|
|
109
|
-
|
|
111
|
+
- `.metaproject/rules/core/tdd-workflow.mdc`: one toolchain, colocation, a test for new or changed logic, boundary mocking, no real network or clock, no sleeps, flakes fixed by waiting on a state, tests never deleted to go green.
|
|
112
|
+
- `.metaproject/rules/core/playwright-testing.mdc`: waits, locator order, auth in a setup project, independent specs, owned data, route mocking, screenshots, smoke tags.
|
|
110
113
|
|
|
111
|
-
|
|
112
|
-
- Shared test infrastructure folders are not used as buckets for feature tests.
|
|
113
|
-
- Unit, integration, component, and e2e tiers are named and routed consistently.
|
|
114
|
-
- Fast feedback lanes stay fast; screenshot/component/e2e suites are not used for cheap unit
|
|
115
|
-
assertions.
|
|
116
|
-
- Coverage gates focus on changed risk, not low-value tests for trivial getters.
|
|
114
|
+
The checks below are the lens's own; no rule covers them.
|
|
117
115
|
|
|
118
|
-
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Checklist
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
-
|
|
123
|
-
|
|
120
|
+
### Boundary Mocking, Beyond the Rule
|
|
121
|
+
|
|
122
|
+
- For data-fetching UI, prefer rendering the real component/store and mocking only the network boundary.
|
|
123
|
+
- Avoid mocking the API module in integration tests when the repository has network-level mock infrastructure.
|
|
124
124
|
- Unhandled network requests fail loudly instead of silently hitting the real world.
|
|
125
|
-
- Mock handlers/fixtures are colocated and reusable by tests/stories where practical.
|
|
126
|
-
- Handler paths match the runtime test environment and avoid hard-coded origins unless required.
|
|
125
|
+
- Mock handlers/fixtures are colocated and reusable by tests/stories where practical; handler paths match the runtime test environment and avoid hard-coded origins unless required.
|
|
127
126
|
|
|
128
127
|
### Behaviour Assertions
|
|
129
128
|
|
|
@@ -166,24 +165,10 @@ pass, then work the checklist.
|
|
|
166
165
|
such test needs one positive artifact proving the path was entered before the
|
|
167
166
|
negative assertions mean anything.
|
|
168
167
|
|
|
169
|
-
###
|
|
170
|
-
|
|
171
|
-
- Tests create their own artifacts with unique names and assert on those artifacts.
|
|
172
|
-
- Avoid mutating or deleting seeded/shared environment data.
|
|
173
|
-
- Avoid env-wide assertions such as exact global counts, `.first()`, or `.nth(N)` unless the test
|
|
174
|
-
owns the full dataset.
|
|
175
|
-
- No fixed sleeps; wait on assertions, events, responses, or polling predicates.
|
|
176
|
-
- Backend-dependent assertions wait on the response/event that proves the backend completed.
|
|
177
|
-
- Smoke tags are reserved for fast, reliable, load-bearing baseline flows.
|
|
178
|
-
- Locator priority prefers stable test ids and accessible roles over raw CSS selectors.
|
|
179
|
-
- Screenshot tests are avoided for heavy, unstable, or non-deterministic surfaces unless the
|
|
180
|
-
repository explicitly supports them.
|
|
168
|
+
### Tiers
|
|
181
169
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
- Account for incremental compiler caches when validating newly added files.
|
|
185
|
-
- Generated/vendored files that are outside the lint/type project are ignored centrally rather
|
|
186
|
-
than hand-formatted into compliance.
|
|
170
|
+
- Fast feedback lanes stay fast: screenshot, component and e2e suites are not used for cheap unit assertions.
|
|
171
|
+
- Coverage gates focus on changed risk.
|
|
187
172
|
|
|
188
173
|
---
|
|
189
174
|
|
|
@@ -234,20 +219,17 @@ class_scope:
|
|
|
234
219
|
- **Fix**: concrete test rewrite or fixture/handler change
|
|
235
220
|
```
|
|
236
221
|
|
|
237
|
-
Severity comes from **Severity (canonical)** in `review-orchestrator/SKILL.md`.
|
|
222
|
+
Severity comes from **Severity (canonical)** in `review-orchestrator/SKILL.md`. Defects the two rules name are rated by their **Review severities** tables (`tdd-workflow.mdc`, `playwright-testing.mdc`), including a test that cannot fail and a flaky test; this lens does not restate them. What follows is where its own recurring conditions land.
|
|
238
223
|
|
|
239
224
|
| Condition | Severity | Why, under the canonical rubric |
|
|
240
225
|
|---|---|---|
|
|
241
|
-
| A test that passes while the behaviour it names is broken | `blocker` | The acceptance criterion is unimplemented — the test only claims otherwise |
|
|
242
|
-
| Real-network leak; shared-data mutation across tests; fixed sleeps; asserting on a backend race | `major` | Named trigger (the run) and named outcome (flake or a false pass) |
|
|
243
226
|
| A gate the diff added survives deletion with the suite green | `minor` | The code is correct; the cost is that the next edit to it is unprotected |
|
|
244
|
-
| A fixture whose shape contradicts the scenario it names, or pins a value the producer cannot emit | `minor` | Same
|
|
227
|
+
| A fixture whose shape contradicts the scenario it names, or pins a value the producer cannot emit | `minor` | Same, plus the next author reads it as coverage it does not provide |
|
|
245
228
|
| Assertions ride the fallback branch while the code names another authoritative | `minor` | Same |
|
|
246
|
-
|
|
|
229
|
+
| A test that asserts only falsy state, with no positive artifact that the path ran | `minor` | It passes when the code never ran |
|
|
230
|
+
| Substrate choice (API module mocked where network-level mocks exist) | `minor` | The suite is correct; the cost is to whoever maintains it |
|
|
247
231
|
| A convention preference with no effect on determinism or signal | `info` | Shared laws 1 and 2 |
|
|
248
232
|
|
|
249
|
-
A flaky test is `major`, not `blocker`: it wastes time, but it does not ship a defect. A test that cannot fail does — which is why it is the one `blocker` here.
|
|
250
|
-
|
|
251
233
|
The three mutation-pass rows sit at `minor` deliberately, and the reasoning is the canonical rubric rather than modesty: a coverage gap names no runtime trigger and no user-visible outcome, so it cannot be `major` under the boundary test. What makes them worth reporting is not severity but **evidence class** — each one is a command that ran, which is the rarest thing in a review and the only kind of finding a later round cannot argue away. Report them with the mutation and its result, and they survive adjudication intact. Report them as "coverage looks thin" and they are correctly discarded.
|
|
252
234
|
|
|
253
235
|
The moment a surviving mutation is accompanied by a **reachable input that makes the unpinned code do the wrong thing**, that is a separate finding at the severity its own outcome earns — usually `major`. The coverage gap and the defect are two findings, not one, and conflating them loses whichever the adjudicator disbelieves.
|
|
@@ -17,7 +17,7 @@ triggers:
|
|
|
17
17
|
- "ai slop check"
|
|
18
18
|
metadata:
|
|
19
19
|
author: "MrCipherSmith"
|
|
20
|
-
version: "1.
|
|
20
|
+
version: "1.3.0"
|
|
21
21
|
origin: "authored"
|
|
22
22
|
category: "review"
|
|
23
23
|
compatible_harnesses: "cursor,codex,zed,opencode,claude"
|
|
@@ -28,27 +28,17 @@ license: "MIT"
|
|
|
28
28
|
|
|
29
29
|
Reviewer for what the user sees and does. Its inputs are the reviewer payload only; session memory and earlier conversation are not inputs.
|
|
30
30
|
|
|
31
|
-
Read-only, three passes, cheapest and most objective first: deterministic checks → usability heuristics → aesthetic judgment.
|
|
32
|
-
tiers, thresholds, and slop score come from `rules/core/ui-anti-slop.mdc` — read it first.
|
|
31
|
+
Read-only, three passes, cheapest and most objective first: deterministic checks → usability heuristics → aesthetic judgment.
|
|
33
32
|
Never edits code; fixes are proposed, not applied.
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
## Workflow
|
|
34
|
+
## Rules This Lens Reads
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
review-ui-ux Progress:
|
|
41
|
-
- [ ] Step 1: Read Job Context and DESIGN.md (if present)
|
|
42
|
-
- [ ] Step 2: Determine mode (code | live | both) and scope
|
|
43
|
-
- [ ] Step 3: Restate context: product, audience, primary task, surface type
|
|
44
|
-
- [ ] Step 4: Pass 1 — deterministic checks (code + render)
|
|
45
|
-
- [ ] Step 5: Pass 2 — usability heuristics, states, forms
|
|
46
|
-
- [ ] Step 6: Pass 3 — hierarchy, distinctiveness, slop score
|
|
47
|
-
- [ ] Step 7: Rate severity, attach evidence, write fixes
|
|
48
|
-
- [ ] Step 8: Emit report; list checks not run
|
|
49
|
-
```
|
|
36
|
+
Read both in `.metaproject/rules/core/` first. Conditions they rate are rated by their **Review severities** tables; this lens states none of them again and keeps only its method and calibration.
|
|
50
37
|
|
|
51
|
-
|
|
38
|
+
| Condition | Rule |
|
|
39
|
+
|---|---|
|
|
40
|
+
| Tell catalog and tiers, **Applies to** (marketing vs app screens), craft thresholds, slop score, exemptions, invented proof, focus, contrast, states, the WCAG floor | `ui-anti-slop.mdc` |
|
|
41
|
+
| Overflow, clipping and sideways scroll at a width, the 320px floor, locale and RTL geometry | `layout-rendering.mdc`, rated by `review-layout`: report none of it here |
|
|
52
42
|
|
|
53
43
|
## Input Contract
|
|
54
44
|
|
|
@@ -75,26 +65,24 @@ review-ui-ux Progress:
|
|
|
75
65
|
|
|
76
66
|
If there is neither a diff with UI files nor a supplied render, return `NEEDS_CONTEXT`.
|
|
77
67
|
|
|
78
|
-
|
|
68
|
+
Before Pass 1, read the job context and `DESIGN.md` if present, then state the product, audience,
|
|
69
|
+
primary task and surface type (marketing/content or app screen, per **Applies to** in the rule).
|
|
79
70
|
|
|
80
71
|
## Pass 1 — Deterministic checks
|
|
81
72
|
|
|
82
|
-
Objective, measurable, run first.
|
|
73
|
+
Objective, measurable, run first. The signals and thresholds are the rule's; this table is
|
|
74
|
+
where each is read in each mode, and each finding cites the measured value and the threshold.
|
|
83
75
|
|
|
84
|
-
| Check | Code mode
|
|
76
|
+
| Check | Code mode | Live mode |
|
|
85
77
|
|---|---|---|
|
|
86
|
-
| Focus | `outline: none` / `outline-0` without `:focus-visible` | Tab through: ring visible,
|
|
87
|
-
| Contrast | Token pairs computed from theme | Computed colors
|
|
88
|
-
| Color-only meaning | Status by class color only |
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
|
|
|
92
|
-
| Names & semantics | Icon-only buttons without accessible name; `div` with `onClick`; heading skips | Accessibility tree check |
|
|
78
|
+
| Focus | `outline: none` / `outline-0` without `:focus-visible` | Tab through: ring visible, not hidden by sticky bars |
|
|
79
|
+
| Contrast | Token pairs computed from the theme | Computed colors on the render |
|
|
80
|
+
| Color-only meaning, targets | Status by class color only; icon buttons with tiny padding | Grayscale read; measured target box |
|
|
81
|
+
| Reduced motion | No `prefers-reduced-motion` branch; `transition: all` | Emulate reduced motion: content stays, travel stops |
|
|
82
|
+
| Zoom | `user-scalable=no`, `maximum-scale=1` | Pinch-zoom on the render |
|
|
83
|
+
| Names & semantics | Icon-only buttons without accessible name; `div` with `onClick`; heading skips | Accessibility tree |
|
|
93
84
|
| Forms | Placeholder-as-label, missing `type`/`autocomplete`, pre-disabled submit, paste blocked | Submit empty: first error focused, message next to field |
|
|
94
|
-
| Fonts |
|
|
95
|
-
| Palette tells | `from-purple-* to-blue-*`, `bg-clip-text`, untouched `indigo-500`/`emerald-500` | Visible on render |
|
|
96
|
-
| Uniform surfaces | Same radius + shadow class on most containers; cards in cards | Visual scan |
|
|
97
|
-
| Copy tells | Filler verbs, emoji in headings, Jane Doe / Acme, lorem, invented round stats | Visible text |
|
|
85
|
+
| Fonts, palette, surfaces, copy | Theme fonts, palette classes, radius/shadow classes, visible strings | Computed font-family, the render, visible text |
|
|
98
86
|
|
|
99
87
|
## Pass 2 — Usability
|
|
100
88
|
|
|
@@ -104,29 +92,25 @@ Against the stated primary task:
|
|
|
104
92
|
consistency & standards, error prevention, recognition over recall, accelerators, minimalism,
|
|
105
93
|
error recovery, help. Cite the heuristic number.
|
|
106
94
|
- **States** — every interactive element: hover, focus-visible, active, disabled, loading.
|
|
107
|
-
Every data view: loading (
|
|
108
|
-
|
|
109
|
-
remedy, input kept), sparse, dense.
|
|
95
|
+
Every data view: loading (timing per the rule), empty (specific reason + action, never
|
|
96
|
+
"No results" while loading), error (near source, cause + remedy, input kept), sparse, dense.
|
|
110
97
|
- **Forms** — labels, inline errors, no redundant entry (3.3.7), password managers allowed (3.3.8).
|
|
111
|
-
- **Laws of UX** — Fitts (primary
|
|
112
|
-
|
|
113
|
-
look is not), proximity/common region (grouping matches meaning).
|
|
98
|
+
- **Laws of UX** — Fitts (primary large and near, destructive not beside it), Hick (fewer
|
|
99
|
+
choices, recommended marked), Jakob, proximity/common region (grouping matches meaning).
|
|
114
100
|
- **Destructive & async** — confirm or Undo; optimistic updates roll back; double-submit guarded.
|
|
115
101
|
|
|
116
102
|
## Pass 3 — Hierarchy and distinctiveness
|
|
117
103
|
|
|
118
|
-
- **Squint test** — blur the render; the intended focal element still dominates
|
|
119
|
-
treatments and ≤2 large elements per view.
|
|
104
|
+
- **Squint test** — blur the render; the intended focal element still dominates; contrast
|
|
105
|
+
treatments within the rule's cap and ≤2 large elements per view.
|
|
120
106
|
- **Five-second test** — first screen says what this is and what to do.
|
|
121
107
|
- **DESIGN.md conformance** — palette roles, type scale, signature element present and single,
|
|
122
108
|
"not doing" list respected. Drift from DESIGN.md is a finding.
|
|
123
109
|
- **Swap / competitor test** — could a competitor's logo go on this unnoticed?
|
|
124
|
-
- **Slop score** — count tells by tier
|
|
125
|
-
honor
|
|
110
|
+
- **Slop score** — count tells by tier with the rule's formula on the surfaces **Applies to**
|
|
111
|
+
names, list them, honor exemptions. Score ≥9 → recommend `ui-direction`, not patching.
|
|
126
112
|
- **Restraint** — name the one element that should be removed.
|
|
127
113
|
|
|
128
|
-
---
|
|
129
|
-
|
|
130
114
|
## Output Contract
|
|
131
115
|
|
|
132
116
|
```
|
|
@@ -143,8 +127,6 @@ task, surface type, mode); Scores (slop score with T1/T2/T3 counts and band, WCA
|
|
|
143
127
|
pass/fail, viewports checked or "not run"); Top 3 changes; findings by severity; What works
|
|
144
128
|
(keep); Checks not run.
|
|
145
129
|
|
|
146
|
-
---
|
|
147
|
-
|
|
148
130
|
## Iron Laws
|
|
149
131
|
|
|
150
132
|
### This reviewer's own
|
|
@@ -155,32 +137,19 @@ pass/fail, viewports checked or "not run"); Top 3 changes; findings by severity;
|
|
|
155
137
|
| Measure on the render when possible | Class names are intent; pixels are truth. A contrast, size or visual claim without a measurement (computed value, screenshot region, exact token pair) is `info` |
|
|
156
138
|
| One tell is not slop; the stack is | Inter for body text alone is fine; five defaults together are not |
|
|
157
139
|
| Distinctive look, conventional behavior | Never penalize a standard interaction pattern as "generic" |
|
|
158
|
-
| DESIGN.md
|
|
140
|
+
| `DESIGN.md`, the brief or the job context wins | A deliberate choice is not a tell (shared law 4) |
|
|
159
141
|
| Never claim checks that weren't run | List them under "Checks not run" |
|
|
160
142
|
|
|
161
143
|
### Shared laws (every reviewer)
|
|
162
144
|
|
|
163
|
-
|
|
164
145
|
1. **A claim of runtime harm with no reproducible path is `info`.** If you cannot name the input, call, or condition that reaches the code, you have an observation, not a finding. Report it as `info` and say what would settle it.
|
|
165
146
|
2. **Never flag the theoretical.** The path you describe must exist in the code under review. Do not report a safe API because it could be misused, or a pattern because it is often wrong elsewhere.
|
|
166
147
|
3. **One finding per class, not one per occurrence.** When the same shape appears at several sites, report it once and list every site. Ten findings that are one finding hide the other nine problems.
|
|
167
148
|
4. **A deliberate choice is not a defect until its reason is read and shown wrong.** An explicit override, suppression or exemption, a comment or commit giving a reason, or a sibling doing the same is a decision: read its reason (the comment, `git log -L` or `git blame`, the sibling) before you report it, and report it only when you can show that reason wrong. A project rule is checked against accepted platform practice and its known exceptions before a deviation from it is reported.
|
|
168
149
|
|
|
169
150
|
Severity levels are defined once, in `review-orchestrator/SKILL.md` →
|
|
170
|
-
**Severity (canonical)**. This reviewer keeps no rubric of its own
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
| Condition | Severity | Why, under the canonical rubric |
|
|
174
|
-
|---|---|---|
|
|
175
|
-
| Invented proof shipped as fact: fake stats, logos, testimonials, customers | `major` | Named trigger (the rendered page), named outcome (users read false claims) |
|
|
176
|
-
| Primary task unreachable by keyboard, or focus invisible on the primary flow | `major` | Named trigger (Tab through the flow), named outcome (the task cannot be finished) |
|
|
177
|
-
| Text contrast below 4.5:1 (3:1 large) on primary content, measured | `major` | Named trigger and outcome (the text is unreadable for low-vision users) |
|
|
178
|
-
| Missing loading / empty / error state on a primary view; destructive action without confirm or Undo | `major` | Named trigger (that state), named outcome (blank, stuck or irreversible screen) |
|
|
179
|
-
| T1 slop tell, or slop score ≥9 | `minor` | The UI works; the cost is identity and trust, not behavior |
|
|
180
|
-
| T2 tells, hierarchy competition, inconsistent tokens, generic CTA labels | `minor` | Behaves correctly; aesthetic or clarity cost |
|
|
181
|
-
| T3 tells, polish, or any visual claim you could not measure | `info` | Shared law 1 |
|
|
182
|
-
|
|
183
|
-
---
|
|
151
|
+
**Severity (canonical)**. This reviewer keeps no rubric of its own: its conditions are
|
|
152
|
+
rated by the **Review severities** table in `ui-anti-slop.mdc`.
|
|
184
153
|
|
|
185
154
|
## Orchestrated Review Contract
|
|
186
155
|
|
|
@@ -215,39 +184,30 @@ a claim that the class has exactly one member — make it deliberately.
|
|
|
215
184
|
- **Fix**: concrete change (token, component, copy, state)
|
|
216
185
|
```
|
|
217
186
|
|
|
218
|
-
---
|
|
219
|
-
|
|
220
187
|
## Scope Boundaries
|
|
221
188
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
| Naming, readability | NO | `review-style` |
|
|
228
|
-
| Re-render cost, bundle size | NO | `review-performance` |
|
|
229
|
-
| Pixel geometry: sizing, collapse, overflow, RTL, locale length | NO | `review-layout` |
|
|
230
|
-
| Logic bugs behind the UI | NO | `review-logic` |
|
|
231
|
-
| Creating a direction or rebuilding the UI | NO | `ui-direction`, `ui-craft` |
|
|
189
|
+
In scope: usability, states, forms, hierarchy, the a11y floor, slop. Elsewhere: React/MobX
|
|
190
|
+
structure (`review-frontend`), class/token conventions (`review-frontend-conventions`), naming
|
|
191
|
+
(`review-style`), re-render cost and bundle size (`review-performance`), pixel geometry — sizing,
|
|
192
|
+
collapse, overflow, reflow at a width, RTL, locale length (`review-layout`), logic bugs behind the
|
|
193
|
+
UI (`review-logic`), creating a direction or rebuilding the UI (`ui-direction`, `ui-craft`).
|
|
232
194
|
|
|
233
195
|
## Job Context Awareness
|
|
234
196
|
|
|
235
197
|
When dispatched with `JOB_NAME` / `CONTEXT_PATH`, read the context document before scope
|
|
236
|
-
detection
|
|
237
|
-
|
|
198
|
+
detection for the primary task, audience and agreed design decisions; an agreed decision is an
|
|
199
|
+
exemption like one in `DESIGN.md`.
|
|
238
200
|
|
|
239
201
|
## Red Flags
|
|
240
202
|
|
|
241
203
|
| Rationalization | Reality |
|
|
242
204
|
|---|---|
|
|
243
205
|
| "It looks fine to me" | State the measurement or cap at `info` |
|
|
244
|
-
| "Generic is safe for an admin panel" |
|
|
206
|
+
| "Generic is safe for an admin panel" | App screens skip the marketing rows (**Applies to**); missing states and broken focus still count |
|
|
245
207
|
| "Accessibility is a separate review" | The WCAG 2.2 AA floor is in scope here |
|
|
246
208
|
| "No browser, so I'll assume the contrast passes" | Compute from tokens or list it under "Checks not run" |
|
|
247
209
|
| "Every card has the same style — that's consistency" | Consistency of tokens, yes; one radius + shadow on everything is the card kit |
|
|
248
210
|
|
|
249
|
-
---
|
|
250
|
-
|
|
251
211
|
## Verification
|
|
252
212
|
|
|
253
213
|
Report done only once all of these hold:
|
|
@@ -259,9 +219,9 @@ Report done only once all of these hold:
|
|
|
259
219
|
about; `line` is derived at ingest from that quote, never counted.
|
|
260
220
|
- Every `blocker` and `major` carries `class_scope` with `sites` and an
|
|
261
221
|
`enumeration_method` naming the search that derived the set.
|
|
262
|
-
- No finding invents a severity: each
|
|
263
|
-
`review-orchestrator/SKILL.md`.
|
|
264
|
-
- Slop score lists its tells by tier and the
|
|
222
|
+
- No finding invents a severity: each comes from the `ui-anti-slop.mdc` table, under
|
|
223
|
+
**Severity (canonical)** in `review-orchestrator/SKILL.md`; overflow went to `review-layout`.
|
|
224
|
+
- Slop score lists its tells by tier and the exemptions it honored, with where each was read.
|
|
265
225
|
- "Checks not run" names every skipped check and why.
|
|
266
226
|
- The reply is the `REVIEW_RESULT` the Orchestrated Review Contract asks for, with
|
|
267
227
|
finding ids prefixed `UX-`, or `NEEDS_CONTEXT` naming what was missing.
|
|
@@ -8,75 +8,33 @@ metadata:
|
|
|
8
8
|
# Angular coding style
|
|
9
9
|
|
|
10
10
|
Narrows the stack-agnostic style rules to current Angular idiom (standalone
|
|
11
|
-
components, signals, `inject()`).
|
|
12
|
-
|
|
13
|
-
common rules this file `extends`.
|
|
11
|
+
components, signals, `inject()`). Everything not Angular-specific comes from
|
|
12
|
+
the common rules this file `extends`.
|
|
14
13
|
|
|
15
14
|
## Components and files
|
|
16
15
|
|
|
17
|
-
- Components, directives, and pipes are standalone
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
end-to-end.
|
|
21
|
-
- One component (and its template/styles) per file, named after the
|
|
22
|
-
component class (`OrderSummary` in `order-summary.ts`, not a generic
|
|
23
|
-
`component.ts`). Match whatever file-suffix convention (`.component.ts`
|
|
24
|
-
vs. plain `.ts`) the project's own `angular.json`/existing files already
|
|
25
|
-
use rather than introducing a second one.
|
|
26
|
-
- Keep a component's template under roughly 60-80 lines before extracting a
|
|
27
|
-
child component; a template doing significant `@if`/`@for` branching for
|
|
28
|
-
more than one concern is a sign the branches belong in separate
|
|
29
|
-
components.
|
|
16
|
+
- Components, directives, and pipes are standalone: do not set `standalone: false` or write a new `NgModule` unless the project is NgModule-based end-to-end.
|
|
17
|
+
- One component per file, named after the class (`OrderSummary` in `order-summary.ts`, not `component.ts`). Match the project's file-suffix convention (`.component.ts` vs plain `.ts`); do not introduce a second one.
|
|
18
|
+
- Extract a child component when a template passes roughly 60-80 lines or branches (`@if`/`@for`) for more than one concern.
|
|
30
19
|
|
|
31
20
|
## Dependency injection
|
|
32
21
|
|
|
33
|
-
- Prefer
|
|
34
|
-
|
|
35
|
-
cleanly with field initializers and works outside constructors (guards,
|
|
36
|
-
resolvers, `provide*` factories). Do not mix `inject()` and
|
|
37
|
-
constructor-parameter injection for different dependencies in the same
|
|
38
|
-
class — pick one per class, and prefer `inject()` for new classes.
|
|
39
|
-
- `inject()` only works inside an injection context (a constructor, a field
|
|
40
|
-
initializer, or a call wrapped in `runInInjectionContext`) — do not call
|
|
41
|
-
it inside a `setTimeout`, a plain async callback, or after the
|
|
42
|
-
constructor has returned.
|
|
22
|
+
- Prefer `inject()` over constructor-parameter injection for new code (`private readonly router = inject(Router);`). Pick one style per class; do not mix.
|
|
23
|
+
- Call `inject()` only in an injection context (constructor, field initializer, `runInInjectionContext`), not in `setTimeout` or a plain async callback.
|
|
43
24
|
|
|
44
25
|
## Signals and state
|
|
45
26
|
|
|
46
|
-
- Use `signal()` for local
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
value directly; always go through `.set()`/`.update()`.
|
|
50
|
-
- Keep a `computed()`'s computation pure (no side effects, no writes to
|
|
51
|
-
other signals inside it) — if a change needs to trigger a side effect,
|
|
52
|
-
use `effect()`, not a computed callback abused for its side effect.
|
|
53
|
-
- Do not mirror a signal's value into a plain class field "for convenience"
|
|
54
|
-
in the template — read the signal directly (`value()`) so Angular's
|
|
55
|
-
fine-grained reactivity tracks the actual dependency.
|
|
27
|
+
- Use `signal()` for local state, `computed()` for derived values, `input()`/`model()` for inputs; change a signal only through `.set()`/`.update()`.
|
|
28
|
+
- Keep `computed()` pure (no side effects, no writes to other signals); use `effect()` for side effects.
|
|
29
|
+
- Do not mirror a signal into a plain class field for the template; read `value()` directly.
|
|
56
30
|
|
|
57
31
|
## Templates and control flow
|
|
58
32
|
|
|
59
|
-
- Use
|
|
60
|
-
|
|
61
|
-
surrounding component's own template still uses the structural-directive
|
|
62
|
-
form throughout, in which case match the existing file rather than
|
|
63
|
-
mixing both styles in one template.
|
|
64
|
-
- Always give `@for` an explicit `track` expression (the item's own stable
|
|
65
|
-
id, not `$index`, unless the list has no natural identity) — an untracked
|
|
66
|
-
or index-tracked loop over data that reorders forces Angular to
|
|
67
|
-
re-render every row instead of just the ones that changed.
|
|
33
|
+
- Use `@if`, `@for` (with `track`), `@switch` in new templates, not `*ngIf`/`*ngFor`/`*ngSwitch`; in a template that still uses the structural-directive form throughout, match the file.
|
|
34
|
+
- Always give `@for` an explicit `track` on the item's stable id, not `$index`, unless the list has no natural identity.
|
|
68
35
|
|
|
69
36
|
## Naming and typing
|
|
70
37
|
|
|
71
|
-
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
already signals reactivity.
|
|
75
|
-
- Type every `input()`/`output()`/`model()` explicitly
|
|
76
|
-
(`input<Order | null>(null)`) rather than relying on inference from a
|
|
77
|
-
loosely-typed default; an untyped input silently becomes `unknown`/`any`
|
|
78
|
-
at every call site.
|
|
79
|
-
- Avoid `any` in component/service code; when the Angular CLI's generated
|
|
80
|
-
boilerplate produces a loosely-typed value (e.g. a form's raw value),
|
|
81
|
-
narrow it explicitly at the boundary instead of propagating `any`
|
|
82
|
-
through the class.
|
|
38
|
+
- Name a signal for the value it holds (`user`, not `userSignal`).
|
|
39
|
+
- Type every `input()`/`output()`/`model()` explicitly (`input<Order | null>(null)`).
|
|
40
|
+
- Avoid `any` in component/service code; narrow loosely-typed CLI-generated values (a form's raw value) at the boundary.
|
|
@@ -7,78 +7,34 @@ metadata:
|
|
|
7
7
|
|
|
8
8
|
# Angular patterns
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
to this stack.
|
|
10
|
+
Component/service/change-detection design for current Angular, narrowing the
|
|
11
|
+
common architecture rules to this stack.
|
|
13
12
|
|
|
14
13
|
## Change detection
|
|
15
14
|
|
|
16
|
-
- Default new components to `ChangeDetectionStrategy.OnPush`.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
`OnPush` plus signals rarely needs a manual `markForCheck()` at all.
|
|
20
|
-
- If a component still receives data via `@Input()` mutation of a plain
|
|
21
|
-
object (not a signal) under `OnPush`, replace the mutation with a new
|
|
22
|
-
object reference (or migrate the input to a signal) — `OnPush` only
|
|
23
|
-
re-checks on a new reference/signal change, not a mutated property on the
|
|
24
|
-
same object.
|
|
25
|
-
- Reach for `ChangeDetectorRef.markForCheck()` only when a value changes
|
|
26
|
-
outside Angular's own change-detection triggers (a third-party callback,
|
|
27
|
-
a native DOM event Angular didn't bind) and cannot reasonably be modeled
|
|
28
|
-
as a signal — not as a routine fix for "the view didn't update".
|
|
15
|
+
- Default new components to `ChangeDetectionStrategy.OnPush`.
|
|
16
|
+
- Under `OnPush`, replace `@Input()` mutation of a plain object with a new reference, or migrate the input to a signal.
|
|
17
|
+
- Use `ChangeDetectorRef.markForCheck()` only for a value that changes outside Angular's triggers (third-party callback, unbound native DOM event) and cannot be a signal.
|
|
29
18
|
|
|
30
19
|
## Dependency injection and service boundaries
|
|
31
20
|
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
the whole app's lifetime.
|
|
36
|
-
- Keep a component's class focused on view state and event wiring; move
|
|
37
|
-
business logic, HTTP calls, and cross-component state into an injectable
|
|
38
|
-
service. A component `inject()`-ing `HttpClient` directly to build
|
|
39
|
-
request logic inline is a sign that logic belongs in a service instead.
|
|
40
|
-
- Use Angular's `HttpClient` (with `provideHttpClient()` and interceptors
|
|
41
|
-
for cross-cutting concerns like auth headers) rather than a bare `fetch`
|
|
42
|
-
scattered through components — interceptors are the idiomatic place for
|
|
43
|
-
auth/error handling, not per-call boilerplate.
|
|
21
|
+
- `providedIn: 'root'` for app-wide singletons; route `providers` (or a standalone component's `providers`) for per-feature/per-route state.
|
|
22
|
+
- Keep the component class to view state and event wiring; business logic, HTTP calls, and cross-component state go in an injectable service.
|
|
23
|
+
- Use `HttpClient` with `provideHttpClient()` and interceptors (auth headers, error handling), not bare `fetch` in components.
|
|
44
24
|
|
|
45
25
|
## RxJS and signal interop
|
|
46
26
|
|
|
47
|
-
- Prefer `toSignal()`/`toObservable()` (`@angular/core/rxjs-interop`) at
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
subscribing into a plain field.
|
|
51
|
-
- When an `Observable` genuinely needs a manual `.subscribe()` inside a
|
|
52
|
-
component (rare once `async` pipe / `toSignal()` cover the common case),
|
|
53
|
-
pipe through `takeUntilDestroyed()` (call it in an injection context, or
|
|
54
|
-
pass an explicit `DestroyRef`) instead of hand-rolling a `Subject`+
|
|
55
|
-
`ngOnDestroy` teardown.
|
|
56
|
-
- Do not fan a single source Observable out into multiple independent
|
|
57
|
-
`.subscribe()` calls that each re-trigger the source's side effects
|
|
58
|
-
(e.g. a re-fetching HTTP call); share it (`shareReplay`, or convert once
|
|
59
|
-
with `toSignal()`) so the side effect runs once per meaningful change.
|
|
27
|
+
- Prefer `toSignal()`/`toObservable()` (`@angular/core/rxjs-interop`) at the RxJS/signal boundary over manual subscribing into a plain field.
|
|
28
|
+
- A manual `.subscribe()` pipes through `takeUntilDestroyed()` (in an injection context, or with an explicit `DestroyRef`), not a hand-rolled `Subject` + `ngOnDestroy`.
|
|
29
|
+
- Do not fan one source Observable into several `.subscribe()` calls that each re-trigger its side effects; share it (`shareReplay`, or convert once with `toSignal()`).
|
|
60
30
|
|
|
61
31
|
## Forms
|
|
62
32
|
|
|
63
|
-
- Prefer
|
|
64
|
-
|
|
65
|
-
trivial single-field form — typed forms catch a renamed/removed control
|
|
66
|
-
at compile time instead of a silent runtime `undefined`.
|
|
67
|
-
- Validate with Angular's built-in or custom `ValidatorFn`s registered on
|
|
68
|
-
the control, not ad-hoc validation logic scattered through submit-button
|
|
69
|
-
click handlers.
|
|
33
|
+
- Prefer typed Reactive Forms (`FormGroup<{...}>`, `FormControl<T>`) over template-driven forms beyond a trivial single-field form.
|
|
34
|
+
- Validate with built-in or custom `ValidatorFn`s on the control, not in submit handlers.
|
|
70
35
|
|
|
71
36
|
## Anti-patterns
|
|
72
37
|
|
|
73
|
-
- Do not reach into a child
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
declaratively.
|
|
77
|
-
- Do not perform DOM manipulation directly through `ElementRef.nativeElement`
|
|
78
|
-
in ordinary component code — use Angular's `Renderer2`, template
|
|
79
|
-
bindings, or a directive when direct DOM access is genuinely required
|
|
80
|
-
(a third-party widget, focus management); bypassing Angular's rendering
|
|
81
|
-
layer breaks server-side rendering and change-detection assumptions.
|
|
82
|
-
- Do not put HTTP calls or other side effects inside a `computed()` — a
|
|
83
|
-
computed's callback can re-run any number of times and must stay pure;
|
|
84
|
-
side effects belong in `effect()` or an explicit event handler.
|
|
38
|
+
- Do not reach into a child via `ViewChild` when an `input()`/signal binding or `output()` event expresses the interaction.
|
|
39
|
+
- Do not manipulate the DOM through `ElementRef.nativeElement` in ordinary component code; use `Renderer2`, template bindings, or a directive when direct access is required (third-party widget, focus management).
|
|
40
|
+
- Do not put HTTP calls or other side effects inside `computed()`; use `effect()` or an event handler.
|
|
@@ -7,64 +7,26 @@ metadata:
|
|
|
7
7
|
|
|
8
8
|
# Angular security
|
|
9
9
|
|
|
10
|
-
Stack-specific risks on top of the common security rules
|
|
11
|
-
|
|
12
|
-
create an opening.
|
|
10
|
+
Stack-specific risks on top of the common security rules: where Angular's
|
|
11
|
+
sanitization can be bypassed and where DI/routing choices open a hole.
|
|
13
12
|
|
|
14
13
|
## Template injection and sanitization bypass
|
|
15
14
|
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
`bypassSecurityTrustResourceUrl`/`bypassSecurityTrustScript` on
|
|
20
|
-
user-supplied or user-influenced content. Those calls tell Angular "trust
|
|
21
|
-
this value completely, skip sanitization" — reserve them for genuinely
|
|
22
|
-
static, developer-authored content (a hardcoded SVG, a known-safe
|
|
23
|
-
asset URL), never for a value that traces back to user input or an
|
|
24
|
-
external API response.
|
|
25
|
-
- Prefer binding through the normal property/interpolation syntax
|
|
26
|
-
(`{{ value }}`, `[textContent]`) over `[innerHTML]` for user-controlled
|
|
27
|
-
text; if `[innerHTML]` is genuinely required for rich content, sanitize
|
|
28
|
-
server-side or via a vetted sanitizer library rather than trusting
|
|
29
|
-
Angular's default sanitizer alone for anything beyond simple formatting.
|
|
30
|
-
- Never write directly to `ElementRef.nativeElement.innerHTML` — that
|
|
31
|
-
bypasses Angular's sanitizer entirely, unlike the `[innerHTML]` template
|
|
32
|
-
binding which still runs through it.
|
|
15
|
+
- Do not call `DomSanitizer.bypassSecurityTrustHtml`/`bypassSecurityTrustUrl`/`bypassSecurityTrustResourceUrl`/`bypassSecurityTrustScript` on user-influenced content; reserve them for static, developer-authored content (hardcoded SVG, known-safe asset URL), never a value traced to user input or an external API response.
|
|
16
|
+
- Bind user-controlled text with `{{ value }}` or `[textContent]`, not `[innerHTML]`; if `[innerHTML]` is required for rich content, sanitize server-side or with a vetted sanitizer library.
|
|
17
|
+
- Never write to `ElementRef.nativeElement.innerHTML`.
|
|
33
18
|
|
|
34
19
|
## HTTP and CSRF
|
|
35
20
|
|
|
36
|
-
- Send credentials/tokens
|
|
37
|
-
|
|
38
|
-
`Authorization` header at each call site — a missed call site is a
|
|
39
|
-
silent auth gap, not a build error.
|
|
40
|
-
- When the backend uses cookie-based sessions, rely on Angular's built-in
|
|
41
|
-
`XSRF-TOKEN`/`X-XSRF-TOKEN` CSRF handling (`withXsrfConfiguration` /
|
|
42
|
-
the default cookie name) rather than disabling `withCredentials` or
|
|
43
|
-
rolling a custom CSRF header scheme, unless the backend's own CSRF
|
|
44
|
-
contract genuinely requires different header/cookie names — configure
|
|
45
|
-
those, don't drop the protection.
|
|
21
|
+
- Send credentials/tokens through `HttpClient` interceptors (`HttpInterceptorFn` or class-based `HttpInterceptor`), not a hand-appended `Authorization` header at each call site.
|
|
22
|
+
- With cookie-based sessions, use Angular's built-in `XSRF-TOKEN`/`X-XSRF-TOKEN` handling (`withXsrfConfiguration` or the default cookie name); do not disable `withCredentials` or roll a custom CSRF header scheme. If the backend contract needs different names, configure them.
|
|
46
23
|
|
|
47
24
|
## Routing and route guards
|
|
48
25
|
|
|
49
|
-
- Gate
|
|
50
|
-
|
|
51
|
-
state (a token's validity, a role from the authenticated session) — never
|
|
52
|
-
a guard that only checks a client-side flag with no corresponding
|
|
53
|
-
server-side check on the API the route's data comes from.
|
|
54
|
-
- Do not put secrets, API keys, or backend-only credentials into
|
|
55
|
-
environment files (`environment.ts`) that ship in the client bundle —
|
|
56
|
-
anything in `environment.*.ts` is public once built; only put
|
|
57
|
-
publicly-safe configuration (API base URLs, feature flags) there.
|
|
26
|
+
- Gate authenticated/authorized routes with a guard (`CanActivateFn`/`CanMatchFn`) that checks server-verified state (token validity, role from the session), never only a client-side flag.
|
|
27
|
+
- Do not put secrets, API keys, or backend-only credentials in `environment.*.ts`; only publicly-safe configuration (API base URLs, feature flags).
|
|
58
28
|
|
|
59
29
|
## Dependency injection surface
|
|
60
30
|
|
|
61
|
-
- Do not widen a service
|
|
62
|
-
|
|
63
|
-
per-session state — a root-scoped singleton is shared across the whole
|
|
64
|
-
app's lifetime (and across users in SSR), so session-scoped data leaking
|
|
65
|
-
into it is a cross-request data leak, not just a design smell.
|
|
66
|
-
- Validate and narrow data crossing a trust boundary (route params, query
|
|
67
|
-
params, a form's raw value, a third-party postMessage payload) before
|
|
68
|
-
using it in a template binding or passing it to a service call — treat
|
|
69
|
-
router/query-string values as untrusted input, not as pre-validated
|
|
70
|
-
application state.
|
|
31
|
+
- Do not widen a service holding per-user or per-session state to `providedIn: 'root'` to work around an injection error (cross-request leak in SSR).
|
|
32
|
+
- Validate and narrow data crossing a trust boundary (route params, query params, a form's raw value, a `postMessage` payload) before using it in a template binding or service call.
|