angular-best-practices-legacy
Angular 12-16 performance optimization guidelines with NgModules, RxJS patterns, and classic template syntax (*ngIf, *ngFor). Use when maintaining or working with pre-v17 Angular codebases. Triggers on tasks involving Angular components, services, modules, or performance improvements in legacy projects.
What this skill does
# Angular Best Practices (Legacy: v12-16) Comprehensive performance optimization guide for Angular 12-16 applications using NgModule-based architecture and RxJS-centric patterns. Contains 30+ rules across 8 categories, prioritized by impact to guide automated refactoring and code generation. ## When to Apply Reference these guidelines when: - Maintaining Angular 12-16 codebases - Using NgModule-based architecture - Working with *ngIf, *ngFor directives - Using RxJS for state management - Using class-based HTTP interceptors - Reviewing code for performance issues ## Key Patterns (v12-16) - **NgModules** - Feature modules for organization - **BehaviorSubject** - Reactive state management - **Subject + takeUntil** - Subscription cleanup pattern - **Class-based interceptors** - HTTP handling with implements HttpInterceptor - ***ngFor / *ngIf** - Structural directives with trackBy - **loadChildren** - Module-based lazy loading ## Rule Categories by Priority | Priority | Category | Impact | Prefix | |----------|----------|--------|--------| | 1 | Change Detection | CRITICAL | `change-` | | 2 | Bundle & Lazy Loading | CRITICAL | `bundle-` | | 3 | RxJS Optimization | HIGH | `rxjs-` | | 4 | Template Performance | HIGH | `template-` | | 5 | Dependency Injection | MEDIUM-HIGH | `di-` | | 6 | HTTP & Caching | MEDIUM | `http-` | | 7 | Forms Optimization | MEDIUM | `forms-` | | 8 | General Performance | LOW-MEDIUM | `perf-` | ## Quick Reference ### 1. Change Detection (CRITICAL) - `change-rxjs-state` - Use BehaviorSubject with OnPush for reactive state - `change-onpush` - Use OnPush change detection strategy - `change-detach-reattach` - Detach change detector for heavy operations - `change-run-outside-zone` - Run non-UI code outside NgZone ### 2. Bundle & Lazy Loading (CRITICAL) - `bundle-ngmodule` - Organize code into feature NgModules - `bundle-scam` - Use Single Component Angular Modules pattern - `bundle-lazy-routes` - Lazy load routes with loadChildren - `bundle-preload` - Preload routes for perceived speed - `bundle-no-barrel-imports` - Avoid barrel files, use direct imports ### 3. RxJS Optimization (HIGH) - `rxjs-async-pipe` - Use async pipe instead of manual subscriptions - `rxjs-takeuntil` - Use takeUntil with destroy$ Subject for cleanup - `rxjs-share-replay` - Share observables to avoid duplicate requests - `rxjs-operators` - Use efficient RxJS operators - `rxjs-mapping-operators` - Use correct mapping operators (switchMap vs exhaustMap) - `rxjs-no-nested-subscribe` - Avoid nested subscriptions ### 4. Template Performance (HIGH) - `template-trackby` - Use trackBy function with *ngFor - `template-pure-pipes` - Use pure pipes for expensive transformations - `template-ng-optimized-image` - Use NgOptimizedImage for image optimization - `template-no-function-calls` - Avoid function calls in templates - `template-virtual-scroll` - Use virtual scrolling for large lists ### 5. Dependency Injection (MEDIUM-HIGH) - `di-provided-in-root` - Use providedIn: 'root' for singleton services - `di-injection-token` - Use InjectionToken for non-class dependencies - `di-factory-providers` - Use factory providers for complex initialization ### 6. HTTP & Caching (MEDIUM) - `http-interceptors` - Use class-based interceptors for cross-cutting concerns - `http-transfer-state` - Use TransferState for SSR hydration ### 7. Forms Optimization (MEDIUM) - `forms-reactive` - Use reactive forms instead of template-driven - `forms-typed` - Use typed FormGroup for type safety ### 8. General Performance (LOW-MEDIUM) - `perf-memory-leaks` - Prevent memory leaks (timers, listeners, subscriptions) - `perf-web-workers` - Offload heavy computation to Web Workers - `arch-smart-dumb-components` - Use Smart/Dumb component pattern ## How to Use Read individual rule files for detailed explanations and code examples: ``` rules/change-rxjs-state.md rules/bundle-ngmodule.md rules/rxjs-takeuntil.md ``` Each rule file contains: - Brief explanation of why it matters - Incorrect code example with explanation - Correct code example with explanation - Additional context and references ## Full Compiled Document For the complete guide with all rules expanded: `AGENTS.md`
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.