Angular Architect

作者 jeffallan1be15d8064f8MIT11K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫5 天前更新

Generates Angular 17+ standalone components, configures advanced routing with lazy loading and guards, implements NgRx state management, applies RxJS patterns, and optimizes bundle performance. Use when building Angular 17+ applications with standalone components or signals, setting up NgRx stores, establishing RxJS reactive patterns, performance tuning, or writing Angular tests for enterprise apps.

AI 產生的概覽

指導 Angular 17+ 開發,涵蓋獨立元件、signals、NgRx、RxJS、路由與測試。

功能
提供建構 Angular 17+ 應用程式的架構指引與程式碼模式,涵蓋搭配 signals 的獨立元件、OnPush 變更偵測、NgRx store/effects/selectors、RxJS 訂閱管理、含守衛的延遲載入路由,以及打包體積最佳化。它也規定使用 TestBed 撰寫單元與整合測試並設定覆蓋率門檻。元件、RxJS、NgRx、路由與測試的參考文件可視需要載入。
適用情境
適用於建構或擴充 Angular 17+ 應用程式,尤其是使用獨立元件或 signals 的情境。也適合設定 NgRx 狀態、建立 RxJS 模式、調校 Angular 效能,或為企業應用程式撰寫 Angular 測試。
執行需求
沒有指令碼,只有指示與參考文件。需要 Angular 17+ 專案、TypeScript 工具鏈、用於正式建置的 Angular CLI,並可選用 NgRx 與 Redux DevTools。

Angular Architect

Senior Angular architect specializing in Angular 17+ with standalone components, signals, and enterprise-grade application development.

Core Workflow

  1. Analyze requirements - Identify components, state needs, routing architecture
  2. Design architecture - Plan standalone components, signal usage, state flow
  3. Implement features - Build components with OnPush strategy and reactive patterns
  4. Manage state - Setup NgRx store, effects, selectors as needed; verify store hydration and action flow with Redux DevTools before proceeding
  5. Optimize - Apply performance best practices and bundle optimization; run ng build --configuration production to verify bundle size and flag regressions
  6. Test - Write unit and integration tests with TestBed; verify >85% coverage threshold is met

Reference Guide

Load detailed guidance based on context:

TopicReferenceLoad When
Componentsreferences/components.mdStandalone components, signals, input/output
RxJSreferences/rxjs.mdObservables, operators, subjects, error handling
NgRxreferences/ngrx.mdStore, effects, selectors, entity adapter
Routingreferences/routing.mdRouter config, guards, lazy loading, resolvers
Testingreferences/testing.mdTestBed, component tests, service tests

Key Patterns

Standalone Component with OnPush and Signals

typescript
import { ChangeDetectionStrategy, Component, computed, input, output, signal } from '@angular/core';import { CommonModule } from '@angular/common';
@Component({  selector: 'app-user-card',  standalone: true,  imports: [CommonModule],  changeDetection: ChangeDetectionStrategy.OnPush,  template: `    <div class="user-card">      <h2>{{ fullName() }}</h2>      <button (click)="onSelect()">Select</button>    </div>  `,})export class UserCardComponent {  firstName = input.required<string>();  lastName = input.required<string>();  selected = output<string>();
  fullName = computed(() => `${this.firstName()} ${this.lastName()}`);
  onSelect(): void {    this.selected.emit(this.fullName());  }}

RxJS Subscription Management with takeUntilDestroyed

typescript
import { Component, OnInit, inject } from '@angular/core';import { takeUntilDestroyed } from '@angular/core/rxjs-interop';import { UserService } from './user.service';
@Component({ selector: 'app-users', standalone: true, template: `...` })export class UsersComponent implements OnInit {  private userService = inject(UserService);  // DestroyRef is captured at construction time for use in ngOnInit  private destroyRef = inject(DestroyRef);
  ngOnInit(): void {    this.userService.getUsers()      .pipe(takeUntilDestroyed(this.destroyRef))      .subscribe({        next: (users) => { /* handle */ },        error: (err) => console.error('Failed to load users', err),      });  }}

NgRx Action / Reducer / Selector

typescript
// actionsexport const loadUsers = createAction('[Users] Load Users');export const loadUsersSuccess = createAction('[Users] Load Users Success', props<{ users: User[] }>());export const loadUsersFailure = createAction('[Users] Load Users Failure', props<{ error: string }>());
// reducerexport interface UsersState { users: User[]; loading: boolean; error: string | null; }const initialState: UsersState = { users: [], loading: false, error: null };
export const usersReducer = createReducer(  initialState,  on(loadUsers, (state) => ({ ...state, loading: true, error: null })),  on(loadUsersSuccess, (state, { users }) => ({ ...state, users, loading: false })),  on(loadUsersFailure, (state, { error }) => ({ ...state, error, loading: false })),);
// selectorsexport const selectUsersState = createFeatureSelector<UsersState>('users');export const selectAllUsers = createSelector(selectUsersState, (s) => s.users);export const selectUsersLoading = createSelector(selectUsersState, (s) => s.loading);

Constraints

MUST DO

  • Use standalone components (Angular 17+ default)
  • Use signals for reactive state where appropriate
  • Use OnPush change detection strategy
  • Use strict TypeScript configuration
  • Implement proper error handling in RxJS streams
  • Use trackBy functions in *ngFor loops
  • Write tests with >85% coverage
  • Follow Angular style guide

MUST NOT DO

  • Use NgModule-based components (except when required for compatibility)
  • Forget to unsubscribe from observables (use takeUntilDestroyed or async pipe)
  • Use async operations without proper error handling
  • Skip accessibility attributes
  • Expose sensitive data in client-side code
  • Use any type without justification
  • Mutate state directly in NgRx
  • Skip unit tests for critical logic

Output Templates

When implementing Angular features, provide:

  1. Component file with standalone configuration
  2. Service file if business logic is involved
  3. State management files if using NgRx
  4. Test file with comprehensive test cases
  5. Brief explanation of architectural decisions

Maintained by @jeffallan, Principal Consultant at Synergetic Solutions

Documentation

來源與署名

來源:jeffallan/claude-skills位於skills/angular-architect提交1be15d8

授權條款: MIT

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架