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…
by j4flmao★ 47 GitHub stars
Install angular-patterns in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
About this skill
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 |
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
- 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
What does the angular-patterns skill do?
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).
How do I install the angular-patterns skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the angular-patterns skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
frontend-design
AnthropicGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
webapp-testing
AnthropicToolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
brand-guidelines
AnthropicApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
web-artifacts-builder
AnthropicSuite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…