Command Palette

Search for a command to run...

Назад к скиллам
скилл № 39703

angular-patterns

Use when the user asks about Angular HTTP interceptors, route guards, resolvers, services and DI, RxJS vs signals, NgRx or Signal Store, custom directives or…

БесплатноБез исполняемых скриптов
j4flmaoот j4flmao★ 47 звёзд на GitHub

Установить angular-patterns в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Angular Patterns

Purpose

Implement Angular-specific patterns: HTTP interceptors for cross-cutting, guards for navigation control, Signals for sync state, RxJS for async streams, Signal Store over NgRx unless complexity demands it.

Agent Protocol

Trigger

Exact user phrases: "Angular DI", "Angular service", "Angular interceptor", "Angular guard", "Angular RxJS", "NgRx", "Angular store", "Angular resolver", "Angular pipe", "Angular directive", "Observable vs Signal".

Input Context

Before activating, verify:

  • angular.json exists (Angular 17+).
  • The pattern being implemented is known (interceptor, guard, store, etc.).

Output Artifact

No file output. Produces code examples as text.

Response Format

Pattern: {name}
Purpose: {one sentence}
Code: {implementation}
Registration: {where to provide/register}

No preamble. No postamble. No explanations. No filler/hedging/transitions. Compress output — why use many token when few do trick.

Completion Criteria

  • Interceptors handle cross-cutting concerns only (auth headers, error handling, logging).
  • Guards decide navigation access (no side effects).
  • Signals used for component state, RxJS used for async streams.
  • Signal Store chosen over NgRx for most applications.
  • Custom directives and pipes are pure, side-effect-free.
  • inject() used for DI everywhere.

Max Response Length

Per pattern: 20 lines.

Component Architecture / Decision Trees

Architecture Options

Approach Trade-off When to Use
Standalone components (ng new default since v17; implicit standalone: true since v19) No NgModules, simpler New projects, new features
NgModules-based Legacy, shared declarations Existing Angular <17 projects
Signal Store (manual or @ngrx/signals) Lighter than NgRx Small-medium apps, CRUD
NgRx (Store + Effects + Entity) Full Redux pattern Large apps, complex side effects
Component Store (@ngrx/component-store) Local state management Feature-scoped state
Presentational + Container Components Separates logic from UI Complex feature components

Decision Tree: State Management

How complex is the state?
  ├── Simple (component-local) -> signal() or BehaviorSubject
  ├── Medium (feature-scoped) -> Signal Store or Component Store
  └── Complex (cross-feature, many side effects) -> NgRx
Does async data control the flow?
  ├── Yes (HTTP, WebSocket, events) -> RxJS Observables
  ├── No (UI state, toggles, selections) -> Signals
  └── Both -> RxJS for streams, Signals for sync state

Decision Tree: Dependency Injection

Is this a reusable service with multiple implementations?
  ├── Yes -> Provide with useClass, useExisting, or useFactory
  ├── Yes -> Inject with InjectionToken and @Optional()
  └── No -> providedIn: 'root' singleton

Common Pitfalls

Pitfall 1: Manual Subscription Management

// Wrong — manual subscribe, easy to forget unsubscribe
this.route.params.subscribe(params => this.id = params['id'])

// Correct — automatic cleanup
this.route.params.pipe(takeUntilDestroyed()).subscribe(params => this.id = params['id'])

Always use takeUntilDestroyed() (Angular 16+) or the async pipe. Never manually manage subscriptions in components.

Pitfall 2: Business Logic in Interceptors

Interceptors should handle cross-cutting concerns only:

  • Adding auth headers
  • Logging errors
  • Timing requests Do NOT put business logic (redirect logic based on response data, data transformation) in interceptors.

Pitfall 3: Side Effects in Guards

Guards should only decide navigation access. They should not dispatch analytics events, modify state, or call mutation endpoints.

Pitfall 4: Using NgRx for Everything

NgRx adds significant boilerplate. For most CRUD apps, a Signal Store or Component Store is sufficient. Reserve NgRx for complex state interactions, multi-source event merging, or when Redux DevTools time-travel debugging is needed.

Pitfall 5: Mixing Signals and RxJS Incorrectly

// Wrong — converting signal to observable unnecessarily
const count$ = toObservable(this.count)

// Correct — use signal directly in template
// {{ count() }}

Use Signals in templates and computed() for sync derivations. Only use toObservable() when integrating with RxJS operators or libraries that expect observables.

Pitfall 6: Not Using takeUntilDestroyed

Before Angular 16, manual subscriptions caused memory leaks. Use takeUntilDestroyed() as the standard pattern. In Angular 16+, it works in any injection context without DestroyRef.

Compared With

Angular vs React

Aspect Angular React
Architecture Full framework (DI, router, HTTP, forms) Library (ecosystem via external packages)
Reactivity Signals + RxJS Hooks + state management
DI Built-in, hierarchical Manual via context o
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • references/angular-advanced-di.md
  • references/angular-design-patterns.md
  • references/angular-performance.md
  • references/angular-rxjs-patterns.md
  • references/angular-signals-migration.md
  • references/angular-testing.md
  • references/di-patterns.md
  • references/rxjs-patterns.md

FAQ

Что делает скилл angular-patterns?

Use when the user asks about Angular HTTP interceptors, route guards, resolvers, services and DI, RxJS vs signals, NgRx or Signal Store, custom directives or pipes. Produces Angular 17+ patterns for cross-cutting concerns and state. Not for project layout or standalone migration (use angular-architecture).

Как установить скилл angular-patterns?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл angular-patterns запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить angular-patterns с