Angular 18+ Signals & Standalone AI Agent Rules & Cursorrules
Enforce modern Angular Signals and standalone architecture in AI assistants.
Prevent AI models from generating deprecated Angular 12 NgModules and manual RxJS subscriptions. Enforce modern Angular Signals, computed states, and built-in control flow (@if, @for).
Configuration Workbench
Select your agent format below to preview, copy, or download the configuration file.
# Angular 18+ Signals Cursor Rules
You are a Principal Angular Architect.
## Core Rules
- Framework: Angular 18+. Standalone components ONLY (never generate 'NgModule').
- Reactivity: Use Angular Signals ('signal()', 'computed()') for state management.
- Templates: Use built-in control flow ('@if', '@for (item of items; track item.id)', '@switch'). NEVER use '*ngIf' or '*ngFor'.
- Dependency Injection: Use the modern 'inject(Service)' function instead of constructor parameters.
- Forms: Reactive Forms with strict typing ('FormControl<string>').Pro-tip: Place this file directly in the root directory of your Angular 18+ Signals & Standalone Components project. AI agents like Cursor Composer, Claude Code, and GitHub Copilot will read it automatically on initialization.
Architectural Principles Enforced
When this configuration file is loaded into Cursor or Claude Code, the agent strictly enforces the following design invariants:
NEVER generate `NgModule` declarations; all components, directives, and pipes must be `standalone: true`.
Use Angular Signals (`signal()`, `computed()`) for reactive component state instead of manual RxJS subscription boilerplate.
Use modern built-in control flow syntax (`@if`, `@for`, `@switch`) instead of legacy `*ngIf` and `*ngFor` directives.
Use `inject()` function for dependency injection rather than constructor injection.
Use `toSignal()` when bridging RxJS observables to component templates.
Installation & Repository Setup
Place in project root as `.cursorrules` or `.cursor/rules/angular.mdc`.
Verified Agent Behavior Examples
Observe how the AI agent responds when prompted under these active rules.
Frequently Asked Questions
Why should I avoid *ngIf and *ngFor in Angular 18?
Angular's new built-in control flow (`@if`, `@for`, `@switch`) compiles directly into template instructions with zero runtime directive overhead, offers cleaner syntax, and requires mandatory track expressions for optimal rendering performance.