Skip to content

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Halcyon Tech

Modern Angular Best Practices Plugin

Signals-First Reactivity, Zoneless Change Detection & Enterprise Architecture (Angular v20+)

Antigravity Plugin License: MIT Website Organization

Production-strict modern Angular (v20+) best practices covering standalone components, Signals-first reactivity, zoneless change detection, feature-first architecture, functional routing and HTTP, typed and Signal forms, SSR with incremental hydration, performance, security, accessibility, and Vitest testing conventions.


Installation & Verification

Antigravity CLI (agy)

Install directly into your Antigravity environment via the CLI:

agy plugin install https://github.com/HalcyonTech-LTDA/modern-angular-best-practices

Verify that the plugin is active and conforms to the strict official schema:

agy plugin list
agy plugin validate --strict ./modern-angular-best-practices

Overview & Strategic Mission

Modern Angular (v20+) has undergone a generational transformation—from NgModule boilerplate and Zone.js monkey-patching to a lean, Signals-first, standalone-by-default, zoneless web platform. Without clear architectural guardrails, AI-assisted and team-built Angular codebases frequently regress into outdated patterns:

  • Legacy NgModule & Structural Directive Drift: Generating unnecessary NgModule files, CommonModule barrel imports, and *ngIf/*ngFor/*ngSwitch instead of standalone components and native control flow (@if, @for, @switch, @let).
  • Imperative State & effect() Abuse: Using BehaviorSubject boilerplate for local UI state or mutating signals inside effect() instead of declarative computed() and linkedSignal().
  • Zone.js Coupling & Performance Bloat: Mutating plain class properties in async callbacks, skipping ChangeDetectionStrategy.OnPush, missing @defer code-splitting, and shipping oversized initial bundles.
  • Technical-Layer Folder Spaghetti: Dumping unrelated code into global /components, /services, and /models directories instead of bounded feature-first domains.
  • Class-Based Routing/HTTP & Untyped Forms: Writing deprecated class-based guards/interceptors, subscribing to ActivatedRoute manually instead of withComponentInputBinding(), and leaking any through untyped forms.
  • Legacy Karma Testing & Flaky Suites: Scaffolding deprecated Karma/Jasmine runners and brittle setTimeout assertions instead of first-party @angular/build:unit-test with Vitest, RouterTestingHarness, DeferBlockBehavior.Manual, and Playwright.

This plugin establishes a Production-Strict Angular v20+ Baseline across five foundational pillars:

                                ┌─────────────────────────────────────────────────┐
                                │     Modern Angular v20+ Engineering System      │
                                └────────────────────────┬────────────────────────┘
                                                         │
     ┌──────────────────────┬──────────────────────┬─────┴─────┬──────────────────────┬──────────────────────┐
     ▼                      ▼                      ▼           ▼                      ▼                      │
┌─────────────────┐  ┌─────────────────┐  ┌─────────────────┐ ┌─────────────────┐  ┌─────────────────┐       │
│  Components &   │  │ Architecture &  │  │ Routing, HTTP   │ │ Performance,    │  │   Testing &     │       │
│    Signals      │  │   State / DI    │  │   & Forms       │ │ SSR & Security  │  │    Tooling      │       │
├─────────────────┤  ├─────────────────┤  ├─────────────────┤ ├─────────────────┤  ├─────────────────┤       │
│• Standalone     │  │• Feature-First  │  │• provideRouter  │ │• @defer Views   │  │• Vitest Builder │       │
│• Signals/linked │  │• Smart vs UI    │  │• Input Binding  │ │• NgOptimizedImg │  │• Zoneless Tests │       │
│• Zoneless+OnPush│  │• Route Providers│  │• Functional Fn  │ │• Inc. Hydration │  │• RouterHarness  │       │
│• @if/@for/@let  │  │• SignalStore    │  │• withFetch HTTP │ │• Bundle Budgets │  │• angular-eslint │       │
│• inject() & host│  │• RxJS Interop   │  │• Typed & Signal │ │• XSS/CSP/WCAG   │  │• Playwright E2E │       │
└─────────────────┘  └─────────────────┘  └─────────────────┘ └─────────────────┘  └─────────────────┘

Specialized Skills Index

This plugin provides five specialized skills loaded progressively on demand, backed by focused reference guides:

Skill Focus Area Key Capabilities
modern-angular-components-and-signals Components, Signals & Templates Standalone-by-default, signal/computed/linkedSignal/effect, input/output/model/signal queries, provideZonelessChangeDetection + OnPush, @if/@for/@switch/@let, host metadata, inject(), and Angular v20+ style guide.
modern-angular-architecture-and-state Architecture, DI & State Feature-first domain layout (core/, features/, shared/), Smart vs. Presentational split, DI scoping & InjectionToken, provideAppInitializer(), Signal stores, @ngrx/signals, and toSignal/toObservable/takeUntilDestroyed.
modern-angular-routing-http-and-forms Routing, HTTP & Forms provideRouter (withComponentInputBinding, withViewTransitions, lazy loading), functional guards/resolvers/interceptors, provideHttpClient(withFetch()), RFC 7807 error normalization, NonNullableFormBuilder, and Signal Forms (@angular/forms/signals).
modern-angular-performance-ssr-and-security Performance, SSR, Security & A11y @defer code-splitting & prefetching, NgOptimizedImage, provideClientHydration(withEventReplay(), withIncrementalHydration()), afterNextRender(), bundle budgets, XSS/CSP/CSRF hardening, and WCAG 2.1 AA accessibility.
modern-angular-testing-and-tooling Testing, Linting & CI Gates First-party @angular/build:unit-test with Vitest, zoneless TestBed, RouterTestingHarness, DeferBlockBehavior.Manual, HttpTestingController, strict tsconfig.json, angular-eslint flat config, and Playwright E2E.

Non-Negotiable Guardrails (Absolute Invariants)

  1. Standalone-by-Default: Zero new NgModule declarations; bootstrap exclusively via bootstrapApplication() and ApplicationConfig.
  2. Signals-First & Zoneless-Ready: Use signal(), computed(), linkedSignal(), input(), output(), model(), provideZonelessChangeDetection(), and ChangeDetectionStrategy.OnPush. Never derive state inside effect().
  3. Native Control Flow & Bindings: Strictly prohibit *ngIf, *ngFor, *ngSwitch, ngClass, ngStyle, @HostBinding, and @HostListener. Use @if, @for (...; track ...), @switch, @let, native [class.*]/[style.*], and host: {}.
  4. Function-Based DI & Primitives: Prefer inject() over constructor injection; write all guards, resolvers, and HTTP interceptors as pure functions.
  5. Memory Safety: Zero unmanaged .subscribe() calls; use toSignal(), async pipe, or takeUntilDestroyed().
  6. Strict Type Safety: Enforce TypeScript strict: true, strictTemplates: true, NonNullableFormBuilder, and zero any.
  7. Security & Accessibility: Zero unchecked bypassSecurityTrust*(), zero secrets in environment.*.ts, CSP/XSRF hygiene, and semantic WCAG 2.1 AA HTML.
  8. Deterministic Vitest Testing: Zero new Karma configs; test deterministically with @angular/build:unit-test (Vitest), RouterTestingHarness, DeferBlockBehavior.Manual, HttpTestingController, and Playwright.

Quick Start Example: Idiomatic Angular v20+ Component

import { ChangeDetectionStrategy, Component, computed, inject, input, output } from '@angular/core';
import { CurrencyPipe } from '@angular/common';
import { CartStore } from '../data-access/cart-store';

export interface Product {
  readonly id: string;
  readonly name: string;
  readonly priceCents: number;
  readonly stock: number;
}

@Component({
  selector: 'app-product-card',
  imports: [CurrencyPipe],
  changeDetection: ChangeDetectionStrategy.OnPush,
  host: { '[class.out-of-stock]': 'isOutOfStock()' },
  template: `
    @let item = product();
    <article>
      <h3>{{ item.name }}</h3>
      <p>{{ item.priceCents / 100 | currency }}</p>

      @if (isOutOfStock()) {
        <span class="badge">Sold out</span>
      } @else {
        <button type="button" (click)="onAdd()">Add to Cart</button>
      }
    </article>
  `,
})
export class ProductCard {
  private readonly cart = inject(CartStore);

  readonly product = input.required<Product>();
  readonly added = output<Product>();

  protected readonly isOutOfStock = computed(() => this.product().stock <= 0);

  protected onAdd(): void {
    const item = this.product();
    this.cart.add(item);
    this.added.emit(item);
  }
}

What's Included (Component Catalog)

Contextual Rules (rules/)

Procedural Skills (skills/)


Directory Hierarchy

modern-angular-best-practices/
├── plugin.json                                                  # Official Antigravity manifest (schema v1)
├── LICENSE                                                      # MIT License (Copyright 2026 HalcyonTech LTDA)
├── .gitignore                                                   # Ignores system junk, logs & installed_version.json
├── .gitattributes                                               # Deterministic LF line endings (* text=auto eol=lf)
├── README.md                                                    # Golden Standard documentation & runbook
├── assets/
│   ├── logo.svg                                                 # Official Halcyon Tech marketplace icon
│   └── halcyon-horizontal-cor.svg                               # Official Halcyon Tech horizontal brand card
├── rules/
│   └── modern-angular-engineering.md                            # Normative guardrails and skill router
└── skills/
    ├── modern-angular-components-and-signals/
    │   ├── SKILL.md                                             # Standalone, Signals, Zoneless & templates workflow
    │   └── references/
    │       ├── signals_and_zoneless.md                          # Signals, linkedSignal, effect discipline & zoneless
    │       └── components_and_templates.md                      # Signal APIs, @if/@for/@switch/@let & v20+ style guide
    ├── modern-angular-architecture-and-state/
    │   ├── SKILL.md                                             # Feature-first architecture, DI & state workflow
    │   └── references/
    │       ├── feature_architecture_and_di.md                   # Core/Features/Shared, Smart vs UI & DI scoping
    │       └── state_and_rxjs_interop.md                        # Signal stores, NgRx SignalStore & RxJS interop
    ├── modern-angular-routing-http-and-forms/
    │   ├── SKILL.md                                             # Functional routing, HTTP & forms workflow
    │   └── references/
    │       ├── routing_and_http.md                              # provideRouter, functional guards/interceptors & fetch
    │       └── typed_and_signal_forms.md                        # NonNullableFormBuilder & @angular/forms/signals
    ├── modern-angular-performance-ssr-and-security/
    │   ├── SKILL.md                                             # Performance, SSR, security & WCAG workflow
    │   └── references/
    │       ├── performance_and_ssr.md                           # @defer, NgOptimizedImage, hydration & bundle budgets
    │       └── security_and_accessibility.md                    # XSS/CSP/CSRF hardening & WCAG 2.1 AA patterns
    └── modern-angular-testing-and-tooling/
        ├── SKILL.md                                             # Vitest, linting & Playwright testing workflow
        └── references/
            ├── vitest_and_component_testing.md                  # @angular/build:unit-test, TestBed & RouterHarness
            └── tooling_linting_and_e2e.md                       # Strict tsconfig, angular-eslint & Playwright E2E

💡 Prompt Recipes & Use Cases

Copy and paste these prompts directly into your Antigravity chat:

1. Legacy Component Modernization

"Refactor this NgModule-based Angular component to standalone Signals-first architecture: replace @Input/@Output with input()/output(), migrate constructor DI to inject(), switch to @if/@for/@let, add ChangeDetectionStrategy.OnPush, and make it zoneless-ready."

2. Feature-First Architecture & State Design

"Design a feature-first orders domain under src/app/features/orders/ with lazy routes, a route-scoped Signal Store service, Smart/Presentational component split, and a typed OrdersApi using functional HTTP interceptors."

3. SSR, Performance & Security Audit

"Audit this Angular application for zoneless readiness, SSR safety (afterNextRender), @defer opportunities, NgOptimizedImage LCP compliance, XSS sanitization boundaries, and WCAG 2.1 AA accessibility gaps."

4. Deterministic Vitest Test Suite

"Migrate this Karma spec to @angular/build:unit-test with Vitest using provideZonelessChangeDetection(), fixture.componentRef.setInput(), RouterTestingHarness, DeferBlockBehavior.Manual, and HttpTestingController."


📄 License & Corporate Governance

Distributed under the MIT License. See LICENSE for the full text.

Engineered with precision and excellence by Halcyon Tech — GitHub Organization.

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors