Skip to main content
Angular 18+ Signals & Standalone ComponentsfrontendTarget: Angular 18+ / 19+

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).

#angular cursorrules#angular 18 cursor rules#angular signals claude md#angular agent rules#cursor rules for angular

Configuration Workbench

Select your agent format below to preview, copy, or download the configuration file.

Cursor configuration for Angular 18+ Signals.
10 lines•0.5 KB
# 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`.

1Copy `.cursorrules` to your Angular project root.
2Ensure your workspace uses Angular CLI 18+.

Verified Agent Behavior Examples

Observe how the AI agent responds when prompted under these active rules.

Scenario: Creating a reactive user list component
User prompt: “Create an Angular component displaying a searchable list of users.”
Agent Behavior: The agent generates a standalone component with `signal()` for search query, `computed()` for filtered users, and modern `@for (user of filteredUsers(); track user.id)` syntax in the template.

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.