forgecraft-mcp 1.2.0 → 1.3.2

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 (136) hide show
  1. package/README.md +525 -525
  2. package/dist/cli/help.js +44 -44
  3. package/dist/registry/renderer-skeletons.js +92 -92
  4. package/dist/shared/gs-score-logger.js +6 -6
  5. package/dist/tools/add-module.js +123 -123
  6. package/dist/tools/advice-registry.js +18 -18
  7. package/dist/tools/check-cascade-report.js +64 -64
  8. package/dist/tools/configure-mcp.d.ts +3 -0
  9. package/dist/tools/configure-mcp.d.ts.map +1 -1
  10. package/dist/tools/configure-mcp.js +10 -0
  11. package/dist/tools/configure-mcp.js.map +1 -1
  12. package/dist/tools/forgecraft-dispatch.d.ts.map +1 -1
  13. package/dist/tools/forgecraft-dispatch.js +3 -0
  14. package/dist/tools/forgecraft-dispatch.js.map +1 -1
  15. package/dist/tools/forgecraft-schema-params.d.ts +9 -0
  16. package/dist/tools/forgecraft-schema-params.d.ts.map +1 -1
  17. package/dist/tools/forgecraft-schema-params.js +21 -0
  18. package/dist/tools/forgecraft-schema-params.js.map +1 -1
  19. package/dist/tools/forgecraft-schema.d.ts +9 -0
  20. package/dist/tools/forgecraft-schema.d.ts.map +1 -1
  21. package/dist/tools/refresh-output.js +14 -14
  22. package/dist/tools/scaffold-spec-stubs.js +115 -115
  23. package/dist/tools/scaffold-templates.js +62 -62
  24. package/dist/tools/setup-artifact-writers.d.ts +30 -0
  25. package/dist/tools/setup-artifact-writers.d.ts.map +1 -1
  26. package/dist/tools/setup-artifact-writers.js +120 -8
  27. package/dist/tools/setup-artifact-writers.js.map +1 -1
  28. package/dist/tools/setup-phase1.d.ts +3 -0
  29. package/dist/tools/setup-phase1.d.ts.map +1 -1
  30. package/dist/tools/setup-phase1.js +79 -35
  31. package/dist/tools/setup-phase1.js.map +1 -1
  32. package/dist/tools/setup-phase2.d.ts +2 -0
  33. package/dist/tools/setup-phase2.d.ts.map +1 -1
  34. package/dist/tools/setup-phase2.js +10 -1
  35. package/dist/tools/setup-phase2.js.map +1 -1
  36. package/dist/tools/setup-project.d.ts +18 -0
  37. package/dist/tools/setup-project.d.ts.map +1 -1
  38. package/dist/tools/setup-project.js +77 -1
  39. package/dist/tools/setup-project.js.map +1 -1
  40. package/dist/tools/spec-parser-tags.d.ts +9 -0
  41. package/dist/tools/spec-parser-tags.d.ts.map +1 -1
  42. package/dist/tools/spec-parser-tags.js +92 -0
  43. package/dist/tools/spec-parser-tags.js.map +1 -1
  44. package/package.json +89 -86
  45. package/templates/analytics/instructions.yaml +37 -37
  46. package/templates/analytics/mcp-servers.yaml +11 -11
  47. package/templates/analytics/structure.yaml +25 -25
  48. package/templates/api/instructions.yaml +231 -231
  49. package/templates/api/mcp-servers.yaml +22 -13
  50. package/templates/api/nfr.yaml +23 -23
  51. package/templates/api/review.yaml +103 -103
  52. package/templates/api/structure.yaml +34 -34
  53. package/templates/api/verification.yaml +132 -132
  54. package/templates/cli/instructions.yaml +31 -31
  55. package/templates/cli/mcp-servers.yaml +11 -11
  56. package/templates/cli/review.yaml +53 -53
  57. package/templates/cli/structure.yaml +16 -16
  58. package/templates/data-lineage/instructions.yaml +28 -28
  59. package/templates/data-lineage/mcp-servers.yaml +22 -22
  60. package/templates/data-pipeline/instructions.yaml +84 -84
  61. package/templates/data-pipeline/mcp-servers.yaml +13 -13
  62. package/templates/data-pipeline/nfr.yaml +39 -39
  63. package/templates/data-pipeline/structure.yaml +23 -23
  64. package/templates/fintech/hooks.yaml +55 -55
  65. package/templates/fintech/instructions.yaml +112 -112
  66. package/templates/fintech/mcp-servers.yaml +13 -13
  67. package/templates/fintech/nfr.yaml +46 -46
  68. package/templates/fintech/playbook.yaml +210 -210
  69. package/templates/fintech/verification.yaml +239 -239
  70. package/templates/game/instructions.yaml +289 -289
  71. package/templates/game/mcp-servers.yaml +38 -38
  72. package/templates/game/nfr.yaml +64 -64
  73. package/templates/game/playbook.yaml +214 -214
  74. package/templates/game/review.yaml +97 -97
  75. package/templates/game/structure.yaml +67 -67
  76. package/templates/game/verification.yaml +174 -174
  77. package/templates/healthcare/instructions.yaml +42 -42
  78. package/templates/healthcare/mcp-servers.yaml +13 -13
  79. package/templates/healthcare/nfr.yaml +47 -47
  80. package/templates/hipaa/instructions.yaml +41 -41
  81. package/templates/hipaa/mcp-servers.yaml +13 -13
  82. package/templates/infra/instructions.yaml +104 -104
  83. package/templates/infra/mcp-servers.yaml +20 -20
  84. package/templates/infra/nfr.yaml +46 -46
  85. package/templates/infra/review.yaml +65 -65
  86. package/templates/infra/structure.yaml +25 -25
  87. package/templates/library/instructions.yaml +36 -36
  88. package/templates/library/mcp-servers.yaml +20 -20
  89. package/templates/library/review.yaml +56 -56
  90. package/templates/library/structure.yaml +19 -19
  91. package/templates/medallion-architecture/instructions.yaml +41 -41
  92. package/templates/medallion-architecture/mcp-servers.yaml +22 -22
  93. package/templates/ml/instructions.yaml +85 -85
  94. package/templates/ml/mcp-servers.yaml +11 -11
  95. package/templates/ml/nfr.yaml +39 -39
  96. package/templates/ml/structure.yaml +25 -25
  97. package/templates/ml/verification.yaml +156 -156
  98. package/templates/mobile/instructions.yaml +44 -44
  99. package/templates/mobile/mcp-servers.yaml +11 -11
  100. package/templates/mobile/nfr.yaml +49 -49
  101. package/templates/mobile/structure.yaml +27 -27
  102. package/templates/mobile/verification.yaml +121 -121
  103. package/templates/observability-xray/instructions.yaml +40 -40
  104. package/templates/observability-xray/mcp-servers.yaml +15 -15
  105. package/templates/realtime/instructions.yaml +42 -42
  106. package/templates/realtime/mcp-servers.yaml +13 -13
  107. package/templates/soc2/instructions.yaml +41 -41
  108. package/templates/soc2/mcp-servers.yaml +24 -24
  109. package/templates/social/instructions.yaml +43 -43
  110. package/templates/social/mcp-servers.yaml +24 -24
  111. package/templates/state-machine/instructions.yaml +42 -42
  112. package/templates/state-machine/mcp-servers.yaml +11 -11
  113. package/templates/tools-registry.yaml +164 -164
  114. package/templates/universal/hooks.yaml +531 -531
  115. package/templates/universal/instructions.yaml +1692 -1692
  116. package/templates/universal/mcp-servers.yaml +50 -50
  117. package/templates/universal/nfr.yaml +197 -197
  118. package/templates/universal/reference.yaml +326 -326
  119. package/templates/universal/review.yaml +204 -204
  120. package/templates/universal/skills.yaml +262 -262
  121. package/templates/universal/structure.yaml +67 -67
  122. package/templates/universal/verification.yaml +416 -416
  123. package/templates/web-react/hooks.yaml +44 -44
  124. package/templates/web-react/instructions.yaml +207 -207
  125. package/templates/web-react/mcp-servers.yaml +20 -20
  126. package/templates/web-react/nfr.yaml +27 -27
  127. package/templates/web-react/review.yaml +94 -94
  128. package/templates/web-react/structure.yaml +46 -46
  129. package/templates/web-react/verification.yaml +126 -126
  130. package/templates/web-static/instructions.yaml +115 -115
  131. package/templates/web-static/mcp-servers.yaml +20 -20
  132. package/templates/web3/instructions.yaml +44 -44
  133. package/templates/web3/mcp-servers.yaml +11 -11
  134. package/templates/web3/verification.yaml +159 -159
  135. package/templates/zero-trust/instructions.yaml +41 -41
  136. package/templates/zero-trust/mcp-servers.yaml +15 -15
