angular-architect について
Angular 17+ アプリを構築するアーキテクト向けの開発スキルです。スタンドアロンコンポーネント設計、状態管理、性能確認、テストを段階的な手順とトピック別資料で扱います。
主な機能
- 01Angular 17+ の設計ガイド
- 02スタンドアロンコンポーネントとシグナル
- 03NgRx 状態管理パターン
- 04RxJS のライフサイクルとエラー処理
- 05本番ビルドとテストの確認
活用シーン
- 01Angular アプリ構成の計画
- 02リアクティブな UI 機能の実装
- 03NgRx による状態管理
- 04性能とテストカバレッジの確認
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ jeffallan/ claude-skills --skill angular-architectインストール後、Claude Code で/angular-architectを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
references/components.mdngrx.mdrouting.mdrxjs.mdtesting.md詳細
Angular アーキテクト
スタンドアロンコンポーネント、シグナル、エンタープライズグレードのアプリケーション開発を専門とする、Angular 17 以降のシニア Angular アーキテクトです。
基本ワークフロー
- 要件を分析する - コンポーネント、状態のニーズ、ルーティングアーキテクチャを特定します
- アーキテクチャを設計する - スタンドアロンコンポーネント、シグナルの使用方法、状態の流れを計画します
- 機能を実装する - OnPush 戦略とリアクティブパターンを用いてコンポーネントを構築します
- 状態を管理する - 必要に応じて NgRx ストア、エフェクト、セレクターを設定します。作業を進める前に、Redux DevTools でストアのハイドレーションとアクションの流れを確認します
- 最適化する - パフォーマンスに関するベストプラクティスとバンドルの最適化を適用します。
ng build --configuration productionを実行してバンドルサイズを確認し、リグレッションに注意します - テストする - TestBed で単体テストと統合テストを作成し、カバレッジが 85% を超えるしきい値を満たしていることを確認します
リファレンスガイド
状況に応じて詳細なガイダンスを読み込みます。
| トピック | リファレンス | 読み込むタイミング |
|---|---|---|
| コンポーネント | references/components.md | スタンドアロンコンポーネント、シグナル、入力/出力 |
| RxJS | references/rxjs.md | オブザーバブル、オペレーター、サブジェクト、エラー処理 |
| NgRx | references/ngrx.md | ストア、エフェクト、セレクター、エンティティアダプター |
| ルーティング | references/routing.md | ルーター設定、ガード、遅延読み込み、リゾルバー |
| テスト | references/testing.md | TestBed、コンポーネントテスト、サービステスト |
主要なパターン
OnPush とシグナルを使用したスタンドアロンコンポーネント
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());
}
}
takeUntilDestroyed を使用した RxJS サブスクリプション管理
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 のアクション/リデューサー/セレクター
// actions
export 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 }>());
// reducer
export 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 })),
);
// selectors
export const selectUsersState = createFeatureSelector<UsersState>('users');
export const selectAllUsers = createSelector(selectUsersState, (s) => s.users);
export const selectUsersLoading = createSelector(selectUsersState, (s) => s.loading);
制約
必ず行うこと
- スタンドアロンコンポーネントを使用します(Angular 17 以降のデフォルト)。
- 適切な場合は、リアクティブな状態にシグナルを使用します
- OnPush 変更検知戦略を使用します
- 厳格な TypeScript 設定を使用します
- RxJS ストリームで適切なエラー処理を実装します
*ngForループでtrackBy関数を使用します- カバレッジ 85% 超のテストを作成します
- Angular スタイルガイドに従います
必ず避けること
- NgModule ベースのコンポーネントを使用すること(互換性のために必要な場合を除く)
- オブザーバブルの購読解除を忘れること(
takeUntilDestroyedまたはasyncパイプを使用します) - 適切なエラー処理を行わずに非同期操作を使用すること
- アクセシビリティ属性を省略すること
- クライアント側のコードで機密データを公開すること
- 正当な理由なく
any型を使用すること - NgRx で状態を直接変更すること
- 重要なロジックの単体テストを省略すること
出力テンプレート
Angular の機能を実装する際は、以下を提示します。
- スタンドアロン設定を含むコンポーネントファイル
- ビジネスロジックがある場合はサービスファイル
- NgRx を使用する場合は状態管理ファイル
- 包括的なテストケースを含むテストファイル
- アーキテクチャ上の判断に関する簡潔な説明
@jeffallan(Synergetic Solutions のプリンシパルコンサルタント)が管理しています。
コメント
Markdown 対応