specialist-agent 2.0.0 → 2.7.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 (104) hide show
  1. package/.claude-plugin/marketplace.json +7 -7
  2. package/.claude-plugin/plugin.json +2 -2
  3. package/.cursor-plugin/marketplace.json +1 -1
  4. package/.cursor-plugin/plugin.json +2 -2
  5. package/LICENSE +1 -1
  6. package/README.md +17 -7
  7. package/agents/api.md +374 -93
  8. package/agents/architect-lite.md +104 -0
  9. package/agents/architect.md +553 -0
  10. package/agents/data.md +108 -0
  11. package/agents/deps.md +323 -167
  12. package/agents/devops.md +12 -0
  13. package/agents/docs.md +381 -134
  14. package/agents/executor.md +117 -0
  15. package/agents/finance.md +85 -0
  16. package/agents/i18n.md +512 -117
  17. package/agents/memory.md +1 -1
  18. package/agents/perf.md +287 -109
  19. package/agents/refactor.md +380 -92
  20. package/agents/ripple-lite.md +106 -0
  21. package/agents/ripple.md +162 -0
  22. package/agents/scout-lite.md +1 -1
  23. package/agents/scout.md +1 -1
  24. package/agents/security.md +65 -0
  25. package/agents/tdd.md +11 -3
  26. package/cli/index.mjs +54 -36
  27. package/hooks/native/auto-dispatch.mjs +6 -0
  28. package/hooks/native/security-guard.mjs +3 -2
  29. package/hooks/native/settings-template.json +4 -4
  30. package/package.json +15 -2
  31. package/packs/angular/ARCHITECTURE.md +814 -0
  32. package/packs/angular/CLAUDE.md +105 -0
  33. package/packs/angular/agents/builder.md +157 -0
  34. package/packs/angular/agents/doctor.md +241 -0
  35. package/packs/angular/agents/migrator.md +195 -0
  36. package/packs/angular/agents/reviewer.md +263 -0
  37. package/packs/angular/agents-lite/builder.md +65 -0
  38. package/packs/angular/agents-lite/doctor.md +64 -0
  39. package/packs/angular/agents-lite/migrator.md +75 -0
  40. package/packs/angular/agents-lite/reviewer.md +69 -0
  41. package/packs/angular/skills/dev-create-component/SKILL.md +56 -0
  42. package/packs/angular/skills/dev-create-injectable/SKILL.md +60 -0
  43. package/packs/angular/skills/dev-create-module/SKILL.md +49 -0
  44. package/packs/angular/skills/dev-create-service/SKILL.md +34 -0
  45. package/packs/angular/skills/dev-create-test/SKILL.md +78 -0
  46. package/packs/angular/skills/dev-generate-types/SKILL.md +37 -0
  47. package/packs/angular/skills/docs-onboard/SKILL.md +42 -0
  48. package/packs/angular/skills/migration-migrate-component/SKILL.md +42 -0
  49. package/packs/angular/skills/migration-migrate-module/SKILL.md +25 -0
  50. package/packs/angular/skills/review-check-architecture/SKILL.md +67 -0
  51. package/packs/angular/skills/review-fix-violations/SKILL.md +43 -0
  52. package/packs/angular/skills/review-review/SKILL.md +42 -0
  53. package/packs/astro/ARCHITECTURE.md +718 -0
  54. package/packs/astro/CLAUDE.md +106 -0
  55. package/packs/astro/agents/builder.md +192 -0
  56. package/packs/astro/agents/doctor.md +254 -0
  57. package/packs/astro/agents/migrator.md +209 -0
  58. package/packs/astro/agents/reviewer.md +263 -0
  59. package/packs/astro/agents-lite/builder.md +71 -0
  60. package/packs/astro/agents-lite/doctor.md +66 -0
  61. package/packs/astro/agents-lite/migrator.md +71 -0
  62. package/packs/astro/agents-lite/reviewer.md +70 -0
  63. package/packs/astro/skills/dev-create-component/SKILL.md +50 -0
  64. package/packs/astro/skills/dev-create-island/SKILL.md +63 -0
  65. package/packs/astro/skills/dev-create-module/SKILL.md +49 -0
  66. package/packs/astro/skills/dev-create-service/SKILL.md +34 -0
  67. package/packs/astro/skills/dev-create-test/SKILL.md +76 -0
  68. package/packs/astro/skills/dev-generate-types/SKILL.md +37 -0
  69. package/packs/astro/skills/docs-onboard/SKILL.md +51 -0
  70. package/packs/astro/skills/migration-migrate-component/SKILL.md +48 -0
  71. package/packs/astro/skills/migration-migrate-module/SKILL.md +25 -0
  72. package/packs/astro/skills/review-check-architecture/SKILL.md +72 -0
  73. package/packs/astro/skills/review-fix-violations/SKILL.md +43 -0
  74. package/packs/astro/skills/review-review/SKILL.md +44 -0
  75. package/packs/nuxt/ARCHITECTURE.md +831 -0
  76. package/packs/nuxt/CLAUDE.md +111 -0
  77. package/packs/nuxt/agents/builder.md +165 -0
  78. package/packs/nuxt/agents/doctor.md +252 -0
  79. package/packs/nuxt/agents/migrator.md +203 -0
  80. package/packs/nuxt/agents/reviewer.md +275 -0
  81. package/packs/nuxt/agents-lite/builder.md +67 -0
  82. package/packs/nuxt/agents-lite/doctor.md +67 -0
  83. package/packs/nuxt/agents-lite/migrator.md +80 -0
  84. package/packs/nuxt/agents-lite/reviewer.md +71 -0
  85. package/packs/nuxt/skills/dev-create-component/SKILL.md +60 -0
  86. package/packs/nuxt/skills/dev-create-composable/SKILL.md +33 -0
  87. package/packs/nuxt/skills/dev-create-module/SKILL.md +49 -0
  88. package/packs/nuxt/skills/dev-create-service/SKILL.md +34 -0
  89. package/packs/nuxt/skills/dev-create-test/SKILL.md +61 -0
  90. package/packs/nuxt/skills/dev-generate-types/SKILL.md +37 -0
  91. package/packs/nuxt/skills/docs-onboard/SKILL.md +49 -0
  92. package/packs/nuxt/skills/migration-migrate-component/SKILL.md +48 -0
  93. package/packs/nuxt/skills/migration-migrate-module/SKILL.md +25 -0
  94. package/packs/nuxt/skills/review-check-architecture/SKILL.md +71 -0
  95. package/packs/nuxt/skills/review-fix-violations/SKILL.md +43 -0
  96. package/packs/nuxt/skills/review-review/SKILL.md +44 -0
  97. package/skills/checkpoint/SKILL.md +8 -0
  98. package/skills/codereview/SKILL.md +255 -0
  99. package/skills/commit/SKILL.md +150 -0
  100. package/skills/estimate/SKILL.md +9 -0
  101. package/skills/finish/SKILL.md +9 -0
  102. package/skills/health/SKILL.md +9 -0
  103. package/skills/lint/SKILL.md +126 -0
  104. package/skills/plan/SKILL.md +9 -0
