angular-best-practices

Provides prioritized Angular performance optimization rules covering change detection, bundles, rendering, and SSR.

1|Updated Aug 17, 2025
One-click install
npx skills add https://github.com/ratnesh-maurya/mdconverter --skill angular-best-practices-ratnesh-maurya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: angular-best-practices
Source: https://github.com/ratnesh-maurya/mdconverter/tree/main/.claude/skills/angular-best-practices
Command: npx skills add https://github.com/ratnesh-maurya/mdconverter --skill angular-best-practices-ratnesh-maurya

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Angular applications often suffer from slow change detection, bloated bundles, async waterfalls, and unnecessary re-renders. This Skill gives AI agents and developers a prioritized, rule-based reference for writing and reviewing performant Angular code. ## Core Features & Use Cases - Prioritized Performance Rules: Eight categories ranked from critical (OnPush, Signals, Zoneless, async waterfalls, lazy loading) to low (memory cleanup), each with wrong/correct code examples. - SSR & Hydration Guidance: Patterns for incremental hydration, @defer triggers, and TransferState to avoid duplicate server/client fetches. - Review Checklists: Ready-made checklists for new components, performance reviews, and SSR audits. - Use Case: When refactoring an Angular dashboard that re-renders excessively, apply the change detection and computed() signal rules to eliminate wasted cycles and shrink the main bundle via lazy routes and @defer. ## Quick Start Ask the AI to review your Angular component against the angular-best-practices performance rules and suggest fixes.

Frequently Asked Questions about angular-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I improve Angular change detection performance?

Use ChangeDetectionStrategy.OnPush on components and replace mutable properties with Signals so updates trigger precise re-renders. For new projects on Angular v20+, enable zoneless change detection with provideZonelessChangeDetection() to remove zone.js overhead.

How to avoid async waterfalls in Angular data fetching?

Replace nested subscriptions with forkJoin for independent parallel calls or switchMap to flatten dependent calls. For SSR apps, fetch critical data in route resolvers so it loads on the server before navigation instead of in ngOnInit.

What is the best way to reduce Angular bundle size?

Lazy load feature routes with loadChildren or loadComponent, wrap heavy components in @defer blocks, and dynamically import large third-party libraries like Chart.js. Avoid barrel file re-exports since they break tree-shaking.

Does Angular @defer work with server-side rendering?

Yes, @defer supports hydration triggers such as 'hydrate on viewport' and 'hydrate on interaction' when incremental hydration is configured via provideClientHydration(withIncrementalHydration()). This lets below-fold content hydrate lazily after the initial server render.

Why does my Angular list re-render entirely on small changes?

Lists re-render when @for lacks a proper track expression or uses $index instead of a stable item id. Add 'track item.id' so Angular reuses DOM nodes, and use CDK virtual scrolling for very large lists.

When should I use Signals instead of RxJS subscriptions in Angular?

Use Signals for synchronous reactive state and derived values via computed(), and convert streams with toSignal() when the template only needs the latest value. Reserve manual subscriptions with takeUntilDestroyed for side-effect-driven logic.