跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
浏览器与自动化

angular

Angular architecture. NgRx, Signals, RxJS, standalone components, lazy loading, dependency injection, Jasmine, Jest.

arbazkhan971 · 已有静态检查记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add arbazkhan971/godmode --skill angular

技能说明


name: angular description: Angular architecture. NgRx, Signals, RxJS, standalone components, lazy loading, dependency injection, Jasmine, Jest.

Angular — Angular Architecture

Activate When

  • User invokes /godmode:angular
  • User says "build an Angular app", "Angular component", "NgRx", "Angular signals", "RxJS"
  • User says "standalone components", "Angular modules", "lazy loading"
  • When creating or scaffolding an Angular application
  • When /godmode:plan or /godmode:review identifies Angular work

Workflow

Step 1: Project Discovery

ANGULAR PROJECT ASSESSMENT:
Angular version: <14-18+>
Architecture: <NgModule | Standalone | Mixed>
State: <NgRx | Signals | Services | NGXS | none>
Routing: <Lazy-loaded modules | Standalone routes | eager>
UI: <Angular Material | PrimeNG | ng-bootstrap | custom>
Testing: <Jasmine+Karma | Jest | Vitest>
Build: <Angular CLI esbuild | Nx | custom>
SSR: <Angular SSR v17+ | Universal | none>
TypeScript strict: <yes | no>

If starting fresh, ask: "What are you building? SSR needed? Scale (enterprise vs small)?"

Step 2: NgModules vs Standalone

DECISION:
  NgModules: All versions, high boilerplate, module imports, loadChildren, well-established enterprise
  Standalone: 14+ (mature 17+), low boilerplate, component imports, loadComponent, better tree-shaking

RULES:
- New projects Angular 17+: default to standalone
- Existing NgModule projects: migrate incrementally with standalone: true
- Mixed is acceptable during migration — establish timeline to complete

Step 3: Component Architecture

Use OnPush change detection on all components. Signal-based inputs/outputs on Angular 17+. Smart vs presentational split. One component per file. Consistent selector prefix.

Standalone pattern (Angular 17+): @Component({ standalone: true, imports: [...], changeDetection: OnPush }) with input(), output(), computed(), inject().

NgModule pattern (legacy): @Component({ changeDetection: OnPush }) with @Input(), @Output(), EventEmitter.

Step 4: RxJS & State Management

RXJS PATTERNS:
  switchMap (search/nav), concatMap (sequential mutations), forkJoin (parallel+all),
  combineLatest (merge reactive), debounceTime (search-as-you-type),
  distinctUntilChanged (filter unchanged), shareReplay(1) (cache), retry(3),
  takeUntilDestroyed (auto-unsubscribe)

STATE MANAGEMENT DECISION:
  Signals → component/local state (low complexity)
  Services + RxJS → shared state, medium apps
  NgRx → large enterprise, complex async flows, time-travel debugging
  NgRx SignalStore → feature stores, simpler NgRx

RULE: Start with Signals. Escalate to Services+RxJS for shared state.
Only NgRx for complex async flows or strict unidirectional requirements.

Step 5: Dependency Injection

inject() over constructor injection (cleaner, works in functions)
providedIn: 'root' for singletons (tree-shakeable)
Component-level providers for scoped services
InjectionTokens for configuration (never inject plain strings)
Abstract classes as interfaces (Angular DI works with abstract classes, not TS interfaces)

Step 6: Lazy Loading & Performance

LAZY LOADING: Every feature route uses loadChildren or loadComponent. Eager only for shell.
Standalone routes: loadComponent: () => import('./feature.component').then(m => m.Component)

SELECTIVE PRELOADING: route.data['preload'] ? load() : EMPTY

PERFORMANCE AUDIT:
[ ] OnPush on all components          [ ] Lazy loading for feature routes
[ ] trackBy on all *ngFor / @for      [ ] Signals for local state
[ ] No subscriptions without cleanup  [ ] Bundle budget configured
[ ] NgOptimizedImage for images       [ ] SSR/prerendering for public routes
[ ] Zoneless evaluated                [ ] No unnecessary re-renders

Step 7: Build Optimization

Use @angular-devkit/build-angular:application (esbuild). Budget: initial 500kB warning, 1MB error. Source maps off in prod. Named chunks off in prod.

Step 8: Testing

STRATEGY: Unit (Jest/Jasmine, >80%), Component (TestBed+Jest, all smart), Integration (service+store), E2E (Playwright)
RULES: jest-preset-angular for Jest, setInput() for signal inputs, httpMock.verify() in afterEach,
  provideMockActions+provideMockStore for NgRx, explicit change detection for OnPush.
THRESHOLDS: statements 80%, branches 70%, functions 80%, lines 80%

Step 9: Validation

ANGULAR AUDIT:
[ ] OnPush on all components           [ ] Standalone (if 17+)
[ ] Signal inputs/outputs (if 17+)     [ ] inject() over constructors
[ ] Lazy loading all feature routes    [ ] trackBy on all ngFor/@for
[ ] No subscriptions without cleanup   [ ] TypeScript strict mode
[ ] Bundle budgets configured          [ ] Core/shared/feature separation
[ ] No circular dependencies           [ ] Smart vs presentational split
[ ] HTTP interceptors for cross-cutting [ ] Global error handler
[ ] Test coverage meets thresholds     [ ] No console.log in production
VERDICT: PASS | NEEDS REVISION

Step 10: Deliverables

ANGULAR COMPLETE:
Components: <N> (OnPush: <M>%), Services: <N>, Routes: <N> (<N> lazy)
State: <Signals|NgRx|Services>, Tests: <N> files, <M>% coverage
Audit: PASS | NEEDS REVISION

Commit: "angular: <project> — <N> components, <architecture>, <state management>"

Key Behaviors

  1. Standalone by default. New 17+ projects use standalone. NgModules are legacy; migrate incrementally.
  2. Signals for local, NgRx for global. Don't use NgRx for a counter. Don't use signals for complex async.
  3. OnPush everything. No exceptions. Fix reactivity at source.
  4. Unsubscribe from everything. takeUntilDestroyed(), async pipe, or DestroyRef.
  5. inject() over constructors. Cleaner, works in functions, Angular-recommended.
  6. Lazy-load all features. Eager only for the shell.
  7. Type everything strictly. Strict mode, interfaces, generics. No any.

Flags & Options

FlagDescription
(none)Full project
阅读完整来源 ↗