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,814 @@
1
+ # ARCHITECTURE.md -- Architecture & Patterns Guide
2
+
3
+ > This document is the **source of truth** for all subagents.
4
+ > Every architectural decision must be documented here.
5
+
6
+ ---
7
+
8
+ ## 1. Overview
9
+
10
+ We are migrating / building an Angular project following a modern, typed, modular architecture:
11
+
12
+ | From | To |
13
+ |------|----|
14
+ | JavaScript | TypeScript (strict) |
15
+ | NgModule-based components | Standalone components |
16
+ | @Input()/@Output() decorators | input()/output() signal-based I/O |
17
+ | Constructor DI | inject() function |
18
+ | RxJS BehaviorSubject stores | Signal-based stores (WritableSignal + computed) |
19
+ | Manual HTTP / inline transforms | Services + Adapters + HttpClient |
20
+ | Scattered try/catch | Centralized error handling via HttpInterceptor |
21
+ | Structure by file type | Modular architecture by feature |
22
+ | Class-heavy patterns | Functional + signal-based patterns |
23
+ | Inconsistent naming | Strict documented conventions |
24
+
25
+ ### Core Stack
26
+
27
+ - **Angular 17+** with standalone components
28
+ - **TypeScript** (strict mode)
29
+ - **Angular Signals** for reactive state (signal, computed, effect)
30
+ - **HttpClient** for HTTP calls
31
+ - **Angular Router** with lazy loading
32
+ - **Zod** for runtime validation
33
+ - **Jest/Vitest** + **Angular Testing Library** for tests
34
+
35
+ ### Data Flow
36
+
37
+ ```
38
+ Service (HttpClient only) --> Adapter (parse) --> Injectable/Component (orchestrate) --> Component (template)
39
+ ```
40
+
41
+ ---
42
+
43
+ ## 2. Directory Structure (Modular Architecture)
44
+
45
+ ```
46
+ src/
47
+ +-- app/ # Application shell
48
+ | +-- app.component.ts
49
+ | +-- app.config.ts
50
+ | +-- app.routes.ts
51
+ | +-- guards/
52
+ | +-- interceptors/ # HttpInterceptors (auth, error handling)
53
+ |
54
+ +-- modules/ # Feature modules (bounded contexts)
55
+ | +-- auth/
56
+ | | +-- components/
57
+ | | +-- services/
58
+ | | +-- adapters/
59
+ | | +-- stores/
60
+ | | +-- types/
61
+ | | +-- pages/
62
+ | | +-- __tests__/
63
+ | | +-- index.ts # Barrel export (public API)
64
+ | |
65
+ | +-- marketplace/
66
+ | | +-- components/
67
+ | | | +-- marketplace-list.component.ts
68
+ | | | +-- marketplace-card.component.ts
69
+ | | | +-- marketplace-filters.component.ts
70
+ | | | +-- marketplace-card/ # Sub-components if needed
71
+ | | | +-- marketplace-card-header.component.ts
72
+ | | | +-- marketplace-card-actions.component.ts
73
+ | | +-- services/
74
+ | | | +-- marketplace.service.ts
75
+ | | +-- adapters/
76
+ | | | +-- marketplace.adapter.ts
77
+ | | +-- stores/
78
+ | | | +-- marketplace.store.ts # Client state only (filters, UI)
79
+ | | +-- types/
80
+ | | | +-- marketplace.types.ts
81
+ | | | +-- marketplace.contracts.ts # Zod schemas / app contracts
82
+ | | +-- pages/
83
+ | | | +-- marketplace-page.component.ts
84
+ | | +-- __tests__/
85
+ | | +-- index.ts
86
+ | |
87
+ | +-- [other-module]/
88
+ |
89
+ +-- shared/ # Shared across modules
90
+ | +-- components/ # Generic components (Button, Modal, Table)
91
+ | +-- services/ # Base API client, interceptors
92
+ | +-- adapters/ # Shared adapters
93
+ | +-- types/ # Global types
94
+ | +-- utils/ # Pure functions, no side effects
95
+ | +-- helpers/ # Functions with side effects or DOM
96
+ | +-- constants/ # Static values
97
+ | +-- pipes/ # Angular pipes
98
+ | +-- directives/ # Angular directives
99
+ |
100
+ +-- assets/ # Static assets (images, fonts, global CSS)
101
+ ```
102
+
103
+ ### Import Rules Between Layers
104
+
105
+ ```
106
+ modules/auth <-> shared/ OK Module imports from shared
107
+ modules/auth --> modules/market NO Module does NOT import from another module
108
+ shared/ --> modules/auth NO Shared does NOT import from modules
109
+ app/ --> modules/* OK App imports modules (routes, providers)
110
+ ```
111
+
112
+ If two modules need to share something, move it to `shared/`.
113
+
114
+ ---
115
+
116
+ ## 3. Naming Conventions
117
+
118
+ ### Files and Directories
119
+
120
+ | Type | Pattern | Example |
121
+ |------|---------|---------|
122
+ | Directories | `kebab-case` | `user-settings/` |
123
+ | Components | `kebab-case.component.ts` | `user-settings-form.component.ts` |
124
+ | Pages | `kebab-case-page.component.ts` | `marketplace-page.component.ts` |
125
+ | Services | `kebab-case.service.ts` | `marketplace.service.ts` |
126
+ | Adapters | `kebab-case.adapter.ts` | `marketplace.adapter.ts` |
127
+ | Stores | `kebab-case.store.ts` | `marketplace.store.ts` |
128
+ | Types | `kebab-case.types.ts` | `marketplace.types.ts` |
129
+ | Contracts/Schemas | `kebab-case.contracts.ts` | `marketplace.contracts.ts` |
130
+ | Utils | `kebab-case.ts` | `format-date.ts` |
131
+ | Helpers | `kebab-case.ts` | `clipboard-helper.ts` |
132
+ | Tests | `kebab-case.spec.ts` | `marketplace-list.component.spec.ts` |
133
+ | Constants | `kebab-case.constants.ts` | `api-endpoints.constants.ts` |
134
+ | Pipes | `kebab-case.pipe.ts` | `currency-format.pipe.ts` |
135
+ | Directives | `kebab-case.directive.ts` | `click-outside.directive.ts` |
136
+ | Guards | `kebab-case.guard.ts` | `auth.guard.ts` |
137
+ | Interceptors | `kebab-case.interceptor.ts` | `error-handler.interceptor.ts` |
138
+
139
+ ### Code
140
+
141
+ | Type | Pattern | Example |
142
+ |------|---------|---------|
143
+ | Variables / functions | `camelCase` | `getUserById`, `isLoading` |
144
+ | Classes / Components | `PascalCase` | `UserProfile`, `MarketplaceListComponent` |
145
+ | Enums | `PascalCase` | `UserRole.Admin` |
146
+ | Constants | `UPPER_SNAKE_CASE` | `API_BASE_URL`, `MAX_RETRIES` |
147
+ | Services | `PascalCase + Service` | `MarketplaceService` |
148
+ | Stores | `PascalCase + Store` | `MarketplaceStore` |
149
+ | Selectors | `kebab-case` | `'app-marketplace-list'` |
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 make **only** the HTTP request via HttpClient. No try/catch, no transformation, no business logic.
160
+
161
+ ```typescript
162
+ // services/marketplace.service.ts
163
+ import { Injectable, inject } from '@angular/core'
164
+ import { HttpClient } from '@angular/common/http'
165
+ import type {
166
+ MarketplaceListResponse,
167
+ MarketplaceItemResponse,
168
+ CreateMarketplacePayload,
169
+ } from '../types/marketplace.types'
170
+
171
+ @Injectable({ providedIn: 'root' })
172
+ export class MarketplaceService {
173
+ private readonly http = inject(HttpClient)
174
+ private readonly baseUrl = '/api/marketplace'
175
+
176
+ list(params: { page: number; pageSize: number; search?: string }) {
177
+ return this.http.get<MarketplaceListResponse>(this.baseUrl, { params: { ...params } })
178
+ }
179
+
180
+ getById(id: string) {
181
+ return this.http.get<MarketplaceItemResponse>(`${this.baseUrl}/${id}`)
182
+ }
183
+
184
+ create(payload: CreateMarketplacePayload) {
185
+ return this.http.post<MarketplaceItemResponse>(this.baseUrl, payload)
186
+ }
187
+
188
+ delete(id: string) {
189
+ return this.http.delete(`${this.baseUrl}/${id}`)
190
+ }
191
+ }
192
+ ```
193
+
194
+ **Service Rules:**
195
+ - NO try/catch (caller handles errors)
196
+ - NO data transformation (adapter does that)
197
+ - NO business logic
198
+ - NO store or signal access
199
+ - YES HttpClient calls with typed request/response
200
+ - YES one file per domain/resource
201
+ - YES `@Injectable({ providedIn: 'root' })` with `inject()`
202
+
203
+ ### 4.2 Adapters -- Contract Parsers
204
+
205
+ Adapters transform API data to the application's TypeScript contract (and vice-versa). They are **pure functions** with no side effects.
206
+
207
+ ```typescript
208
+ // adapters/marketplace.adapter.ts
209
+ import type {
210
+ MarketplaceListResponse,
211
+ MarketplaceItemResponse,
212
+ } from '../types/marketplace.types'
213
+ import type {
214
+ MarketplaceItem,
215
+ MarketplaceList,
216
+ } from '../types/marketplace.contracts'
217
+
218
+ export const marketplaceAdapter = {
219
+ /**
220
+ * API response -> App contract (inbound)
221
+ */
222
+ toMarketplaceItem(response: MarketplaceItemResponse): MarketplaceItem {
223
+ return {
224
+ id: response.uuid,
225
+ name: response.name,
226
+ vendor: response.vendor_name,
227
+ category: response.category_slug,
228
+ price: response.price_cents / 100,
229
+ isActive: response.status === 'active',
230
+ createdAt: new Date(response.created_at),
231
+ updatedAt: new Date(response.updated_at),
232
+ }
233
+ },
234
+
235
+ toMarketplaceList(response: MarketplaceListResponse): MarketplaceList {
236
+ return {
237
+ items: response.results.map(marketplaceAdapter.toMarketplaceItem),
238
+ totalItems: response.count,
239
+ totalPages: Math.ceil(response.count / response.page_size),
240
+ currentPage: response.page,
241
+ }
242
+ },
243
+
244
+ /**
245
+ * App contract -> API payload (outbound)
246
+ */
247
+ toCreatePayload(item: CreateMarketplaceInput): CreateMarketplacePayload {
248
+ return {
249
+ name: item.name,
250
+ vendor_name: item.vendor,
251
+ category_slug: item.category,
252
+ price_cents: Math.round(item.price * 100),
253
+ }
254
+ },
255
+ }
256
+ ```
257
+
258
+ **Adapter Rules:**
259
+ - YES pure functions (input -> output, no side effects)
260
+ - YES two directions: API->App (inbound) and App->API (outbound)
261
+ - YES rename fields (snake_case API -> camelCase App)
262
+ - YES convert types (string->Date, cents->decimal, status->boolean)
263
+ - NO HTTP calls
264
+ - NO store/service access
265
+ - NO try/catch (failure = wrong type = bug to fix)
266
+
267
+ ### 4.3 Types & Contracts
268
+
269
+ ```typescript
270
+ // types/marketplace.types.ts
271
+ // <-- Types that mirror the API exactly as it returns (snake_case)
272
+
273
+ export interface MarketplaceItemResponse {
274
+ uuid: string
275
+ name: string
276
+ vendor_name: string
277
+ category_slug: string
278
+ price_cents: number
279
+ status: 'active' | 'inactive' | 'pending'
280
+ created_at: string
281
+ updated_at: string
282
+ }
283
+
284
+ export interface MarketplaceListResponse {
285
+ count: number
286
+ page: number
287
+ page_size: number
288
+ results: MarketplaceItemResponse[]
289
+ }
290
+
291
+ export interface CreateMarketplacePayload {
292
+ name: string
293
+ vendor_name: string
294
+ category_slug: string
295
+ price_cents: number
296
+ }
297
+
298
+ // types/marketplace.contracts.ts
299
+ // <-- Application contracts (camelCase, correct types)
300
+
301
+ export interface MarketplaceItem {
302
+ id: string
303
+ name: string
304
+ vendor: string
305
+ category: string
306
+ price: number // in currency, not cents
307
+ isActive: boolean // derived from status
308
+ createdAt: Date
309
+ updatedAt: Date
310
+ }
311
+
312
+ export interface MarketplaceList {
313
+ items: MarketplaceItem[]
314
+ totalItems: number
315
+ totalPages: number
316
+ currentPage: number
317
+ }
318
+
319
+ export interface CreateMarketplaceInput {
320
+ name: string
321
+ vendor: string
322
+ category: string
323
+ price: number
324
+ }
325
+ ```
326
+
327
+ ### 4.4 Signal Stores -- Client State Only
328
+
329
+ Signal stores manage state that **does not come from the server**: UI state, filters, preferences, auth tokens.
330
+
331
+ ```typescript
332
+ // stores/marketplace.store.ts
333
+ import { Injectable, signal, computed } from '@angular/core'
334
+
335
+ @Injectable({ providedIn: 'root' })
336
+ export class MarketplaceStore {
337
+ // State (private writable signals)
338
+ private readonly _selectedCategory = signal<string | null>(null)
339
+ private readonly _viewMode = signal<'grid' | 'list'>('grid')
340
+ private readonly _searchQuery = signal('')
341
+
342
+ // Public read-only signals
343
+ readonly selectedCategory = this._selectedCategory.asReadonly()
344
+ readonly viewMode = this._viewMode.asReadonly()
345
+ readonly searchQuery = this._searchQuery.asReadonly()
346
+
347
+ // Computed
348
+ readonly hasActiveFilters = computed(() =>
349
+ !!this._selectedCategory() || !!this._searchQuery()
350
+ )
351
+
352
+ // Actions
353
+ setCategory(category: string | null) {
354
+ this._selectedCategory.set(category)
355
+ }
356
+
357
+ setViewMode(mode: 'grid' | 'list') {
358
+ this._viewMode.set(mode)
359
+ }
360
+
361
+ setSearchQuery(query: string) {
362
+ this._searchQuery.set(query)
363
+ }
364
+
365
+ clearFilters() {
366
+ this._selectedCategory.set(null)
367
+ this._searchQuery.set('')
368
+ }
369
+ }
370
+ ```
371
+
372
+ **Store Rules:**
373
+ - YES client state only (UI, filters, preferences, session)
374
+ - YES `@Injectable({ providedIn: 'root' })` with signals
375
+ - YES private WritableSignal, public asReadonly()
376
+ - YES computed() for derived values
377
+ - NO server state (API data is fetched via services and managed locally)
378
+ - NO HTTP calls inside stores
379
+ - NO complex business logic (services or components handle that)
380
+
381
+ ### 4.5 Components -- Standalone with Signals
382
+
383
+ ```typescript
384
+ // components/marketplace-list.component.ts
385
+ import { Component, inject, input, output, signal, computed } from '@angular/core'
386
+ import { MarketplaceService } from '../services/marketplace.service'
387
+ import { marketplaceAdapter } from '../adapters/marketplace.adapter'
388
+ import { MarketplaceStore } from '../stores/marketplace.store'
389
+ import { MarketplaceCardComponent } from './marketplace-card.component'
390
+ import type { MarketplaceItem } from '../types/marketplace.contracts'
391
+
392
+ @Component({
393
+ selector: 'app-marketplace-list',
394
+ standalone: true,
395
+ imports: [MarketplaceCardComponent],
396
+ template: `
397
+ @if (isLoading()) {
398
+ <div>Loading...</div>
399
+ } @else if (isEmpty()) {
400
+ <div>No items found</div>
401
+ } @else {
402
+ @for (item of items(); track item.id) {
403
+ <app-marketplace-card
404
+ [item]="item"
405
+ [isSelected]="item.id === selectedId()"
406
+ (select)="handleSelect($event)"
407
+ />
408
+ }
409
+ }
410
+ `,
411
+ })
412
+ export class MarketplaceListComponent {
413
+ // Inputs / Outputs (signal-based)
414
+ readonly categoryFilter = input<string>()
415
+ readonly select = output<MarketplaceItem>()
416
+
417
+ // Injected dependencies
418
+ private readonly service = inject(MarketplaceService)
419
+ private readonly store = inject(MarketplaceStore)
420
+
421
+ // Local state
422
+ readonly page = signal(1)
423
+ readonly selectedId = signal<string | null>(null)
424
+ readonly items = signal<MarketplaceItem[]>([])
425
+ readonly isLoading = signal(false)
426
+
427
+ // Computed
428
+ readonly isEmpty = computed(() => !this.isLoading() && this.items().length === 0)
429
+ readonly isFirstPage = computed(() => this.page() === 1)
430
+
431
+ // Handlers
432
+ handleSelect(item: MarketplaceItem) {
433
+ this.selectedId.set(item.id)
434
+ this.select.emit(item)
435
+ }
436
+
437
+ handlePageChange(newPage: number) {
438
+ this.page.set(newPage)
439
+ }
440
+ }
441
+ ```
442
+
443
+ ---
444
+
445
+ ## 5. Component Patterns
446
+
447
+ ### 5.1 Stop Prop Drilling -- Component Composition
448
+
449
+ **BAD -- Prop Drilling:**
450
+ ```html
451
+ <!-- GrandParent passes data through 3 levels -->
452
+ <app-parent [user]="user" [theme]="theme" [permissions]="permissions">
453
+ <app-child [user]="user" [theme]="theme" [permissions]="permissions">
454
+ <app-grandchild [user]="user" [permissions]="permissions" />
455
+ </app-child>
456
+ </app-parent>
457
+ ```
458
+
459
+ **GOOD -- Composition with content projection:**
460
+ ```typescript
461
+ // marketplace-page.component.ts
462
+ @Component({
463
+ selector: 'app-marketplace-page',
464
+ standalone: true,
465
+ imports: [PageLayoutComponent, MarketplaceFiltersComponent, MarketplaceListComponent, MarketplaceDetailsComponent],
466
+ template: `
467
+ <app-page-layout>
468
+ <ng-container header>
469
+ <app-marketplace-filters />
470
+ </ng-container>
471
+
472
+ <app-marketplace-list (select)="handleSelect($event)" />
473
+
474
+ @if (selectedItem()) {
475
+ <ng-container sidebar>
476
+ <app-marketplace-details [item]="selectedItem()!" />
477
+ </ng-container>
478
+ }
479
+ </app-page-layout>
480
+ `,
481
+ })
482
+ export class MarketplacePageComponent {
483
+ readonly selectedItem = signal<MarketplaceItem | null>(null)
484
+
485
+ handleSelect(item: MarketplaceItem) {
486
+ this.selectedItem.set(item)
487
+ }
488
+ }
489
+ ```
490
+
491
+ **GOOD -- Shared injectable for cross-component state:**
492
+ ```typescript
493
+ // stores/marketplace-context.store.ts
494
+ import { Injectable, signal, computed } from '@angular/core'
495
+ import type { MarketplaceItem } from '../types/marketplace.contracts'
496
+
497
+ @Injectable()
498
+ export class MarketplaceContextStore {
499
+ private readonly _selectedItem = signal<MarketplaceItem | null>(null)
500
+
501
+ readonly selectedItem = this._selectedItem.asReadonly()
502
+ readonly hasSelection = computed(() => this._selectedItem() !== null)
503
+
504
+ selectItem(item: MarketplaceItem) {
505
+ this._selectedItem.set(item)
506
+ }
507
+
508
+ clearSelection() {
509
+ this._selectedItem.set(null)
510
+ }
511
+ }
512
+
513
+ // Provide in the page component:
514
+ @Component({
515
+ providers: [MarketplaceContextStore],
516
+ // ...
517
+ })
518
+ export class MarketplacePageComponent {
519
+ private readonly context = inject(MarketplaceContextStore)
520
+ }
521
+ ```
522
+
523
+ ### 5.2 Component Hierarchy
524
+
525
+ ```
526
+ Pages --> Composition, orchestration, provide context
527
+ +-- Layout --> Visual structure (content projection)
528
+ +-- Features --> Feature logic (services, stores, signals)
529
+ +-- Shared --> Pure presentation (inputs in, outputs out)
530
+ ```
531
+
532
+ | Type | Responsibility | Can have logic? | Can have state? |
533
+ |------|---------------|-----------------|-----------------|
534
+ | **Pages** | Compose components, provide context | Via services/stores | Yes (signals) |
535
+ | **Feature Components** | UI + feature logic | Via services/stores | Yes (signals) |
536
+ | **Shared Components** | Generic, reusable UI | Minimal (UI only) | Minimal (local) |
537
+
538
+ ---
539
+
540
+ ## 6. Utils vs Helpers
541
+
542
+ ### Utils -- Pure Functions
543
+ - No side effects
544
+ - Deterministic input -> output
545
+ - Testable without mocks
546
+ - No dependency on DOM, browser APIs, or Angular
547
+
548
+ ```typescript
549
+ // shared/utils/format-date.ts
550
+ export function formatDate(date: Date, locale = 'en-US'): string {
551
+ return new Intl.DateTimeFormat(locale).format(date)
552
+ }
553
+
554
+ // shared/utils/currency.ts
555
+ export function formatCurrency(value: number, currency = 'USD'): string {
556
+ return new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(value)
557
+ }
558
+
559
+ // shared/utils/string.ts
560
+ export function slugify(text: string): string {
561
+ return text.toLowerCase().replace(/\s+/g, '-').replace(/[^\w-]/g, '')
562
+ }
563
+ ```
564
+
565
+ ### Helpers -- Functions with Side Effects or DOM
566
+ - Interact with browser APIs (clipboard, localStorage, DOM)
567
+ - May have side effects
568
+ - May need mocks in tests
569
+
570
+ ```typescript
571
+ // shared/helpers/clipboard-helper.ts
572
+ export async function copyToClipboard(text: string): Promise<boolean> {
573
+ try {
574
+ await navigator.clipboard.writeText(text)
575
+ return true
576
+ } catch {
577
+ return false
578
+ }
579
+ }
580
+
581
+ // shared/helpers/download-helper.ts
582
+ export function downloadAsFile(content: string, filename: string): void {
583
+ const blob = new Blob([content], { type: 'text/plain' })
584
+ const url = URL.createObjectURL(blob)
585
+ const a = document.createElement('a')
586
+ a.href = url
587
+ a.download = filename
588
+ a.click()
589
+ URL.revokeObjectURL(url)
590
+ }
591
+
592
+ // shared/helpers/storage-helper.ts
593
+ export function getStorageItem<T>(key: string, fallback: T): T {
594
+ try {
595
+ const item = localStorage.getItem(key)
596
+ return item ? (JSON.parse(item) as T) : fallback
597
+ } catch {
598
+ return fallback
599
+ }
600
+ }
601
+ ```
602
+
603
+ ---
604
+
605
+ ## 7. Error Handling -- Centralized Pattern
606
+
607
+ ### Global HttpInterceptor
608
+
609
+ ```typescript
610
+ // app/interceptors/error-handler.interceptor.ts
611
+ import { HttpInterceptorFn, HttpErrorResponse } from '@angular/common/http'
612
+ import { inject } from '@angular/core'
613
+ import { Router } from '@angular/router'
614
+ import { catchError, throwError } from 'rxjs'
615
+
616
+ export const errorHandlerInterceptor: HttpInterceptorFn = (req, next) => {
617
+ const router = inject(Router)
618
+
619
+ return next(req).pipe(
620
+ catchError((error: HttpErrorResponse) => {
621
+ // Only redirect on 401 (session expired)
622
+ if (error.status === 401) {
623
+ router.navigate(['/login'])
624
+ }
625
+ // DO NOT handle other errors here -- let the caller handle them
626
+ return throwError(() => error)
627
+ }),
628
+ )
629
+ }
630
+ ```
631
+
632
+ ### Service-Level Error Handling (in components)
633
+
634
+ ```typescript
635
+ // In the component that subscribes:
636
+ this.service.delete(id).subscribe({
637
+ next: () => {
638
+ // success: refresh data, show toast
639
+ },
640
+ error: (error) => {
641
+ // handle error: show toast with parseApiError(error)
642
+ },
643
+ })
644
+ ```
645
+
646
+ ### Centralized Error Parser
647
+
648
+ ```typescript
649
+ // shared/utils/parse-api-error.ts
650
+ import { HttpErrorResponse } from '@angular/common/http'
651
+
652
+ interface ApiErrorResponse {
653
+ message?: string
654
+ detail?: string
655
+ errors?: Record<string, string[]>
656
+ }
657
+
658
+ export function parseApiError(error: unknown): string {
659
+ if (error instanceof HttpErrorResponse) {
660
+ const data = error.error as ApiErrorResponse | undefined
661
+ if (data?.message) return data.message
662
+ if (data?.detail) return data.detail
663
+ if (error.status === 403) return 'Permission denied'
664
+ if (error.status === 404) return 'Resource not found'
665
+ if (error.status === 500) return 'Internal server error'
666
+ }
667
+ return 'Unexpected error. Please try again.'
668
+ }
669
+ ```
670
+
671
+ ---
672
+
673
+ ## 8. Barrel Exports (index.ts)
674
+
675
+ Each module exports only its **public API**:
676
+
677
+ ```typescript
678
+ // modules/marketplace/index.ts
679
+
680
+ // Pages (for the router)
681
+ export { MarketplacePageComponent } from './pages/marketplace-page.component'
682
+
683
+ // Components reusable by others (rare, avoid)
684
+ export { MarketplaceCardComponent } from './components/marketplace-card.component'
685
+
686
+ // Types (for consumers that need typing)
687
+ export type { MarketplaceItem, MarketplaceList } from './types/marketplace.contracts'
688
+
689
+ // DO NOT export:
690
+ // - services (internal detail)
691
+ // - adapters (internal detail)
692
+ // - stores (internal detail)
693
+ // - internal components
694
+ ```
695
+
696
+ ---
697
+
698
+ ## 9. SOLID Principles Applied to Angular
699
+
700
+ | Principle | Angular Application |
701
+ |-----------|---------------------|
702
+ | **S**ingle Responsibility | 1 component = 1 responsibility. 1 service = 1 resource. 1 store = 1 domain. |
703
+ | **O**pen/Closed | Components extensible via content projection (ng-content) and inputs -- not by internal modification. |
704
+ | **L**iskov Substitution | Shared components must work in any context without breaking. |
705
+ | **I**nterface Segregation | Specific inputs, not generic objects. `<app-avatar [src]="src" [alt]="alt" />` not `<app-avatar [user]="user" />`. |
706
+ | **D**ependency Inversion | Components depend on abstractions (injection tokens), not concrete implementations. Services injected via inject(), never instantiated directly. |
707
+
708
+ ### SOLID Examples
709
+
710
+ **Single Responsibility:**
711
+ ```typescript
712
+ // BAD: component doing too much
713
+ @Component({ /* ... */ })
714
+ export class UserDashboardComponent {
715
+ // fetching data, filtering, rendering chart, rendering table, handling forms...
716
+ }
717
+
718
+ // GOOD: composed from focused components
719
+ @Component({
720
+ template: `
721
+ <app-dashboard-layout>
722
+ <app-user-stats />
723
+ <app-user-activity-chart />
724
+ <app-user-table />
725
+ </app-dashboard-layout>
726
+ `,
727
+ })
728
+ export class UserDashboardComponent {}
729
+ ```
730
+
731
+ **Open/Closed:**
732
+ ```typescript
733
+ // GOOD: extensible via content projection and inputs
734
+ @Component({
735
+ selector: 'app-data-table',
736
+ template: `
737
+ @if (items().length === 0) {
738
+ <ng-content select="[empty]" />
739
+ } @else {
740
+ <table>
741
+ <ng-content select="[header]" />
742
+ <tbody>
743
+ @for (item of items(); track trackFn(item)) {
744
+ <ng-content />
745
+ }
746
+ </tbody>
747
+ </table>
748
+ }
749
+ `,
750
+ })
751
+ export class DataTableComponent<T> {
752
+ readonly items = input.required<T[]>()
753
+ readonly trackFn = input.required<(item: T) => unknown>()
754
+ }
755
+ ```
756
+
757
+ **Interface Segregation:**
758
+ ```typescript
759
+ // BAD: passing entire object when only a few fields are needed
760
+ @Component({ /* ... */ })
761
+ export class AvatarComponent {
762
+ readonly user = input.required<User>() // component only uses name and avatarUrl
763
+ }
764
+
765
+ // GOOD: specific inputs
766
+ @Component({ /* ... */ })
767
+ export class AvatarComponent {
768
+ readonly src = input.required<string>()
769
+ readonly alt = input.required<string>()
770
+ readonly size = input<'sm' | 'md' | 'lg'>('md')
771
+ }
772
+ ```
773
+
774
+ ---
775
+
776
+ ## 10. Migration Checklist per File
777
+
778
+ ### Component (.component.ts)
779
+ - [ ] Standalone component (no NgModule)
780
+ - [ ] input() / output() signal-based I/O
781
+ - [ ] inject() instead of constructor DI
782
+ - [ ] No prop drilling (use content projection / shared injectable)
783
+ - [ ] < 200 lines total
784
+ - [ ] Template < 100 lines
785
+ - [ ] No business logic in template
786
+ - [ ] Loading / error / empty states
787
+ - [ ] OnPush change detection strategy
788
+ - [ ] trackBy function for @for loops
789
+
790
+ ### Service (.service.ts)
791
+ - [ ] HttpClient calls only
792
+ - [ ] No try/catch
793
+ - [ ] No data transformation
794
+ - [ ] Typed request and response
795
+ - [ ] inject(HttpClient) instead of constructor
796
+ - [ ] `@Injectable({ providedIn: 'root' })`
797
+
798
+ ### Adapter (.adapter.ts)
799
+ - [ ] Pure functions
800
+ - [ ] Inbound (API->App) and Outbound (App->API)
801
+ - [ ] Naming conversion (snake_case -> camelCase)
802
+ - [ ] Type conversion (string->Date, etc.)
803
+
804
+ ### Store (.store.ts)
805
+ - [ ] Client state only
806
+ - [ ] Private WritableSignal, public asReadonly()
807
+ - [ ] computed() for derived values
808
+ - [ ] inject() for dependencies
809
+ - [ ] No HTTP calls
810
+
811
+ ### Types
812
+ - [ ] `.types.ts` for API types (raw response)
813
+ - [ ] `.contracts.ts` for application contracts
814
+ - [ ] No `any`