@@ -1,44 +1,44 @@
1
- tag: WEB-REACT
2
- section: hooks
3
- hooks:
4
- - name: i18n-enforcement
5
- trigger: pre-commit
6
- description: "Scan JSX/TSX for hardcoded user-facing strings not wrapped in t()"
7
- filename: pre-commit-i18n.sh
8
- script: |
9
- #!/bin/bash
10
- STAGED=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(tsx|jsx)$')
11
- if [ -z "$STAGED" ]; then exit 0; fi
12
- VIOLATIONS=0
13
- for file in $STAGED; do
14
- # Find string literals in JSX that aren't in t() calls, className, data-testid, etc.
15
- if grep -nE '>\s*[A-Z][a-z]+(\s+[a-z]+)+\s*<' "$file" | grep -vE '(className|data-testid|aria-|console\.)' > /tmp/i18n_violations 2>/dev/null; then
16
- if [ -s /tmp/i18n_violations ]; then
17
- echo " ⚠️ $file — possible untranslated string:"
18
- cat /tmp/i18n_violations | head -3
19
- VIOLATIONS=$((VIOLATIONS + 1))
20
- fi
21
- fi
22
- done
23
- rm -f /tmp/i18n_violations
24
- if [ $VIOLATIONS -gt 0 ]; then
25
- echo "⚠️ $VIOLATIONS file(s) may have untranslated strings. Use t() wrapper."
26
- fi
27
-
28
- - name: a11y-lint
29
- trigger: pre-commit
30
- description: "Run accessibility checks on staged JSX/TSX files"
31
- filename: pre-commit-a11y.sh
32
- script: |
33
- #!/bin/bash
34
- STAGED=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(tsx|jsx)$')
35
- if [ -z "$STAGED" ]; then exit 0; fi
36
- # Check for div used as button without role
37
- for file in $STAGED; do
38
- if grep -nE '<div\s+onClick' "$file" | grep -v 'role=' > /tmp/a11y_violations 2>/dev/null; then
39
- if [ -s /tmp/a11y_violations ]; then
40
- echo " ⚠️ $file — clickable div without role attribute. Use <button> or add role=\"button\""
41
- fi
42
- fi
43
- done
44
- rm -f /tmp/a11y_violations
1
+ tag: WEB-REACT
2
+ section: hooks
3
+ hooks:
4
+ - name: i18n-enforcement
5
+ trigger: pre-commit
6
+ description: "Scan JSX/TSX for hardcoded user-facing strings not wrapped in t()"
7
+ filename: pre-commit-i18n.sh
8
+ script: |
9
+ #!/bin/bash
10
+ STAGED=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(tsx|jsx)$')
11
+ if [ -z "$STAGED" ]; then exit 0; fi
12
+ VIOLATIONS=0
13
+ for file in $STAGED; do
14
+ # Find string literals in JSX that aren't in t() calls, className, data-testid, etc.
15
+ if grep -nE '>\s*[A-Z][a-z]+(\s+[a-z]+)+\s*<' "$file" | grep -vE '(className|data-testid|aria-|console\.)' > /tmp/i18n_violations 2>/dev/null; then
16
+ if [ -s /tmp/i18n_violations ]; then
17
+ echo " ⚠️ $file — possible untranslated string:"
18
+ cat /tmp/i18n_violations | head -3
19
+ VIOLATIONS=$((VIOLATIONS + 1))
20
+ fi
21
+ fi
22
+ done
23
+ rm -f /tmp/i18n_violations
24
+ if [ $VIOLATIONS -gt 0 ]; then
25
+ echo "⚠️ $VIOLATIONS file(s) may have untranslated strings. Use t() wrapper."
26
+ fi
27
+
28
+ - name: a11y-lint
29
+ trigger: pre-commit
30
+ description: "Run accessibility checks on staged JSX/TSX files"
31
+ filename: pre-commit-a11y.sh
32
+ script: |
33
+ #!/bin/bash
34
+ STAGED=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(tsx|jsx)$')
35
+ if [ -z "$STAGED" ]; then exit 0; fi
36
+ # Check for div used as button without role
37
+ for file in $STAGED; do
38
+ if grep -nE '<div\s+onClick' "$file" | grep -v 'role=' > /tmp/a11y_violations 2>/dev/null; then
39
+ if [ -s /tmp/a11y_violations ]; then
40
+ echo " ⚠️ $file — clickable div without role attribute. Use <button> or add role=\"button\""
41
+ fi
42
+ fi
43
+ done
44
+ rm -f /tmp/a11y_violations
@@ -1,207 +1,207 @@
1
- tag: WEB-REACT
2
- section: instructions
3
- blocks:
4
- - id: react-component-architecture
5
- tier: recommended
6
- title: "React Component Architecture"
7
- content: |
8
- ## React & Frontend Standards
9
-
10
- ### Component Architecture
11
- - Atomic Design: atoms → molecules → organisms → templates → pages.
12
- - Components are pure UI. No API calls, no business logic, no direct state management.
13
- - Container/Presenter split: containers fetch data, presenters render UI.
14
- - All components must have TypeScript props interfaces. No `any` types.
15
- - No inline styles. Use CSS modules, Tailwind, or styled-components consistently.
16
-
17
- - id: react-state-management
18
- tier: recommended
19
- title: "State Management"
20
- content: |
21
- ### State Management
22
- - Local state (useState) for UI-only state (open/closed, hover, form inputs).
23
- - Shared state via context or state library ONLY when 3+ components need the same data.
24
- - Server state via React Query / TanStack Query / SWR — NEVER manually cache API responses.
25
- - No prop drilling beyond 2 levels. Use composition (children) or context.
26
-
27
- - id: react-i18n
28
- tier: recommended
29
- title: "Internationalization (i18n)"
30
- content: |
31
- ### Internationalization — From Day One
32
- - EVERY user-facing string goes through the i18n system. No hardcoded display text.
33
- - Use react-i18next or next-intl.
34
- - Translation keys namespaced by feature: `members.table.header.name`.
35
- - Date, number, currency formatting via Intl API — never manual formatting.
36
-
37
- - id: react-forms
38
- tier: recommended
39
- title: "Forms"
40
- content: |
41
- ### Forms
42
- - Use a form library (React Hook Form or Formik). No manual onChange handlers per field.
43
- - Validation schema defined separately (Zod, Yup) and shared with backend if possible.
44
- - All forms must handle: loading state, validation errors, submission errors, success feedback.
45
-
46
- - id: react-api-integration
47
- tier: recommended
48
- title: "API Integration"
49
- content: |
50
- ### API Integration
51
- - All API calls go through a centralized API client module.
52
- - API client handles: auth headers, base URL from config, error transformation, retry logic.
53
- - Use React Query for all server state.
54
-
55
- - id: react-accessibility
56
- tier: recommended
57
- title: "Accessibility (a11y)"
58
- content: |
59
- ### Accessibility (a11y) — Non-Negotiable
60
- - Semantic HTML elements (nav, main, section, article, button — not div for everything).
61
- - All interactive elements keyboard-accessible. All images have alt text.
62
- - ARIA labels on non-obvious interactive elements.
63
- - Color contrast minimum AA (4.5:1 for text).
64
-
65
- - id: react-error-boundaries
66
- tier: recommended
67
- title: "Error Handling & Suspense"
68
- content: |
69
- ### Error Boundaries
70
- - Wrap feature areas in Error Boundaries — a crash in one widget must not take down the page.
71
- - Error boundaries display user-friendly fallback UI with retry action.
72
- - Log caught errors to monitoring service (Sentry, DataDog, etc.).
73
- - Never catch errors silently — always report and show feedback.
74
-
75
- ### Suspense & Loading States
76
- - Use React Suspense for code-split components and async data.
77
- - Every async operation has three states: loading, success, error. No blank screens.
78
- - Skeleton loaders preferred over spinners for layout stability (reduces CLS).
79
- - Optimistic updates for user-driven mutations (like/unlike, form submit).
80
-
81
- - id: react-deployment
82
- tier: recommended
83
- title: "React Deployment & Hosting"
84
- content: |
85
- ## Frontend Deployment
86
-
87
- ### Platform Selection
88
- - **Vercel**: First choice for Next.js. Zero-config deploys, edge functions, image optimization built in.
89
- ISR / on-demand revalidation works natively. Preview deployments on every PR.
90
- - **Netlify**: Great for static + serverless. Form handling, edge functions, split testing built in.
91
- Works well with Gatsby, Astro, plain React (via adapter).
92
- - **Cloudflare Pages**: Unlimited bandwidth, global edge. Best for static or Pages Functions.
93
- - **AWS Amplify / S3+CloudFront**: Full control, lower cost at scale. More ops overhead.
94
- - Self-hosted Docker: only when platform restrictions require it.
95
-
96
- ### Build & Deploy
97
- - CI builds produce a static bundle (`dist/` or `.next/`). Same bundle deploys to staging then prod.
98
- - Preview deployments for every PR — URL posted in PR comments for stakeholder review.
99
- - Environment variables injected at build time (`NEXT_PUBLIC_*`, `VITE_*`). No secrets in client bundles.
100
- - Build cache enabled (Turborepo, Nx, or platform-native). Target < 2 min builds.
101
-
102
- ### Performance Budgets
103
- - JavaScript budget: < {{js_budget_kb | default: 200}} KB compressed for initial load.
104
- - Lighthouse CI in pipeline. Fail build if performance score drops below {{lighthouse_min | default: 90}}.
105
- - Monitor Core Web Vitals in production (Vercel Analytics, web-vitals library, or RUM).
106
-
107
- ### Edge & CDN
108
- - Static assets served from CDN with immutable cache headers (content-hashed filenames).
109
- - HTML entry point: short cache (5 min) or stale-while-revalidate.
110
- - Use edge middleware for: redirects, A/B testing, geo-routing, auth checks (avoid full round-trip).
111
-
112
- - id: web-react-testing
113
- tier: recommended
114
- title: "React-Specific Testing Patterns"
115
- content: |
116
- ## React-Specific Testing Patterns
117
-
118
- ### Component-Level Visual Regression
119
- - Run every Storybook story through Chromatic or Percy on each PR.
120
- - Stories are the visual spec. A story without at least one state variant per meaningful prop combination is incomplete.
121
- - Snapshot diff threshold: 0% pixel change for exact-match surfaces; configure per-story for components with intentional animation or dynamic content.
122
-
123
- ### Interaction Testing (Testing Library)
124
- - Use `@testing-library/user-event` over `fireEvent`. It simulates real browser input sequences (focus, keydown, keyup, input, change) rather than synthetic events.
125
- - Test behavior, not implementation: assert what the user sees, not which internal functions were called.
126
- - Never assert on component internals — class names, internal state, refs — unless they are the public contract.
127
- - `getByRole` and `getByLabelText` are the correct primary queries. `getByTestId` is the last resort.
128
-
129
- ### Expose-Store-to-Window (Playwright / E2E Layer)
130
- For React applications with a shared state store (Redux, Zustand, Context-based stores), expose
131
- the store to `window` in the test environment:
132
- ```typescript
133
- // In store initialization
134
- if (process.env.NODE_ENV === 'test' || import.meta.env.VITEST) {
135
- (window as any).__store = store;
136
- }
137
- ```
138
- Playwright tests can then assert both what the screen renders AND what the application's store
139
- believes is true — independently. This catches the failure class where UI renders correctly but
140
- internal state is corrupted: optimistic updates that corrupt on failure, form state that looks
141
- submitted but is not saved, filters that render active but have no effect on query state.
142
-
143
- ### Vertical Chain Test (Critical Flows)
144
- For flows that cross more than one architectural boundary (UI → service → persistence), write
145
- one Playwright test that follows the full chain:
146
- 1. User action (click, form submit)
147
- 2. Intercept or query the API layer response (`page.waitForResponse`)
148
- 3. Assert store state via `window.__store`
149
- 4. Assert rendered UI outcome
150
- 5. If the flow persists data: assert the database or backend state via a test API endpoint
151
-
152
- This is not a unit test and not a happy-path flow test. It is a chain verification — one trigger,
153
- every boundary inspected. Specify in the architectural constitution which flows receive this
154
- treatment. Minimum: authentication flow, primary write operation, and any multi-step wizard.
155
-
156
- ### Accessibility at Component Level
157
- - Run `axe-core` in every Storybook story via `@storybook/addon-a11y`. Violations block story acceptance.
158
- - Run `axe` at the page level in Playwright E2E suite on every route.
159
- - Add `aria-label`, `aria-describedby`, and `role` to every interactive component that is not a native HTML element. Accessibility is not a feature — it is a correctness criterion.
160
- - Keyboard navigation: every interactive element must be reachable and operable via keyboard alone. Test tab order in E2E suite for critical flows.
161
-
162
- - id: web-react-smoke-testing
163
- tier: recommended
164
- title: "React App Smoke Testing (Post-Deploy)"
165
- content: |
166
- ## React App Smoke Testing
167
-
168
- ### Required: Playwright Full Browser
169
- Tag all smoke tests `@smoke` for isolated execution:
170
- ```
171
- npx playwright test --config playwright.smoke.config.ts --grep @smoke
172
- ```
173
-
174
- Minimum smoke suite for every React app:
175
- - **Page loads**: all key routes render, document title present, no console errors
176
- - **Auth wall**: protected route redirects unauthenticated user to login page
177
- - **Core journey**: primary user action (sign-in or key feature) completes end-to-end
178
- - **a11y baseline**: no critical axe violations on the landing route
179
-
180
- ```typescript
181
- // tests/smoke/app.smoke.ts
182
- import { test, expect } from '@playwright/test';
183
- import AxeBuilder from '@axe-core/playwright';
184
-
185
- test('@smoke home page loads without errors', async ({ page }) => {
186
- const errors: string[] = [];
187
- page.on('console', m => { if (m.type() === 'error') errors.push(m.text()); });
188
- await page.goto('/');
189
- expect(await page.title()).not.toBe('');
190
- expect(errors.filter(e => !e.includes('DevTools'))).toHaveLength(0);
191
- });
192
-
193
- test('@smoke protected route redirects unauthenticated', async ({ page }) => {
194
- await page.goto('/dashboard');
195
- await expect(page).toHaveURL(/login/);
196
- });
197
-
198
- test('@smoke no critical a11y violations on home', async ({ page }) => {
199
- await page.goto('/');
200
- const results = await new AxeBuilder({ page }).analyze();
201
- const critical = results.violations.filter(v => v.impact === 'critical');
202
- expect(critical).toHaveLength(0);
203
- });
204
- ```
205
-
206
- Use `retries: 1` in smoke config — one retry before calling a failure. Smoke failure
207
- means the deploy is broken, not the test.
1
+ tag: WEB-REACT
2
+ section: instructions
3
+ blocks:
4
+ - id: react-component-architecture
5
+ tier: recommended
6
+ title: "React Component Architecture"
7
+ content: |
8
+ ## React & Frontend Standards
9
+
10
+ ### Component Architecture
11
+ - Atomic Design: atoms → molecules → organisms → templates → pages.
12
+ - Components are pure UI. No API calls, no business logic, no direct state management.
13
+ - Container/Presenter split: containers fetch data, presenters render UI.
14
+ - All components must have TypeScript props interfaces. No `any` types.
15
+ - No inline styles. Use CSS modules, Tailwind, or styled-components consistently.
16
+
17
+ - id: react-state-management
18
+ tier: recommended
19
+ title: "State Management"
20
+ content: |
21
+ ### State Management
22
+ - Local state (useState) for UI-only state (open/closed, hover, form inputs).
23
+ - Shared state via context or state library ONLY when 3+ components need the same data.
24
+ - Server state via React Query / TanStack Query / SWR — NEVER manually cache API responses.
25
+ - No prop drilling beyond 2 levels. Use composition (children) or context.
26
+
27
+ - id: react-i18n
28
+ tier: recommended
29
+ title: "Internationalization (i18n)"
30
+ content: |
31
+ ### Internationalization — From Day One
32
+ - EVERY user-facing string goes through the i18n system. No hardcoded display text.
33
+ - Use react-i18next or next-intl.
34
+ - Translation keys namespaced by feature: `members.table.header.name`.
35
+ - Date, number, currency formatting via Intl API — never manual formatting.
36
+
37
+ - id: react-forms
38
+ tier: recommended
39
+ title: "Forms"
40
+ content: |
41
+ ### Forms
42
+ - Use a form library (React Hook Form or Formik). No manual onChange handlers per field.
43
+ - Validation schema defined separately (Zod, Yup) and shared with backend if possible.
44
+ - All forms must handle: loading state, validation errors, submission errors, success feedback.
45
+
46
+ - id: react-api-integration
47
+ tier: recommended
48
+ title: "API Integration"
49
+ content: |
50
+ ### API Integration
51
+ - All API calls go through a centralized API client module.
52
+ - API client handles: auth headers, base URL from config, error transformation, retry logic.
53
+ - Use React Query for all server state.
54
+
55
+ - id: react-accessibility
56
+ tier: recommended
57
+ title: "Accessibility (a11y)"
58
+ content: |
59
+ ### Accessibility (a11y) — Non-Negotiable
60
+ - Semantic HTML elements (nav, main, section, article, button — not div for everything).
61
+ - All interactive elements keyboard-accessible. All images have alt text.
62
+ - ARIA labels on non-obvious interactive elements.
63
+ - Color contrast minimum AA (4.5:1 for text).
64
+
65
+ - id: react-error-boundaries
66
+ tier: recommended
67
+ title: "Error Handling & Suspense"
68
+ content: |
69
+ ### Error Boundaries
70
+ - Wrap feature areas in Error Boundaries — a crash in one widget must not take down the page.
71
+ - Error boundaries display user-friendly fallback UI with retry action.
72
+ - Log caught errors to monitoring service (Sentry, DataDog, etc.).
73
+ - Never catch errors silently — always report and show feedback.
74
+
75
+ ### Suspense & Loading States
76
+ - Use React Suspense for code-split components and async data.
77
+ - Every async operation has three states: loading, success, error. No blank screens.
78
+ - Skeleton loaders preferred over spinners for layout stability (reduces CLS).
79
+ - Optimistic updates for user-driven mutations (like/unlike, form submit).
80
+
81
+ - id: react-deployment
82
+ tier: recommended
83
+ title: "React Deployment & Hosting"
84
+ content: |
85
+ ## Frontend Deployment
86
+
87
+ ### Platform Selection
88
+ - **Vercel**: First choice for Next.js. Zero-config deploys, edge functions, image optimization built in.
89
+ ISR / on-demand revalidation works natively. Preview deployments on every PR.
90
+ - **Netlify**: Great for static + serverless. Form handling, edge functions, split testing built in.
91
+ Works well with Gatsby, Astro, plain React (via adapter).
92
+ - **Cloudflare Pages**: Unlimited bandwidth, global edge. Best for static or Pages Functions.
93
+ - **AWS Amplify / S3+CloudFront**: Full control, lower cost at scale. More ops overhead.
94
+ - Self-hosted Docker: only when platform restrictions require it.
95
+
96
+ ### Build & Deploy
97
+ - CI builds produce a static bundle (`dist/` or `.next/`). Same bundle deploys to staging then prod.
98
+ - Preview deployments for every PR — URL posted in PR comments for stakeholder review.
99
+ - Environment variables injected at build time (`NEXT_PUBLIC_*`, `VITE_*`). No secrets in client bundles.
100
+ - Build cache enabled (Turborepo, Nx, or platform-native). Target < 2 min builds.
101
+
102
+ ### Performance Budgets
103
+ - JavaScript budget: < {{js_budget_kb | default: 200}} KB compressed for initial load.
104
+ - Lighthouse CI in pipeline. Fail build if performance score drops below {{lighthouse_min | default: 90}}.
105
+ - Monitor Core Web Vitals in production (Vercel Analytics, web-vitals library, or RUM).
106
+
107
+ ### Edge & CDN
108
+ - Static assets served from CDN with immutable cache headers (content-hashed filenames).
109
+ - HTML entry point: short cache (5 min) or stale-while-revalidate.
110
+ - Use edge middleware for: redirects, A/B testing, geo-routing, auth checks (avoid full round-trip).
111
+
112
+ - id: web-react-testing
113
+ tier: recommended
114
+ title: "React-Specific Testing Patterns"
115
+ content: |
116
+ ## React-Specific Testing Patterns
117
+
118
+ ### Component-Level Visual Regression
119
+ - Run every Storybook story through Chromatic or Percy on each PR.
120
+ - Stories are the visual spec. A story without at least one state variant per meaningful prop combination is incomplete.
121
+ - Snapshot diff threshold: 0% pixel change for exact-match surfaces; configure per-story for components with intentional animation or dynamic content.
122
+
123
+ ### Interaction Testing (Testing Library)
124
+ - Use `@testing-library/user-event` over `fireEvent`. It simulates real browser input sequences (focus, keydown, keyup, input, change) rather than synthetic events.
125
+ - Test behavior, not implementation: assert what the user sees, not which internal functions were called.
126
+ - Never assert on component internals — class names, internal state, refs — unless they are the public contract.
127
+ - `getByRole` and `getByLabelText` are the correct primary queries. `getByTestId` is the last resort.
128
+
129
+ ### Expose-Store-to-Window (Playwright / E2E Layer)
130
+ For React applications with a shared state store (Redux, Zustand, Context-based stores), expose
131
+ the store to `window` in the test environment:
132
+ ```typescript
133
+ // In store initialization
134
+ if (process.env.NODE_ENV === 'test' || import.meta.env.VITEST) {
135
+ (window as any).__store = store;
136
+ }
137
+ ```
138
+ Playwright tests can then assert both what the screen renders AND what the application's store
139
+ believes is true — independently. This catches the failure class where UI renders correctly but
140
+ internal state is corrupted: optimistic updates that corrupt on failure, form state that looks
141
+ submitted but is not saved, filters that render active but have no effect on query state.
142
+
143
+ ### Vertical Chain Test (Critical Flows)
144
+ For flows that cross more than one architectural boundary (UI → service → persistence), write
145
+ one Playwright test that follows the full chain:
146
+ 1. User action (click, form submit)
147
+ 2. Intercept or query the API layer response (`page.waitForResponse`)
148
+ 3. Assert store state via `window.__store`
149
+ 4. Assert rendered UI outcome
150
+ 5. If the flow persists data: assert the database or backend state via a test API endpoint
151
+
152
+ This is not a unit test and not a happy-path flow test. It is a chain verification — one trigger,
153
+ every boundary inspected. Specify in the architectural constitution which flows receive this
154
+ treatment. Minimum: authentication flow, primary write operation, and any multi-step wizard.
155
+
156
+ ### Accessibility at Component Level
157
+ - Run `axe-core` in every Storybook story via `@storybook/addon-a11y`. Violations block story acceptance.
158
+ - Run `axe` at the page level in Playwright E2E suite on every route.
159
+ - Add `aria-label`, `aria-describedby`, and `role` to every interactive component that is not a native HTML element. Accessibility is not a feature — it is a correctness criterion.
160
+ - Keyboard navigation: every interactive element must be reachable and operable via keyboard alone. Test tab order in E2E suite for critical flows.
161
+
162
+ - id: web-react-smoke-testing
163
+ tier: recommended
164
+ title: "React App Smoke Testing (Post-Deploy)"
165
+ content: |
166
+ ## React App Smoke Testing
167
+
168
+ ### Required: Playwright Full Browser
169
+ Tag all smoke tests `@smoke` for isolated execution:
170
+ ```
171
+ npx playwright test --config playwright.smoke.config.ts --grep @smoke
172
+ ```
173
+
174
+ Minimum smoke suite for every React app:
175
+ - **Page loads**: all key routes render, document title present, no console errors
176
+ - **Auth wall**: protected route redirects unauthenticated user to login page
177
+ - **Core journey**: primary user action (sign-in or key feature) completes end-to-end
178
+ - **a11y baseline**: no critical axe violations on the landing route
179
+
180
+ ```typescript
181
+ // tests/smoke/app.smoke.ts
182
+ import { test, expect } from '@playwright/test';
183
+ import AxeBuilder from '@axe-core/playwright';
184
+
185
+ test('@smoke home page loads without errors', async ({ page }) => {
186
+ const errors: string[] = [];
187
+ page.on('console', m => { if (m.type() === 'error') errors.push(m.text()); });
188
+ await page.goto('/');
189
+ expect(await page.title()).not.toBe('');
190
+ expect(errors.filter(e => !e.includes('DevTools'))).toHaveLength(0);
191
+ });
192
+
193
+ test('@smoke protected route redirects unauthenticated', async ({ page }) => {
194
+ await page.goto('/dashboard');
195
+ await expect(page).toHaveURL(/login/);
196
+ });
197
+
198
+ test('@smoke no critical a11y violations on home', async ({ page }) => {
199
+ await page.goto('/');
200
+ const results = await new AxeBuilder({ page }).analyze();
201
+ const critical = results.violations.filter(v => v.impact === 'critical');
202
+ expect(critical).toHaveLength(0);
203
+ });
204
+ ```
205
+
206
+ Use `retries: 1` in smoke config — one retry before calling a failure. Smoke failure
207
+ means the deploy is broken, not the test.
@@ -1,20 +1,20 @@
1
- tag: WEB-REACT
2
- section: mcp-servers
3
- servers:
4
- - name: chrome-devtools
5
- description: "Chrome DevTools integration for debugging, profiling, and network inspection"
6
- command: npx
7
- args: ["-y", "@anthropic/chrome-devtools-mcp@latest"]
8
- tags: [WEB-REACT, WEB-STATIC, ANALYTICS]
9
- category: devtools
10
- tier: recommended
11
- url: "https://github.com/anthropics/anthropic-quickstarts/tree/main/chrome-devtools-mcp"
12
-
13
- - name: playwright
14
- description: "Browser automation for E2E testing, screenshots, and web scraping"
15
- command: npx
16
- args: ["-y", "@anthropic/mcp-server-playwright"]
17
- tags: [WEB-REACT, WEB-STATIC]
18
- category: testing
19
- tier: recommended
20
- url: "https://github.com/anthropics/anthropic-quickstarts/tree/main/mcp-server-playwright"
1
+ tag: WEB-REACT
2
+ section: mcp-servers
3
+ servers:
4
+ - name: chrome-devtools
5
+ description: "Chrome DevTools integration for debugging, profiling, and network inspection"
6
+ command: npx
7
+ args: ["-y", "@anthropic/chrome-devtools-mcp@latest"]
8
+ tags: [WEB-REACT, WEB-STATIC, ANALYTICS]
9
+ category: devtools
10
+ tier: recommended
11
+ url: "https://github.com/anthropics/anthropic-quickstarts/tree/main/chrome-devtools-mcp"
12
+
13
+ - name: playwright
14
+ description: "Browser automation for E2E testing, screenshots, and web scraping"
15
+ command: npx
16
+ args: ["-y", "@anthropic/mcp-server-playwright"]
17
+ tags: [WEB-REACT, WEB-STATIC]
18
+ category: testing
19
+ tier: recommended
20
+ url: "https://github.com/anthropics/anthropic-quickstarts/tree/main/mcp-server-playwright"
@@ -1,27 +1,27 @@
1
- tag: WEB-REACT
2
- section: nfr
3
- blocks:
4
- - id: frontend-performance
5
- tier: recommended
6
- title: "Frontend Performance"
7
- content: |
8
- ## NFR: Frontend Performance
9
-
10
- ### Core Web Vitals Targets
11
- - LCP (Largest Contentful Paint): < 2.5s
12
- - FID (First Input Delay): < 100ms
13
- - CLS (Cumulative Layout Shift): < 0.1
14
-
15
- ### Bundle
16
- - Code splitting by route. No single bundle > 200KB gzipped.
17
- - Tree shaking enabled. No unused exports.
18
- - Bundle size tracked in CI — PRs that increase bundle > 10KB require justification.
19
-
20
- ### Runtime
21
- - Virtual/windowed lists for collections > 50 items.
22
- - Debounce search inputs (300ms minimum).
23
-
24
- ### Assets
25
- - Images in modern formats (WebP/AVIF with fallback).
26
- - Responsive images with srcset.
27
- - Fonts preloaded, display:swap.
1
+ tag: WEB-REACT
2
+ section: nfr
3
+ blocks:
4
+ - id: frontend-performance
5
+ tier: recommended
6
+ title: "Frontend Performance"
7
+ content: |
8
+ ## NFR: Frontend Performance
9
+
10
+ ### Core Web Vitals Targets
11
+ - LCP (Largest Contentful Paint): < 2.5s
12
+ - FID (First Input Delay): < 100ms
13
+ - CLS (Cumulative Layout Shift): < 0.1
14
+
15
+ ### Bundle
16
+ - Code splitting by route. No single bundle > 200KB gzipped.
17
+ - Tree shaking enabled. No unused exports.
18
+ - Bundle size tracked in CI — PRs that increase bundle > 10KB require justification.
19
+
20
+ ### Runtime
21
+ - Virtual/windowed lists for collections > 50 items.
22
+ - Debounce search inputs (300ms minimum).
23
+
24
+ ### Assets
25
+ - Images in modern formats (WebP/AVIF with fallback).
26
+ - Responsive images with srcset.
27
+ - Fonts preloaded, display:swap.