Org Skills

Angular

Always-on rules for writing and editing Angular application code and templates, matched by folder so they apply under both the current and the legacy file-naming convention.

Raw Source
What it isAlways-on coding rules. GitHub Copilot applies them to files matching **/src/app/**/*.ts,**/src/app/**/*.html,**/libs/**/src/**/*.ts,**/libs/**/src/**/*.html,**/src/main.ts; the Claude Code version is a path-scoped rule generated from the same file. Why use instructions →

Install

This repository (recommended)

Adds .github/instructions/angular.instructions.md — commit it so everyone's Copilot follows the same rules.

npx -y github:AGCO-Global/org-skills add instructions angular

Just for me, every repository

Save it in your user profile instead.

npx -y github:AGCO-Global/org-skills add instructions angular --user

Use it

Nothing to invoke — edit a matching file and Copilot picks the rules up. Adjust applyTo if your repository layout differs.

This repository (recommended)

Adds .claude/rules/angular.md — commit it. Claude loads it when it reads a matching file.

npx -y github:AGCO-Global/org-skills add instructions angular --tool claude

Just for me, every repository

Save it in your user profile instead.

npx -y github:AGCO-Global/org-skills add instructions angular --tool claude --user

Use it

Nothing to invoke. Adjust the paths globs if your repository layout differs.

Commands run in your repository folder and need Node.js 20+. They use your normal git sign-in to GitHub, so they work while the repository is private. Run npx -y github:AGCO-Global/org-skills list to see everything available.

Settings

name: "Angular"
description: "Always-on rules for writing and editing Angular application code and templates, matched by folder so they apply under both the current and the legacy file-naming convention."
applyTo: "**/src/app/**/*.ts,**/src/app/**/*.html,**/libs/**/src/**/*.ts,**/libs/**/src/**/*.html,**/src/main.ts"

Instructions Copilot follows

Angular rules

Baseline Angular 20 LTS – 22; v19 and below are out of support. On v22 OnPush and zoneless are framework defaults, so their absence from a decorator or config is not a defect.

These globs match by folder, not by file suffix, because Angular CLI 20+ generates order-list.ts rather than order-list.component.ts. Both conventions work; the repo picks one and configures schematics in angular.json to match.

Assume typescript.instructions.md, secure-coding.instructions.md and frontend-security.instructions.md are also loaded — do not repeat their rules here.

Components

  • Write standalone components with ChangeDetectionStrategy.OnPush; never write standalone: true, which has been the default since v19 and marks the code as old.
  • Use input(), input.required(), output() and model(), never @Input()/@Output(). Signal inputs participate in change detection precisely; decorators force a subtree check.
  • List every directive, component and pipe a template uses in imports. Never import CommonModule wholesale — it pulls the whole module into the chunk, and a missing entry is a compile error (NG8001), not a runtime surprise.
  • inject() in field initialisers; keep the constructor for effect() and afterNextRender() registration only.
  • Mark everything Angular initialises readonly, and template-only members protected, so the public surface stays honest.

Signals

  • Hold state in signal(), derive with computed(), derive-but-overridable with linkedSignal(). Never store a derived value in a plain field: it goes stale silently.
  • Update immutably (items.update((l) => [...l, x])). Mutating an object or array in place does not notify readers.
  • A signal write inside effect() is allowed but is a smell — prefer computed(). Legitimate exceptions are syncing external state in (router events, a third-party widget callback, ResizeObserver); comment those.
  • Convert RxJS to signals once, at the service or store edge, with toSignal(). Templates read signals only.
  • Every manual subscribe() gets takeUntilDestroyed(), or it leaks for the life of the page.

Templates

  • Use @if / @for / @switch. Give every @for a track on a stable id and an @empty branch; track $index on a reorderable list rebuilds the DOM on each move.
  • Bind classes and styles with [class.x], [class] and [style.width.px]. Never ngClass/ngStyle — they are slower and the migration schematics remove them.
  • No method calls in bindings: they run on every change-detection pass. Use a computed(), a pure pipe, or @let value = expr; for a value read more than once.
  • Render loading, empty, error and success branches explicitly — a template with only the happy path ships a blank screen on failure.
  • Use @defer for heavy, below-the-fold or interaction-gated content, always with a @placeholder that reserves height.
  • Use real interactive elements (<button>, <a href>, form controls), never a div with (click). Keyboard and screen-reader users cannot reach the latter.
  • Use NgOptimizedImage (ngSrc, width/height or fill, priority on the LCP image only).

Services, HTTP and routing

  • Components never inject HttpClient. Data comes from an API service, an httpResource()/resource(), or a store.
  • Declare root singletons with @Service() on v22, or @Injectable({ providedIn: 'root' }) on v20/21; keep @Injectable when the provider needs useClass/useFactory or a non-root scope. Both are correct — do not rewrite one into the other.
  • Provide feature state on the feature's route, not in root, so it is released when the user leaves and tests start clean.
  • Handle auth headers, base URLs, retries and error normalisation in functional interceptors (withInterceptors([...])), not per call site.
  • Lazy-load every feature route with loadChildren/loadComponent; guards and resolvers are functions, and a guard returns true or a UrlTree rather than navigating itself.
  • Bind route params with withComponentInputBinding() so they arrive as input(), instead of subscribing to ActivatedRoute.

Forms, DOM and deprecated APIs

  • New forms on v22 use Signal Forms (form(), [formField], required()); on v20/21, or in an existing reactive form, use typed Reactive Forms with nonNullable. Never mix both APIs in one form.
  • DOM measurement and third-party widget setup go in afterNextRender({ read: … }) or afterEveryRender, never setTimeout(0). afterRender was renamed in v20 and no longer compiles.
  • Do not use @angular/animations in new code — it is deprecated. Use animate.enter/animate.leave with CSS.
  • Keep strict and strictTemplates on; no any, no ! to silence an error.

Go deeper: angular-development for writing code, angular-architecture for structure, angular-testing for tests, angular-performance for slowness, angular-ssr for server rendering, angular-migration for upgrades, and frontend-code-review before opening a pull request.