🅰️

Cursor Rules for Angular + TypeScript

Enterprise Angular with TypeScript, RxJS, and signals

AngularTypeScriptRxJSSignals
.cursorrules
# Role
You are an expert Angular developer using TypeScript, standalone components, and signals.

# Tech Stack
- Angular 19+
- TypeScript (strict)
- RxJS
- Angular Signals
- NgRx

# Code Conventions
- Use standalone components by default — avoid NgModules.
- Use Angular Signals for reactive state management.
- Use RxJS for async streams and HTTP calls via `HttpClient`.
- Follow Angular style guide: feature folders, barrel exports.
- Use reactive forms with strong typing via `FormGroup<T>`.
- Use `inject()` function instead of constructor injection.
- Use `@defer` blocks for lazy loading components.
- Use Angular CLI for generating components, services, and pipes.
- Write unit tests with Jasmine and Karma or Jest.

# Code Style Preferences
- Use TypeScript strict mode. Define types for all variables, parameters, and return values.
- Never use the `any` type. Use `unknown` if the type is truly uncertain, then narrow it.
- Use `const` by default. Only use `let` when reassignment is needed. Never use `var`.
- Always handle errors explicitly. Use try/catch for async operations. Never silently swallow errors.
- Use early returns (guard clauses) to reduce nesting and improve readability.
- Use descriptive, meaningful names for variables, functions, and classes. Avoid abbreviations.
- Keep functions small and focused. Each function should do one thing. Aim for under 50 lines.

# What to Avoid
- Do not use `any` type.
- Do not use decorator-based injection — prefer `inject()`.
- Do not subscribe to observables without unsubscribing.
- Do not use `ngOnChanges` when signals can replace it.
- Do not create god-components — keep them small.

About Cursor Rules for Angular + TypeScript

The .cursorrules file helps Cursor understand your Angular + TypeScript project's conventions, tech stack, and coding standards. This ensures the AI generates code that matches your team's style and follows best practices for Angular.

This preset includes rules for:

  • Use standalone components by default — avoid NgModules.
  • Use Angular Signals for reactive state management.
  • Use RxJS for async streams and HTTP calls via `HttpClient`.
  • Follow Angular style guide: feature folders, barrel exports.
  • Use reactive forms with strong typing via `FormGroup<T>`.

How to use this file

  1. Click Copy or Download above.
  2. Place the .cursorrules file in your project's root directory.
  3. Cursor will automatically detect and apply these rules.

Get Angular + TypeScript Rules for Other IDEs

Other Cursor Presets