This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
frontendcritical PriorityID: angular-19-signals-defer-views

Angular 19 Signal Primitives, Linked Signals, and @defer Template Chunking

Enforces modern Angular 19 reactive architectures by requiring signal inputs and linkedSignal for derived mutable state, while prohibiting ngOnChanges and manual synchronizations. Mandates explicit @defer blocks with viewport triggers, minimum durations, and error/placeholder fallbacks for non-critical template subtrees to optimize bundle chunking and Core Web Vitals.

Prohibited Anti-Pattern: Mutating state via ngOnChanges/effects and omitting @defer blocks on below-the-fold dependencies.

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Angular 19 Signal Primitives, Linked Signals, and @defer Template Chunking - Enforces modern Angular 19 reactive architectures by requiring signal inputs and linkedSignal for derived mutable state, while prohibiting ngOnChanges and manual synchronizations. Mandates explicit @defer blocks with viewport triggers, minimum durations, and error/placeholder fallbacks for non-critical template subtrees to optimize bundle chunking and Core Web Vitals.
globs: src/**/*.component.ts, src/**/*.component.html, src/**/*.ts
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/angular-19-signals-defer-views"
---

# Angular 19 Signal Primitives, Linked Signals, and @defer Template Chunking

> **Severity**: CRITICAL | **Category**: frontend
> **Anti-Pattern Warning**: Mutating state via ngOnChanges/effects and omitting @defer blocks on below-the-fold dependencies.

## System Constraints
You are a Principal Angular Architect enforcing Angular 19 standards. Strictly enforce Signal Inputs (`input()`, `input.required()`), `linkedSignal` for mutable state reset upon source signal changes, and `@defer` chunking with robust placeholders. Disallow legacy decorators (`@Input`, `@Output`, `@ViewChild`), `ngOnChanges` lifecycle hooks for state sync, and arbitrary side-effect mutations inside `effect()`.

## Strict Guidelines
- Engineers MUST ALWAYS declare inputs using `input()` or `input.required()` instead of the legacy `@Input()` decorator.
- Engineers MUST use `linkedSignal()` when local mutable state must reset or re-derive based on an upstream signal input, avoiding `ngOnChanges` or manual synchronization effects.
- Engineers MUST NOT write to signals inside an `effect()` block; effects are strictly reserved for external non-Angular side effects (e.g., logging, Web APIs, DOM measurements).
- Components MUST ALWAYS specify `changeDetection: ChangeDetectionStrategy.OnPush` and `standalone: true` (or rely on Angular 19 default standalone configuration).
- Engineers MUST wrap all heavy, non-critical, or below-the-fold components in `@defer` blocks equipped with `on viewport` or `on idle` triggers, accompanied by `@placeholder`, `@loading`, and `@error` blocks.
- Template `@loading` and `@placeholder` blocks SHOULD specify `minimum` display durations (e.g., `minimum 300ms`) to eliminate layout thrashing and visual flickering.

## Bad vs Good Implementations
### Migrating Legacy Input Sync & Static Components to LinkedSignal & @defer

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Uses legacy @Input decorators and ngOnChanges to imperatively synchronize mutable local draft state with incoming properties. Statically imports and renders HeavyAnalyticsChartComponent into the main bundle rather than code-splitting it via @defer, impacting LCP and initial bundle size.
```typescript
import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { HeavyAnalyticsChartComponent } from './heavy-analytics-chart.component';

@Component({
  selector: 'app-user-profile',
  standalone: true,
  imports: [HeavyAnalyticsChartComponent],
  template: `
    <div>
      <h2>User: {{ selectedUser.name }}</h2>
      <input [(ngModel)]="draftEmail" />
      <button (click)="save()">Save</button>
      <app-heavy-analytics-chart [data]="selectedUser.stats" />
    </div>
  `
})
export class UserProfileComponent implements OnChanges {
  @Input({ required: true }) selectedUser!: { id: string; name: string; email: string; stats: any };
  draftEmail: string = '';

  ngOnChanges(changes: SimpleChanges): void {
    // Anti-pattern: Imperative state syncing via ngOnChanges causes race conditions
    if (changes['selectedUser']) {
      this.draftEmail = this.selectedUser.email;
    }
  }

  save(): void {
    // Imperative save
  }
}
```