@@ -0,0 +1,831 @@
1
+ # ARCHITECTURE.md — Architecture Guide and Patterns
2
+
3
+ > This document is the **source of truth** for all agents and skills.
4
+ > Any architectural decision must be documented here.
5
+
6
+ ---
7
+
8
+ ## 1. Overview
9
+
10
+ Nuxt 3 is a full-stack Vue 3 framework with auto-imports, file-based routing, and a built-in Nitro server engine. This architecture leverages Nuxt's conventions for a modern, typed, and modular codebase:
11
+
12
+ | Feature | Approach |
13
+ |---------|----------|
14
+ | Language | TypeScript (strict) |
15
+ | Components | `<script setup lang="ts">` with auto-imports |
16
+ | Server state | `useFetch` / `useAsyncData` (built-in caching) |
17
+ | Client state (simple) | `useState` (SSR-safe) |
18
+ | Client state (complex) | Pinia (setup syntax) |
19
+ | Routing | File-based (`pages/` directory) |
20
+ | Server API | Nitro (`server/api/` directory) |
21
+ | Rendering | Hybrid (SSR, SSG, SPA per route) |
22
+ | Validation | Zod schemas |
23
+ | Testing | Vitest + `@nuxt/test-utils` |
24
+ | Naming | kebab-case files, PascalCase components |
25
+
26
+ ---
27
+
28
+ ## 2. Directory Structure (Modular Architecture)
29
+
30
+ ```
31
+ ├── app/ # App shell
32
+ │ ├── app.vue # Root component
33
+ │ └── error.vue # Global error page
34
+ │
35
+ ├── pages/ # File-based routing
36
+ │ ├── index.vue # /
37
+ │ ├── login.vue # /login
38
+ │ └── marketplace/
39
+ │ ├── index.vue # /marketplace
40
+ │ └── [id].vue # /marketplace/:id
41
+ │
42
+ ├── layouts/ # Layout components
43
+ │ ├── default.vue
44
+ │ └── auth.vue
45
+ │
46
+ ├── components/ # Auto-imported shared components
47
+ │ ├── AppButton.vue
48
+ │ ├── AppModal.vue
49
+ │ └── AppTable.vue
50
+ │
51
+ ├── composables/ # Auto-imported shared composables
52
+ │ ├── useAuth.ts
53
+ │ └── useToast.ts
54
+ │
55
+ ├── modules/ # Feature modules (bounded contexts)
56
+ │ └── marketplace/
57
+ │ ├── components/
58
+ │ │ ├── MarketplaceList.vue
59
+ │ │ ├── MarketplaceCard.vue
60
+ │ │ └── MarketplaceFilters.vue
61
+ │ ├── composables/
62
+ │ │ ├── useMarketplaceList.ts
63
+ │ │ └── useMarketplaceFilters.ts
64
+ │ ├── services/
65
+ │ │ └── marketplace-service.ts
66
+ │ ├── adapters/
67
+ │ │ └── marketplace-adapter.ts
68
+ │ ├── types/
69
+ │ │ ├── marketplace.types.ts
70
+ │ │ └── marketplace.contracts.ts
71
+ │ ├── __tests__/
72
+ │ └── index.ts # Barrel export (public API)
73
+ │
74
+ ├── server/ # Nitro server engine
75
+ │ ├── api/ # API routes
76
+ │ │ ├── marketplace/
77
+ │ │ │ ├── index.get.ts # GET /api/marketplace
78
+ │ │ │ ├── index.post.ts # POST /api/marketplace
79
+ │ │ │ └── [id].get.ts # GET /api/marketplace/:id
80
+ │ │ └── auth/
81
+ │ │ └── login.post.ts
82
+ │ ├── middleware/ # Server middleware
83
+ │ │ └── auth.ts
84
+ │ └── utils/ # Server-side utilities
85
+ │ ├── db.ts
86
+ │ └── validate.ts
87
+ │
88
+ ├── middleware/ # Route middleware (client-side)
89
+ │ ├── auth.ts
90
+ │ └── guest.ts
91
+ │
92
+ ├── plugins/ # Nuxt plugins (app initialization)
93
+ │ └── error-handler.ts
94
+ │
95
+ ├── shared/ # Shared utilities
96
+ │ ├── utils/ # Pure functions
97
+ │ ├── helpers/ # Functions with side effects
98
+ │ ├── types/ # Global types
99
+ │ └── constants/ # Static values
100
+ │
101
+ ├── assets/ # Static assets (processed by Vite)
102
+ │
103
+ └── public/ # Public static files (served as-is)
104
+ ```
105
+
106
+ ### Import Rules Between Layers
107
+ ```
108
+ modules/auth <-> shared/ OK — Module imports from shared
109
+ modules/auth -> modules/market PROHIBITED — Module imports from another module
110
+ shared/ -> modules/auth PROHIBITED — Shared imports from module
111
+ pages/ -> modules/* OK — Pages import module components/composables
112
+ composables/ <-> shared/ OK — Shared composables use shared utils
113
+ server/ -> shared/types OK — Server uses shared types
114
+ ```
115
+
116
+ If two modules need to share something, move it to `shared/` or `composables/`.
117
+
118
+ ---
119
+
120
+ ## 3. Naming Conventions
121
+
122
+ ### Files and Directories
123
+
124
+ | Type | Pattern | Example |
125
+ |------|---------|---------|
126
+ | Directories | `kebab-case` | `user-settings/` |
127
+ | Vue Components | `PascalCase.vue` | `MarketplaceCard.vue` |
128
+ | Pages | `kebab-case.vue` | `marketplace/index.vue` |
129
+ | Composables | `use` + `PascalCase.ts` | `useMarketplaceList.ts` |
130
+ | Services | `kebab-case-service.ts` | `marketplace-service.ts` |
131
+ | Adapters | `kebab-case-adapter.ts` | `marketplace-adapter.ts` |
132
+ | Server API routes | `kebab-case.[method].ts` | `index.get.ts`, `[id].delete.ts` |
133
+ | Types | `kebab-case.types.ts` | `marketplace.types.ts` |
134
+ | Contracts/Schemas | `kebab-case.contracts.ts` | `marketplace.contracts.ts` |
135
+ | Utils | `kebab-case.ts` | `format-date.ts` |
136
+ | Helpers | `kebab-case.ts` | `clipboard-helper.ts` |
137
+ | Tests | `OriginalName.spec.ts` | `MarketplaceList.spec.ts` |
138
+ | Middleware | `kebab-case.ts` | `auth.ts` |
139
+ | Plugins | `kebab-case.ts` | `error-handler.ts` |
140
+
141
+ ### Code
142
+
143
+ | Type | Pattern | Example |
144
+ |------|---------|---------|
145
+ | Variables / functions | `camelCase` | `getUserById`, `isLoading` |
146
+ | Types / Interfaces | `PascalCase` | `UserProfile`, `MarketplaceItem` |
147
+ | Enums | `PascalCase` | `UserRole.Admin` |
148
+ | Constants | `UPPER_SNAKE_CASE` | `API_BASE_URL`, `MAX_RETRIES` |
149
+ | Composables | `use` + `PascalCase` | `useAuth`, `useMarketplaceList` |
150
+ | Event handlers | `handle` + action | `handleSubmit`, `handleDelete` |
151
+ | Boolean | `is`/`has`/`can`/`should` | `isLoading`, `hasPermission` |
152
+
153
+ ---
154
+
155
+ ## 4. Responsibility Layers
156
+
157
+ ### 4.1 Services — Pure HTTP Requests
158
+
159
+ Services perform **only** the HTTP request. No try/catch, no transformation, no business logic.
160
+
161
+ ```typescript
162
+ // modules/marketplace/services/marketplace-service.ts
163
+ import type { MarketplaceListResponse, MarketplaceItemResponse } from '../types/marketplace.types'
164
+
165
+ export const marketplaceService = {
166
+ list(params: { page: number; pageSize: number; search?: string }) {
167
+ return $fetch<MarketplaceListResponse>('/api/marketplace', { params })
168
+ },
169
+
170
+ getById(id: string) {
171
+ return $fetch<MarketplaceItemResponse>(`/api/marketplace/${id}`)
172
+ },
173
+
174
+ create(payload: CreateMarketplacePayload) {
175
+ return $fetch<MarketplaceItemResponse>('/api/marketplace', {
176
+ method: 'POST',
177
+ body: payload,
178
+ })
179
+ },
180
+
181
+ delete(id: string) {
182
+ return $fetch(`/api/marketplace/${id}`, { method: 'DELETE' })
183
+ },
184
+ }
185
+ ```
186
+
187
+ **Service rules:**
188
+ - NO try/catch (caller handles errors)
189
+ - NO data transformation (adapter does that)
190
+ - NO business logic
191
+ - NO access to stores or composables
192
+ - YES typed request/response
193
+ - YES one file per domain/resource
194
+ - YES export as object with methods
195
+ - Use `$fetch` (Nuxt built-in) instead of axios
196
+
197
+ ### 4.2 Adapters — Contract Parsers
198
+
199
+ Adapters transform data from the API to the TypeScript app contract (and vice-versa). They are **pure functions** without side effects.
200
+
201
+ ```typescript
202
+ // modules/marketplace/adapters/marketplace-adapter.ts
203
+ import type {
204
+ MarketplaceListResponse,
205
+ MarketplaceItemResponse,
206
+ } from '../types/marketplace.types'
207
+ import type {
208
+ MarketplaceItem,
209
+ MarketplaceList,
210
+ } from '../types/marketplace.contracts'
211
+
212
+ export const marketplaceAdapter = {
213
+ toMarketplaceItem(response: MarketplaceItemResponse): MarketplaceItem {
214
+ return {
215
+ id: response.uuid,
216
+ name: response.name,
217
+ vendor: response.vendor_name,
218
+ category: response.category_slug,
219
+ price: response.price_cents / 100,
220
+ isActive: response.status === 'active',
221
+ createdAt: new Date(response.created_at),
222
+ updatedAt: new Date(response.updated_at),
223
+ }
224
+ },
225
+
226
+ toMarketplaceList(response: MarketplaceListResponse): MarketplaceList {
227
+ return {
228
+ items: response.results.map(marketplaceAdapter.toMarketplaceItem),
229
+ totalItems: response.count,
230
+ totalPages: Math.ceil(response.count / response.page_size),
231
+ currentPage: response.page,
232
+ }
233
+ },
234
+
235
+ toCreatePayload(item: CreateMarketplaceInput): CreateMarketplacePayload {
236
+ return {
237
+ name: item.name,
238
+ vendor_name: item.vendor,
239
+ category_slug: item.category,
240
+ price_cents: Math.round(item.price * 100),
241
+ }
242
+ },
243
+ }
244
+ ```
245
+
246
+ **Adapter rules:**
247
+ - Pure functions (input -> output, no side effects)
248
+ - Two directions: API->App (inbound) and App->API (outbound)
249
+ - Rename fields (snake_case API -> camelCase App)
250
+ - Convert types (string->Date, cents->decimal, status->boolean)
251
+ - NO HTTP calls
252
+ - NO access to store/composable
253
+ - NO try/catch (failure = wrong type = bug to fix)
254
+
255
+ ### 4.3 Types & Contracts
256
+
257
+ ```typescript
258
+ // types/marketplace.types.ts
259
+ // Types that mirror the API exactly as it returns (snake_case)
260
+
261
+ export interface MarketplaceItemResponse {
262
+ uuid: string
263
+ name: string
264
+ vendor_name: string
265
+ category_slug: string
266
+ price_cents: number
267
+ status: 'active' | 'inactive' | 'pending'
268
+ created_at: string
269
+ updated_at: string
270
+ }
271
+
272
+ export interface MarketplaceListResponse {
273
+ count: number
274
+ page: number
275
+ page_size: number
276
+ results: MarketplaceItemResponse[]
277
+ }
278
+
279
+ // types/marketplace.contracts.ts
280
+ // App contracts (camelCase, correct types)
281
+
282
+ export interface MarketplaceItem {
283
+ id: string
284
+ name: string
285
+ vendor: string
286
+ category: string
287
+ price: number // in currency units, not cents
288
+ isActive: boolean // derived from status
289
+ createdAt: Date
290
+ updatedAt: Date
291
+ }
292
+
293
+ export interface MarketplaceList {
294
+ items: MarketplaceItem[]
295
+ totalItems: number
296
+ totalPages: number
297
+ currentPage: number
298
+ }
299
+
300
+ export interface CreateMarketplaceInput {
301
+ name: string
302
+ vendor: string
303
+ category: string
304
+ price: number
305
+ }
306
+ ```
307
+
308
+ ### 4.4 Composables — Business Logic + Orchestration
309
+
310
+ Composables connect everything: call service, pass through adapter, manage loading/error, and expose reactive data. In Nuxt, composables in the `composables/` directory are **auto-imported**.
311
+
312
+ ```typescript
313
+ // modules/marketplace/composables/useMarketplaceList.ts
314
+ import { marketplaceService } from '../services/marketplace-service'
315
+ import { marketplaceAdapter } from '../adapters/marketplace-adapter'
316
+ import type { MarketplaceList } from '../types/marketplace.contracts'
317
+
318
+ interface UseMarketplaceListOptions {
319
+ page: Ref<number>
320
+ pageSize?: Ref<number>
321
+ search?: Ref<string>
322
+ }
323
+
324
+ export function useMarketplaceList(options: UseMarketplaceListOptions) {
325
+ const page = computed(() => toValue(options.page))
326
+ const pageSize = computed(() => toValue(options.pageSize) ?? 20)
327
+ const search = computed(() => toValue(options.search) ?? '')
328
+
329
+ const { data, status, error, refresh } = useAsyncData(
330
+ () => `marketplace-list-${page.value}-${pageSize.value}-${search.value}`,
331
+ () => marketplaceService.list({
332
+ page: page.value,
333
+ pageSize: pageSize.value,
334
+ search: search.value,
335
+ }),
336
+ {
337
+ transform: (response) => marketplaceAdapter.toMarketplaceList(response),
338
+ watch: [page, pageSize, search],
339
+ },
340
+ )
341
+
342
+ const items = computed(() => data.value?.items ?? [])
343
+ const totalPages = computed(() => data.value?.totalPages ?? 0)
344
+ const isLoading = computed(() => status.value === 'pending')
345
+ const isEmpty = computed(() => !isLoading.value && items.value.length === 0)
346
+
347
+ return {
348
+ // Data
349
+ items,
350
+ totalPages,
351
+ // State
352
+ isLoading,
353
+ isEmpty,
354
+ error,
355
+ // Actions
356
+ refresh,
357
+ }
358
+ }
359
+ ```
360
+
361
+ **Composable rules:**
362
+ - Orchestrate: service -> adapter -> reactive data
363
+ - Manage loading, error, empty states
364
+ - Return refs/computed (never raw values)
365
+ - Name with `use` prefix
366
+ - Typed return values
367
+ - NO template/rendering (component does that)
368
+ - NO direct API access (service does that)
369
+ - Use `useAsyncData` or `useFetch` for server state (not TanStack Query)
370
+
371
+ ### 4.5 useState — SSR-Safe Shared State
372
+
373
+ `useState` is Nuxt's built-in SSR-friendly state. Use it for simple shared state that needs to survive SSR hydration.
374
+
375
+ ```typescript
376
+ // composables/useMarketplaceFilters.ts
377
+ export function useMarketplaceFilters() {
378
+ const selectedCategory = useState<string | null>('marketplace-category', () => null)
379
+ const viewMode = useState<'grid' | 'list'>('marketplace-view-mode', () => 'grid')
380
+ const searchQuery = useState<string>('marketplace-search', () => '')
381
+
382
+ const hasActiveFilters = computed(() =>
383
+ !!selectedCategory.value || !!searchQuery.value
384
+ )
385
+
386
+ function setCategory(category: string | null) {
387
+ selectedCategory.value = category
388
+ }
389
+
390
+ function setViewMode(mode: 'grid' | 'list') {
391
+ viewMode.value = mode
392
+ }
393
+
394
+ function clearFilters() {
395
+ selectedCategory.value = null
396
+ searchQuery.value = ''
397
+ }
398
+
399
+ return {
400
+ selectedCategory: readonly(selectedCategory),
401
+ viewMode: readonly(viewMode),
402
+ searchQuery,
403
+ hasActiveFilters,
404
+ setCategory,
405
+ setViewMode,
406
+ clearFilters,
407
+ }
408
+ }
409
+ ```
410
+
411
+ ### 4.6 Pinia Stores — Complex Client State Only
412
+
413
+ Use Pinia only when `useState` is not enough (complex state, devtools, plugin ecosystem).
414
+
415
+ ```typescript
416
+ // modules/marketplace/stores/marketplace-store.ts
417
+ import { defineStore } from 'pinia'
418
+
419
+ export const useMarketplaceStore = defineStore('marketplace', () => {
420
+ // State
421
+ const cart = ref<CartItem[]>([])
422
+ const recentlyViewed = ref<string[]>([])
423
+
424
+ // Getters
425
+ const cartTotal = computed(() =>
426
+ cart.value.reduce((sum, item) => sum + item.price * item.quantity, 0)
427
+ )
428
+
429
+ const cartCount = computed(() =>
430
+ cart.value.reduce((sum, item) => sum + item.quantity, 0)
431
+ )
432
+
433
+ // Actions
434
+ function addToCart(item: CartItem) {
435
+ const existing = cart.value.find(i => i.id === item.id)
436
+ if (existing) {
437
+ existing.quantity += item.quantity
438
+ } else {
439
+ cart.value.push(item)
440
+ }
441
+ }
442
+
443
+ function removeFromCart(id: string) {
444
+ cart.value = cart.value.filter(i => i.id !== id)
445
+ }
446
+
447
+ return {
448
+ cart: readonly(cart),
449
+ recentlyViewed: readonly(recentlyViewed),
450
+ cartTotal,
451
+ cartCount,
452
+ addToCart,
453
+ removeFromCart,
454
+ }
455
+ })
456
+ ```
457
+
458
+ **State management rules:**
459
+ - `useState` for simple shared state (filters, UI mode, preferences)
460
+ - Pinia for complex client state (cart, multi-step forms, computed chains)
461
+ - `useFetch` / `useAsyncData` for server state — NEVER in Pinia
462
+ - Pinia: setup syntax, readonly() on state, storeToRefs() in consumers
463
+ - NO HTTP calls inside stores
464
+
465
+ ### 4.7 Server Routes (Nitro)
466
+
467
+ ```typescript
468
+ // server/api/marketplace/index.get.ts
469
+ import { z } from 'zod'
470
+
471
+ const querySchema = z.object({
472
+ page: z.coerce.number().min(1).default(1),
473
+ pageSize: z.coerce.number().min(1).max(100).default(20),
474
+ search: z.string().optional(),
475
+ })
476
+
477
+ export default defineEventHandler(async (event) => {
478
+ const query = await getValidatedQuery(event, querySchema.parse)
479
+
480
+ // Fetch from database or external API
481
+ const items = await fetchMarketplaceItems(query)
482
+
483
+ return items
484
+ })
485
+
486
+ // server/api/marketplace/index.post.ts
487
+ import { z } from 'zod'
488
+
489
+ const bodySchema = z.object({
490
+ name: z.string().min(1).max(255),
491
+ vendor_name: z.string().min(1),
492
+ category_slug: z.string().min(1),
493
+ price_cents: z.number().int().positive(),
494
+ })
495
+
496
+ export default defineEventHandler(async (event) => {
497
+ const body = await readValidatedBody(event, bodySchema.parse)
498
+
499
+ const item = await createMarketplaceItem(body)
500
+
501
+ return item
502
+ })
503
+ ```
504
+
505
+ ---
506
+
507
+ ## 5. Components — Composition Pattern
508
+
509
+ ### 5.1 SFC Pattern (with auto-imports)
510
+
511
+ ```vue
512
+ <script setup lang="ts">
513
+ // In Nuxt, composables, components, and Vue APIs are auto-imported
514
+ // NO import statements needed for: ref, computed, watch, useRoute, etc.
515
+
516
+ // 1. Props & Emits (type-based)
517
+ interface Props {
518
+ categoryFilter?: string
519
+ }
520
+
521
+ interface Emits {
522
+ (e: 'select', item: MarketplaceItem): void
523
+ }
524
+
525
+ const props = withDefaults(defineProps<Props>(), {
526
+ categoryFilter: undefined,
527
+ })
528
+
529
+ const emit = defineEmits<Emits>()
530
+
531
+ // 2. Composables (auto-imported if in composables/ dir)
532
+ const page = ref(1)
533
+ const { items, totalPages, isLoading, isEmpty } = useMarketplaceList({
534
+ page,
535
+ })
536
+
537
+ // 3. Local state
538
+ const selectedId = ref<string | null>(null)
539
+
540
+ // 4. Computed
541
+ const isFirstPage = computed(() => page.value === 1)
542
+
543
+ // 5. Handlers
544
+ function handleSelect(item: MarketplaceItem) {
545
+ selectedId.value = item.id
546
+ emit('select', item)
547
+ }
548
+
549
+ function handlePageChange(newPage: number) {
550
+ page.value = newPage
551
+ }
552
+ </script>
553
+
554
+ <template>
555
+ <!-- ... -->
556
+ </template>
557
+
558
+ <style scoped>
559
+ /* ... */
560
+ </style>
561
+ ```
562
+
563
+ ### 5.2 Stop Prop Drilling — Component Composition
564
+
565
+ **WRONG — Prop Drilling:**
566
+ ```vue
567
+ <Parent :user="user" :theme="theme" :permissions="permissions">
568
+ <Child :user="user" :theme="theme" :permissions="permissions">
569
+ <GrandChild :user="user" :permissions="permissions" />
570
+ </Child>
571
+ </Parent>
572
+ ```
573
+
574
+ **CORRECT — Composition with Slots:**
575
+ ```vue
576
+ <!-- pages/marketplace/index.vue -->
577
+ <template>
578
+ <NuxtLayout>
579
+ <MarketplaceFilters />
580
+
581
+ <MarketplaceList @select="handleSelect">
582
+ <template #card="{ item }">
583
+ <MarketplaceCard :item="item" />
584
+ </template>
585
+
586
+ <template #empty>
587
+ <EmptyState message="No items found" />
588
+ </template>
589
+ </MarketplaceList>
590
+
591
+ <MarketplaceDetails v-if="selectedItem" :item="selectedItem" />
592
+ </NuxtLayout>
593
+ </template>
594
+ ```
595
+
596
+ **CORRECT — Provide/Inject for shared context:**
597
+ ```typescript
598
+ // composables/useMarketplaceContext.ts
599
+ import type { InjectionKey, Ref } from 'vue'
600
+
601
+ interface MarketplaceContext {
602
+ selectedItem: Ref<MarketplaceItem | null>
603
+ selectItem: (item: MarketplaceItem) => void
604
+ clearSelection: () => void
605
+ }
606
+
607
+ export const MARKETPLACE_CONTEXT: InjectionKey<MarketplaceContext> = Symbol('marketplace-context')
608
+
609
+ export function provideMarketplaceContext() {
610
+ const selectedItem = ref<MarketplaceItem | null>(null)
611
+
612
+ function selectItem(item: MarketplaceItem) {
613
+ selectedItem.value = item
614
+ }
615
+
616
+ function clearSelection() {
617
+ selectedItem.value = null
618
+ }
619
+
620
+ const context: MarketplaceContext = {
621
+ selectedItem: readonly(selectedItem),
622
+ selectItem,
623
+ clearSelection,
624
+ }
625
+
626
+ provide(MARKETPLACE_CONTEXT, context)
627
+ return context
628
+ }
629
+
630
+ export function useMarketplaceContext() {
631
+ const context = inject(MARKETPLACE_CONTEXT)
632
+ if (!context) {
633
+ throw new Error('useMarketplaceContext must be used within a provider')
634
+ }
635
+ return context
636
+ }
637
+ ```
638
+
639
+ ### 5.3 Component Hierarchy
640
+
641
+ ```
642
+ Pages (pages/) -> Composition, orchestration, provide context
643
+ └── Layout -> Visual structure (slots)
644
+ └── Features -> Feature logic (composables)
645
+ └── Shared -> Pure presentation (props in, events out)
646
+ ```
647
+
648
+ | Type | Responsibility | Can have logic? | Can have state? |
649
+ |------|---------------|----------------|----------------|
650
+ | **Pages** | Compose components, provide context | Via composables | Yes (composables) |
651
+ | **Feature Components** | UI + feature logic | Via composables | Yes (composables) |
652
+ | **Shared Components** | Generic, reusable UI | Minimal (UI only) | Minimal (local) |
653
+
654
+ ---
655
+
656
+ ## 6. Utils vs Helpers
657
+
658
+ ### Utils — Pure Functions
659
+ - No side effects
660
+ - Input -> Output deterministic
661
+ - Testable without mocks
662
+ - No dependency on DOM, browser APIs, or Vue
663
+
664
+ ```typescript
665
+ // shared/utils/format-date.ts
666
+ export function formatDate(date: Date, locale = 'en-US'): string {
667
+ return new Intl.DateTimeFormat(locale).format(date)
668
+ }
669
+
670
+ // shared/utils/currency.ts
671
+ export function formatCurrency(value: number, currency = 'USD'): string {
672
+ return new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(value)
673
+ }
674
+ ```
675
+
676
+ ### Helpers — Functions with Side Effects
677
+ - Interact with browser APIs (clipboard, localStorage, DOM)
678
+ - May have side effects
679
+ - May need mocks in tests
680
+
681
+ ```typescript
682
+ // shared/helpers/clipboard-helper.ts
683
+ export async function copyToClipboard(text: string): Promise<boolean> {
684
+ try {
685
+ await navigator.clipboard.writeText(text)
686
+ return true
687
+ } catch {
688
+ return false
689
+ }
690
+ }
691
+ ```
692
+
693
+ ---
694
+
695
+ ## 7. Error Handling — Centralized Pattern
696
+
697
+ ### In Composables (useFetch / useAsyncData)
698
+ ```typescript
699
+ const { data, error } = await useFetch('/api/marketplace', {
700
+ onResponseError({ response }) {
701
+ showError({
702
+ statusCode: response.status,
703
+ statusMessage: response.statusText,
704
+ })
705
+ },
706
+ })
707
+ ```
708
+
709
+ ### Global Error Page (error.vue)
710
+ ```vue
711
+ <!-- app/error.vue -->
712
+ <script setup lang="ts">
713
+ const props = defineProps<{
714
+ error: {
715
+ statusCode: number
716
+ statusMessage: string
717
+ message: string
718
+ }
719
+ }>()
720
+
721
+ function handleClearError() {
722
+ clearError({ redirect: '/' })
723
+ }
724
+ </script>
725
+
726
+ <template>
727
+ <div>
728
+ <h1>{{ error.statusCode }}</h1>
729
+ <p>{{ error.message }}</p>
730
+ <button @click="handleClearError">Go home</button>
731
+ </div>
732
+ </template>
733
+ ```
734
+
735
+ ### Server Error Handling (Nitro)
736
+ ```typescript
737
+ // server/api/marketplace/[id].get.ts
738
+ export default defineEventHandler(async (event) => {
739
+ const id = getRouterParam(event, 'id')
740
+
741
+ const item = await findMarketplaceItem(id)
742
+ if (!item) {
743
+ throw createError({
744
+ statusCode: 404,
745
+ statusMessage: 'Item not found',
746
+ })
747
+ }
748
+
749
+ return item
750
+ })
751
+ ```
752
+
753
+ ### Error Utilities
754
+ - `useError()` — access current error in components
755
+ - `showError()` — trigger the error page
756
+ - `clearError()` — clear error and optionally redirect
757
+ - `createError()` — create an error in server routes
758
+
759
+ ---
760
+
761
+ ## 8. Barrel Exports (index.ts)
762
+
763
+ Due to auto-imports, barrel exports are less critical in Nuxt. However, for `modules/` (which are NOT auto-imported), each module exports its **public API**:
764
+
765
+ ```typescript
766
+ // modules/marketplace/index.ts
767
+
768
+ // Components (for use in pages)
769
+ export { default as MarketplaceList } from './components/MarketplaceList.vue'
770
+ export { default as MarketplaceCard } from './components/MarketplaceCard.vue'
771
+
772
+ // Types (for typing)
773
+ export type { MarketplaceItem, MarketplaceList } from './types/marketplace.contracts'
774
+
775
+ // DO NOT export:
776
+ // - services (internal detail)
777
+ // - adapters (internal detail)
778
+ // - stores (use via composable)
779
+ // - internal composables
780
+ ```
781
+
782
+ ---
783
+
784
+ ## 9. SOLID Applied to Nuxt
785
+
786
+ | Principle | Application in Nuxt |
787
+ |-----------|---------------------|
788
+ | **S**ingle Responsibility | 1 component = 1 responsibility. 1 composable = 1 domain. 1 server route = 1 operation. |
789
+ | **O**pen/Closed | Components extensible via slots and props, not internal modification. |
790
+ | **L**iskov Substitution | Shared components must work in any context without breaking. |
791
+ | **I**nterface Segregation | Specific props, not generic objects. `<UserAvatar :src :alt>` not `<UserAvatar :user>`. |
792
+ | **D**ependency Inversion | Composables depend on interfaces (types), not implementations. Services injected via composable. |
793
+
794
+ ---
795
+
796
+ ## 10. Migration Checklist (Nuxt 2 -> Nuxt 3)
797
+
798
+ ### Nuxt Configuration
799
+ - [ ] `nuxt.config.js` -> `nuxt.config.ts`
800
+ - [ ] `buildModules` -> `modules` (no distinction in Nuxt 3)
801
+ - [ ] `@nuxtjs/` modules -> Nuxt 3 compatible alternatives
802
+
803
+ ### Data Fetching
804
+ - [ ] `asyncData()` -> `useAsyncData()`
805
+ - [ ] `fetch()` -> `useFetch()`
806
+ - [ ] `$axios` / `@nuxtjs/axios` -> `$fetch` (built-in)
807
+
808
+ ### State Management
809
+ - [ ] `store/` (Vuex) -> `composables/` + `useState` or Pinia
810
+ - [ ] Vuex modules -> Pinia stores (setup syntax)
811
+
812
+ ### Components
813
+ - [ ] Options API -> `<script setup lang="ts">`
814
+ - [ ] `this.$route` -> `useRoute()`
815
+ - [ ] `this.$router` -> `useRouter()`
816
+ - [ ] `this.$store` -> composables / Pinia
817
+ - [ ] `this.$refs` -> `useTemplateRef()`
818
+
819
+ ### Plugins
820
+ - [ ] `plugins/*.js` -> `plugins/*.ts`
821
+ - [ ] `inject()` pattern -> `provide()` + composables
822
+ - [ ] `context` parameter -> `useNuxtApp()`, `useRuntimeConfig()`
823
+
824
+ ### Middleware
825
+ - [ ] `middleware/*.js` -> `middleware/*.ts`
826
+ - [ ] `context` parameter -> `navigateTo()`, `abortNavigation()`
827
+
828
+ ### File Structure
829
+ - [ ] `static/` -> `public/`
830
+ - [ ] `store/` -> composables or Pinia
831
+ - [ ] Manual imports -> auto-imports (composables/, components/, utils/)