#### Production Standard (Correct)
> **Standard**: Adopts signal inputs (`input.required()`) and Angular 19's `linkedSignal()`, cleanly establishing derived mutable draft state without manual `ngOnChanges` lifecycle hooks. Uses `@defer (on viewport)` to lazily load the analytics component chunk only when needed, protected by `@placeholder` and `@loading` minimum durations to prevent layout jitter.
```typescript
import { Component, ChangeDetectionStrategy, input, linkedSignal } from '@angular/core';
import { HeavyAnalyticsChartComponent } from './heavy-analytics-chart.component';

interface User {
  id: string;
  name: string;
  email: string;
  stats: Record<string, number>;
}

@Component({
  selector: 'app-user-profile',
  standalone: true,
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [HeavyAnalyticsChartComponent],
  template: `
    <div>
      <h2>User: {{ selectedUser().name }}</h2>
      <input [value]="draftEmail()" (input)="draftEmail.set($any($event.target).value)" />
      <button (click)="save()">Save</button>

      @defer (on viewport; prefetch on idle) {
        <app-heavy-analytics-chart [data]="selectedUser().stats" />
      } @placeholder (minimum 300ms) {
        <div class="skeleton-chart">Loading chart visual placeholder...</div>
      } @loading (minimum 200ms) {
        <div class="spinner">Fetching chart chunk...</div>
      } @error {
        <div class="error-banner">Failed to load analytics engine.</div>
      }
    </div>
  `
})
export class UserProfileComponent {
  readonly selectedUser = input.required<User>();

  // Angular 19 linkedSignal creates derived, mutable state that auto-resets when selectedUser changes
  readonly draftEmail = linkedSignal({
    source: this.selectedUser,
    computation: (user) => user.email,
  });

  save(): void {
    const updatedEmail = this.draftEmail();
    // Handle emission or persistence
  }
}
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Angular 19 Signal Primitives, Linked Signals, and @defer Template Chunking

Angular 19 Signal Primitives, Linked Signals, and @defer Template Chunking defines an industrial-grade behavioral standard for frontend engineering. Enforces modern Angular 19 reactive architectures by requiring signal inputs and linkedSignal for derived mutable state, while prohibiting ngOnChanges and manual synchronizations. Mandates explicit @defer blocks with viewport triggers, minimum durations, and error/placeholder fallbacks for non-critical template subtrees to optimize bundle chunking and Core Web Vitals. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Mutating state via ngOnChanges/effects and omitting @defer blocks on below-the-fold dependencies. Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftMutating state via ngOnChanges/effects and omitting @defer blocks on below-the-fold dependencies.Critical
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST ALWAYS declare inputs using `input()` or `input.required()` instead of the legacy `@Input()` decorator.

Engineers MUST ALWAYS declare inputs using `input()` or `input.required()` instead of the legacy `@Input()` decorator.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST use `linkedSignal()` when local mutable state must reset or re-derive based on an upstream signal input, avoiding `ngOnChanges` or manual synchronization effects.

Engineers MUST use `linkedSignal()` when local mutable state must reset or re-derive based on an upstream signal input, avoiding `ngOnChanges` or manual synchronization effects.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Engineers MUST NOT write to signals inside an `effect()` block

Engineers MUST NOT write to signals inside an `effect()` block; effects are strictly reserved for external non-Angular side effects (e.g., logging, Web APIs, DOM measurements).

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Components MUST ALWAYS specify `changeDetection

Components MUST ALWAYS specify `changeDetection: ChangeDetectionStrategy.OnPush` and `standalone: true` (or rely on Angular 19 default standalone configuration).

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Engineers MUST wrap all heavy, non-critical, or below-the-fold components in `@defer` blocks equipped with `on viewport` or `on idle` triggers, accompanied by `@placeholder`, `@loading`, and `@error` blocks.

Engineers MUST wrap all heavy, non-critical, or below-the-fold components in `@defer` blocks equipped with `on viewport` or `on idle` triggers, accompanied by `@placeholder`, `@loading`, and `@error` blocks.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
6

Template `@loading` and `@placeholder` blocks SHOULD specify `minimum` display durations (e.g., `minimum 300ms`) to eliminate layout thrashing and visual flickering.

Template `@loading` and `@placeholder` blocks SHOULD specify `minimum` display durations (e.g., `minimum 300ms`) to eliminate layout thrashing and visual flickering.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Angular 19 Signal Primitives, Linked Signals, and @defer Template Chunking critical for AI coding assistants?

Enforces modern Angular 19 reactive architectures by requiring signal inputs and linkedSignal for derived mutable state, while prohibiting ngOnChanges and manual synchronizations. Mandates explicit @defer blocks with viewport triggers, minimum durations, and error/placeholder fallbacks for non-critical template subtrees to optimize bundle chunking and Core Web Vitals. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (Mutating state via ngOnChanges/effects and omitting @defer blocks on below-the-fold dependencies.) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

Related FRONTEND Rules

View all rules →
frontend
119

SolidStart 1.0 Server Functions & Async Boundaries Production Standard

SolidStart 1.0 relies on the Vinxi bundler to split `server$` closures into independent HTTP POST RPC endpoints. Direct lexical closure over client signals within `server$` scopes or failure to demarcate async boundaries with `<Suspense>` causes silent serialization failures, client-bundle secret leaks, and SSR hydration mismatches. Enforcing strict parameter passing, runtime input validation, and Solid async primitives maintains security and fine-grained reactivity across network boundaries.

frontend
119

Astro 5 Actions & Content Layer Production Standard

Enforces strict type safety and architectural correctness for Astro 5 Server Actions and the zero-waterfall Content Layer API. Prevents runtime contract mismatches, hydration mismatches, and unhandled mutation exceptions across dynamic and prerendered boundaries. Failure to follow these patterns leads to silent data fetching waterfalls, build-time cache corruptions, and unhandled server action exceptions.

frontend
51

Nuxt 4 Nitro Server Engine & Shared Directory Production Standard

Nuxt 4 enforces strict boundary segregation between client UI in the app/ directory, backend endpoints in server/, and universal contracts in shared/. Violating cross-boundary isolation or maintaining module-scoped state in Nitro server handlers causes catastrophic cross-request data corruption and hydration mismatches under concurrent production traffic. Architects must enforce request-isolated H3 event contexts, universal serialization schemas, and strict path-alias boundaries.

1 Rule in Stack

Angular