[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7F7GR2QG7T0N7N8NEDH2733":3,"skill-same:01M7F7GR2QG7T0N7N8NEDH2733":74},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":34,"commitSha":35,"skillDirectory":36,"forksCount":37,"repositoryHtmlUrl":38,"repositoryHomepageUrl":6,"ownerHtmlUrl":39,"ownerBlogUrl":6,"ownerDescription":40,"updatedAt":41,"install":42,"resources":55},"01M7F7GR2QG7T0N7N8NEDH2733","angular",null,"Use when building, refactoring, or debugging Angular (v20\u002F21+): standalone components, signals, zoneless change detection, @if\u002F@for\u002F@defer control flow, inject() DI, resource()\u002FhttpResource(), RxJS interop, NgRx SignalStore, ng CLI. NOT React (that is react), NOT Next.js (that is nextjs), NOT a TypeScript language question (that is typescript).","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F06-前端与设计\u002Fangular-ericrisco__rsc-harness\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\nname: angular\ndescription: \"Use when building, refactoring, or debugging Angular (v20\u002F21+): standalone components, signals, zoneless change detection, @if\u002F@for\u002F@defer control flow, inject() DI, resource()\u002FhttpResource(), RxJS interop, NgRx SignalStore, ng CLI. NOT React (that is react), NOT Next.js (that is nextjs), NOT a TypeScript language question (that is typescript).\"\ntags: [angular, frontend, web, signals, typescript, spa]\nrecommends: [typescript, testing-web, secure-coding]\norigin: risco\n---\n\n# Angular — Standalone, Signals, Zoneless (Angular 20\u002F21+)\n\n> Build Angular the way it ships in 2026: standalone components, signals as the reactivity model, zoneless change detection, built-in control flow, and `inject()` DI. Treat NgModules, `*ngFor`, and `@Input()` decorators as legacy you only touch to migrate.\n\n## Not this skill\n\n**AngularJS (1.x)** is out of scope entirely — this skill is Angular 2+ only and the APIs do not map.\nRoute elsewhere for **React** → `..\u002Freact\u002FSKILL.md`; **Next.js App Router** → `..\u002Fnextjs\u002FSKILL.md`;\n**Vue\u002FNuxt, Svelte, SolidJS, Astro** → `..\u002Fvue-nuxt\u002FSKILL.md`, `..\u002Fsvelte\u002FSKILL.md`,\n`..\u002Fsolid-js\u002FSKILL.md`, `..\u002Fastro\u002FSKILL.md`; a **pure TypeScript language question** (generics,\nnarrowing, tsconfig) with no Angular dimension → `..\u002Ftypescript\u002FSKILL.md`; a **standalone NestJS\nAPI** → `..\u002Fnestjs\u002FSKILL.md`; a generic Node service → `..\u002Fnodejs\u002FSKILL.md`; **cross-framework\nPlaywright e2e strategy** → `..\u002Ftesting-web\u002FSKILL.md` \u002F `..\u002Fe2e-testing\u002FSKILL.md`. Angular Universal\nSSR and Angular's own `ng test` (Vitest) setup stay here.\n\n## Decide first\n\n| Situation | Do this | Why |\n|-----------|---------|-----|\n| Greenfield app \u002F new feature | Zoneless + signals + standalone by default. `ng new` (Angular 21) already excludes Zone.js. | The defaults shipped stable in v20-v21; fight them and you write more code that the framework now does for you. |\n| Brownfield NgModule + decorator app | Migrate incrementally with the schematics in `references\u002Fmigration.md` (NgModule→standalone, control flow, decorator→signal inputs, Zone.js→zoneless, Karma→Vitest); do not rewrite. Keep Zone.js until you flip it on purpose. | A working app that uses `*ngIf` is not a bug. Churn introduces risk for no user value. |\n| \"View not updating\" complaint | Jump to the change-detection section: signal not read in template, `OnPush` without a signal, or stale Zone.js assumption. | Zoneless means a mutation that no signal observes will never repaint — the fix is structural, not a `detectChanges()` call. |\n\n## The modern baseline\n\nNo NgModules. Bootstrap a standalone root component and configure providers in `app.config.ts`.\n\n```typescript\n\u002F\u002F main.ts\nimport { bootstrapApplication } from '@angular\u002Fplatform-browser';\nimport { App } from '.\u002Fapp\u002Fapp';\nimport { appConfig } from '.\u002Fapp\u002Fapp.config';\n\nbootstrapApplication(App, appConfig);\n```\n\n```typescript\n\u002F\u002F app\u002Fapp.config.ts\nimport { ApplicationConfig, provideZonelessChangeDetection } from '@angular\u002Fcore';\nimport { provideRouter } from '@angular\u002Frouter';\nimport { provideHttpClient, withFetch } from '@angular\u002Fcommon\u002Fhttp';\nimport { routes } from '.\u002Fapp.routes';\n\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    provideZonelessChangeDetection(), \u002F\u002F no Zone.js; CD driven by signals + events\n    provideRouter(routes),\n    provideHttpClient(withFetch()),\n  ],\n};\n```\n\n- Rule: one `bootstrapApplication` call, providers in `app.config.ts`. Why: NgModule bootstrap (`platformBrowserDynamic().bootstrapModule(AppModule)`) is the legacy path — more files, slower to reason about.\n- Rule: components are `standalone` by default (the `standalone` flag is implied in v20+; do not write `standalone: true` in new code, and never write `standalone: false`). Why: standalone is the framework default now; the flag is noise.\n\n**Bad → Good**\n\n```typescript\n\u002F\u002F Bad — NgModule wiring for a single component\n@NgModule({ declarations: [UserCard], imports: [CommonModule], exports: [UserCard] })\nexport class UserCardModule {}\n\n\u002F\u002F Good — standalone component imports only what it uses\n@Component({\n  selector: 'app-user-card',\n  imports: [DatePipe],\n  template: `\u003Cp>{{ joined() | date }}\u003C\u002Fp>`,\n})\nexport class UserCard {\n  joined = input.required\u003CDate>();\n}\n```\n\n## Signals as the reactivity model\n\n`signal()` holds state, `computed()` derives it, `effect()` runs side effects, `linkedSignal()` resets writable state when a source changes.\n\n```typescript\nimport { signal, computed, effect, linkedSignal } from '@angular\u002Fcore';\n\nconst qty = signal(1);\nconst price = signal(9.99);\nconst total = computed(() => qty() * price());        \u002F\u002F derived — recomputes lazily\nconst draftQty = linkedSignal(() => qty());            \u002F\u002F writable, resets when qty changes\n\neffect(() => console.log('total changed:', total())); \u002F\u002F side effect ONLY (logging, DOM, sync)\n```\n\n- Rule: derive with `computed()`, never with `effect()`. Why: an `effect()` that writes a signal to \"compute\" a value creates a hidden dependency graph that loops or fires extra times — `computed()` is pull-based and memoized.\n- Rule: `effect()` is for side effects (logging, `localStorage`, imperative DOM, 3rd-party libs), not for keeping two signals in sync. Why: synced state belongs in `computed()` or `linkedSignal()`.\n\nComponent I\u002FO is signal-based: `input()`, `input.required()`, `output()`, `model()` for two-way.\n\n**Bad → Good**\n\n```typescript\n\u002F\u002F Bad — decorator I\u002FO, mutable, no type-safety on required\n@Input() userId!: string;\n@Output() saved = new EventEmitter\u003CUser>();\n\n\u002F\u002F Good — signal inputs\u002Foutputs\nuserId = input.required\u003Cstring>();          \u002F\u002F read as userId()\nsaved = output\u003CUser>();                     \u002F\u002F emit with saved.emit(user)\nname = model('');                           \u002F\u002F two-way: [(name)]=\"...\"\n```\n\n## Templates: built-in control flow\n\nUse `@if` \u002F `@for` \u002F `@switch` \u002F `@defer`. The legacy `*ngIf` \u002F `*ngFor` \u002F `*ngSwitch` structural directives are deprecated.\n\n```html\n@if (user(); as u) {\n  \u003Ch1>{{ u.name }}\u003C\u002Fh1>\n} @else {\n  \u003Capp-spinner \u002F>\n}\n\n@for (item of items(); track item.id) {\n  \u003Cli>{{ item.label }}\u003C\u002Fli>\n} @empty {\n  \u003Cli>No items\u003C\u002Fli>\n}\n\n@defer (on viewport) {\n  \u003Capp-heavy-chart [data]=\"rows()\" \u002F>\n} @placeholder {\n  \u003Cdiv class=\"skeleton\">\u003C\u002Fdiv>\n}\n```\n\n- Rule: every `@for` **must** declare `track`. Why: it is required syntax (the template won't compile without it) and it controls DOM reuse — `track item.id` over `track $index` when items have stable identity, or the DOM thrashes on reorder.\n- Rule: reach for `@defer` to lazy-load heavy sub-trees and enable incremental hydration. Why: it ships less JS up front without manual `loadComponent` plumbing.\n\n**Bad → Good**\n\n```html\n\u003C!-- Bad — legacy structural directive, no tracking -->\n\u003Cli *ngFor=\"let item of items\">{{ item.label }}\u003C\u002Fli>\n\n\u003C!-- Good — built-in control flow with track -->\n@for (item of items(); track item.id) { \u003Cli>{{ item.label }}\u003C\u002Fli> }\n```\n\n## Data fetching\n\nDefault to signal-based resources; reach for `HttpClient` + RxJS only when you need streams, cancellation, or operator composition.\n\n```typescript\nimport { httpResource } from '@angular\u002Fcommon\u002Fhttp';\nimport { resource } from '@angular\u002Fcore';\n\n\u002F\u002F httpResource — declarative GET wired to HttpClient; reactive to its URL signal\nusers = httpResource\u003CUser[]>(() => `\u002Fapi\u002Fusers?team=${this.team()}`);\n\u002F\u002F template: @if (users.isLoading()) {…} @else { @for (u of users.value(); track u.id) {…} }\n\u002F\u002F users.error()  -> error signal;  users.reload() -> refetch\n\n\u002F\u002F resource — any async loader (not just HTTP)\nprofile = resource({\n  params: () => ({ id: this.userId() }),\n  loader: ({ params }) => fetchProfile(params.id),\n});\n```\n\n- Rule: `httpResource()`\u002F`resource()` give you `value()`, `isLoading()`, `error()`, `reload()` for free — prefer them over a manual `subscribe` that you have to clean up. Why: less boilerplate, no leak, refetches automatically when its source signals change.\n- Rule: when you genuinely need a stream (websocket, debounced search, retry\u002FswitchMap), keep `HttpClient` + RxJS and bridge to a signal with `toSignal()`. Why: signals are not streams; do not fake backpressure with effects. `references\u002Fsignals-rxjs.md` has the signals-vs-RxJS decision matrix, `toSignal`\u002F`toObservable` interop recipes, `effect` pitfalls (infinite loops, untracked reads), and `takeUntilDestroyed`.\n\n## DI & services\n\n```typescript\n@Injectable({ providedIn: 'root' })\nexport class UserApi {\n  private http = inject(HttpClient);          \u002F\u002F field initializer — no constructor needed\n  list = () => this.http.get\u003CUser[]>('\u002Fapi\u002Fusers');\n}\n```\n\n- Rule: inject with `inject()`, not constructor parameters. Why: `inject()` works in field initializers and composes into plain functions (guards, factories); constructor DI is the legacy ergonomic.\n- Rule: `providedIn: 'root'` for app-wide singletons. Why: tree-shakable — unused services drop from the bundle.\n- Rule: HTTP cross-cutting concerns are functional interceptors: `provideHttpClient(withInterceptors([authInterceptor]))`. Why: class interceptors with `HTTP_INTERCEPTORS` are the older multi-provider pattern.\n\n## Routing\n\n```typescript\n\u002F\u002F app.routes.ts\nexport const routes: Routes = [\n  { path: 'users', loadComponent: () => import('.\u002Fusers\u002Fusers-list').then(m => m.UsersList) },\n  { path: 'users\u002F:id', loadComponent: () => import('.\u002Fusers\u002Fuser-detail').then(m => m.UserDetail),\n    canActivate: [authGuard] },\n];\n\nexport const authGuard: CanActivateFn = () => inject(AuthService).isLoggedIn();\n```\n\nEnable route-bound signal inputs with `withComponentInputBinding()` in `provideRouter`, then read route params as signal inputs:\n\n```typescript\nprovideRouter(routes, withComponentInputBinding());\n\u002F\u002F in UserDetail: id = input.required\u003Cstring>();  \u002F\u002F bound from the :id segment\n```\n\n- Rule: lazy-load routes with `loadComponent` (or `loadChildren` with a routes array). Why: smaller initial bundle, no NgModule needed.\n- Rule: guards\u002Fresolvers are functions (`CanActivateFn`, `ResolveFn`) using `inject()`. Why: class-based guards are deprecated.\n\n## State\n\n- Local\u002Ffeature state → a signal service (`@Injectable` holding `signal`\u002F`computed`). Simple, no library.\n- App-wide state → **NgRx SignalStore** (`signalStore`, `withState`, `withComputed`, `withMethods`, `withProps`) — signals-native, pairs cleanly with `resource()`.\n\n```typescript\nexport const CartStore = signalStore(\n  { providedIn: 'root' },\n  withState({ items: [] as Item[] }),\n  withComputed(({ items }) => ({ count: computed(() => items().length) })),\n  withMethods((store) => ({ add: (i: Item) => patchState(store, s => ({ items: [...s.items, i] })) })),\n);\n```\n\n- Note: **Signal Forms** is experimental (prototype since Angular 21.0.0-next.2). For production forms use reactive\u002Ftyped forms (`FormGroup`\u002F`FormControl` with typed values). Why: do not ship a prototype API to users.\n\n## CLI workflow\n\n```bash\nng new my-app                  # Angular 21: zoneless + standalone + Vitest by default\nng generate component user-card # standalone by default; no --standalone flag needed\nng generate service user-api\nng build                       # production build\nng test                        # Vitest (default runner in v21; Karma is deprecated)\nng update @angular\u002Fcore @angular\u002Fcli  # version bumps + automated migrations\n```\n\n## Testing\n\nUse Vitest + `TestBed`. Provide zoneless CD in tests and set signal inputs via `componentRef`.\n\n```typescript\nimport { TestBed } from '@angular\u002Fcore\u002Ftesting';\nimport { provideZonelessChangeDetection } from '@angular\u002Fcore';\n\nit('renders the user name', async () => {\n  TestBed.configureTestingModule({\n    providers: [provideZonelessChangeDetection()],\n  });\n  const fixture = TestBed.createComponent(UserCard);\n  fixture.componentRef.setInput('joined', new Date('2026-01-01'));\n  await fixture.whenStable();                       \u002F\u002F not detectChanges() — let CD settle\n  expect(fixture.nativeElement.textContent).toContain('2026');\n});\n```\n\n- Rule: set signal inputs with `fixture.componentRef.setInput('name', value)`, never by poking the instance field. Why: `setInput` flows through the input pipeline and marks the view dirty.\n- Rule: prefer `await fixture.whenStable()` over manual `detectChanges()` loops under zoneless. Why: it waits for the scheduler to flush instead of forcing a single synchronous pass.\n\n## Anti-patterns\n\n| Bad | Why it's wrong | Good |\n|-----|----------------|------|\n| `@NgModule` in new code | Standalone is the default; modules add ceremony and slow analysis | Standalone component with an `imports: []` array |\n| `*ngIf` \u002F `*ngFor` \u002F `*ngSwitch` | Legacy structural directives; deprecated | `@if` \u002F `@for (… ; track id)` \u002F `@switch` |\n| `@Input()` \u002F `@Output()` decorators | No required-input safety, not signal-reactive | `input()` \u002F `input.required()` \u002F `output()` \u002F `model()` |\n| `effect(() => this.total.set(a()*b()))` | Effect-to-derive-state loops and double-fires | `total = computed(() => a()*b())` |\n| `@for` without `track` | Won't compile; if forced, DOM thrashes on reorder | `track item.id` (stable identity) |\n| `subscribe()` in a component with no teardown | Memory leak; runs after the view is destroyed | `toSignal()` or `takeUntilDestroyed()` |\n| `ChangeDetectorRef.detectChanges()` to \"fix\" a stale view | Masks the real cause under zoneless | Read the value through a signal so CD tracks it |\n| Nested `subscribe()` inside `subscribe()` | Callback pyramid, lost cancellation | `switchMap`\u002F`concatMap`, one subscription |\n| Constructor DI only (`constructor(private x: X)`) | Legacy ergonomic; can't compose into functions | `private x = inject(X)` |\n\n`scripts\u002Fverify.sh` is a heuristic copy-banlist lint — it greps your Angular sources for the banned patterns above. It is a hint, not a compiler.\n","# Angular — Standalone, Signals, Zoneless (Angular 20\u002F21+)\n\n> Build Angular the way it ships in 2026: standalone components, signals as the reactivity model, zoneless change detection, built-in control flow, and `inject()` DI. Treat NgModules, `*ngFor`, and `@Input()` decorators as legacy you only touch to migrate.\n\n## Not this skill\n\n**AngularJS (1.x)** is out of scope entirely — this skill is Angular 2+ only and the APIs do not map.\nRoute elsewhere for **React** → `..\u002Freact\u002FSKILL.md`; **Next.js App Router** → `..\u002Fnextjs\u002FSKILL.md`;\n**Vue\u002FNuxt, Svelte, SolidJS, Astro** → `..\u002Fvue-nuxt\u002FSKILL.md`, `..\u002Fsvelte\u002FSKILL.md`,\n`..\u002Fsolid-js\u002FSKILL.md`, `..\u002Fastro\u002FSKILL.md`; a **pure TypeScript language question** (generics,\nnarrowing, tsconfig) with no Angular dimension → `..\u002Ftypescript\u002FSKILL.md`; a **standalone NestJS\nAPI** → `..\u002Fnestjs\u002FSKILL.md`; a generic Node service → `..\u002Fnodejs\u002FSKILL.md`; **cross-framework\nPlaywright e2e strategy** → `..\u002Ftesting-web\u002FSKILL.md` \u002F `..\u002Fe2e-testing\u002FSKILL.md`. Angular Universal\nSSR and Angular's own `ng test` (Vitest) setup stay here.\n\n## Decide first\n\n| Situation | Do this | Why |\n|-----------|---------|-----|\n| Greenfield app \u002F new feature | Zoneless + signals + standalone by default. `ng new` (Angular 21) already excludes Zone.js. | The defaults shipped stable in v20-v21; fight them and you write more code that the framework now does for you. |\n| Brownfield NgModule + decorator app | Migrate incrementally with the schematics in `references\u002Fmigration.md` (NgModule→standalone, control flow, decorator→signal inputs, Zone.js→zoneless, Karma→Vitest); do not rewrite. Keep Zone.js until you flip it on purpose. | A working app that uses `*ngIf` is not a bug. Churn introduces risk for no user value. |\n| \"View not updating\" complaint | Jump to the change-detection section: signal not read in template, `OnPush` without a signal, or stale Zone.js assumption. | Zoneless means a mutation that no signal observes will never repaint — the fix is structural, not a `detectChanges()` call. |\n\n## The modern baseline\n\nNo NgModules. Bootstrap a standalone root component and configure providers in `app.config.ts`.\n\n```typescript\n\u002F\u002F main.ts\nimport { bootstrapApplication } from '@angular\u002Fplatform-browser';\nimport { App } from '.\u002Fapp\u002Fapp';\nimport { appConfig } from '.\u002Fapp\u002Fapp.config';\n\nbootstrapApplication(App, appConfig);\n```\n\n```typescript\n\u002F\u002F app\u002Fapp.config.ts\nimport { ApplicationConfig, provideZonelessChangeDetection } from '@angular\u002Fcore';\nimport { provideRouter } from '@angular\u002Frouter';\nimport { provideHttpClient, withFetch } from '@angular\u002Fcommon\u002Fhttp';\nimport { routes } from '.\u002Fapp.routes';\n\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    provideZonelessChangeDetection(), \u002F\u002F no Zone.js; CD driven by signals + events\n    provideRouter(routes),\n    provideHttpClient(withFetch()),\n  ],\n};\n```\n\n- Rule: one `bootstrapApplication` call, providers in `app.config.ts`. Why: NgModule bootstrap (`platformBrowserDynamic().bootstrapModule(AppModule)`) is the legacy path — more files, slower to reason about.\n- Rule: components are `standalone` by default (the `standalone` flag is implied in v20+; do not write `standalone: true` in new code, and never write `standalone: false`). Why: standalone is the framework default now; the flag is noise.\n\n**Bad → Good**\n\n```typescript\n\u002F\u002F Bad — NgModule wiring for a single component\n@NgModule({ declarations: [UserCard], imports: [CommonModule], exports: [UserCard] })\nexport class UserCardModule {}\n\n\u002F\u002F Good — standalone component imports only what it uses\n@Component({\n  selector: 'app-user-card',\n  imports: [DatePipe],\n  template: `\u003Cp>{{ joined() | date }}\u003C\u002Fp>`,\n})\nexport class UserCard {\n  joined = input.required\u003CDate>();\n}\n```\n\n## Signals as the reactivity model\n\n`signal()` holds state, `computed()` derives it, `effect()` runs side effects, `linkedSignal()` resets writable state when a source changes.\n\n```typescript\nimport { signal, computed, effect, linkedSignal } from '@angular\u002Fcore';\n\nconst qty = signal(1);\nconst price = signal(9.99);\nconst total = computed(() => qty() * price());        \u002F\u002F derived — recomputes lazily\nconst draftQty = linkedSignal(() => qty());            \u002F\u002F writable, resets when qty changes\n\neffect(() => console.log('total changed:', total())); \u002F\u002F side effect ONLY (logging, DOM, sync)\n```\n\n- Rule: derive with `computed()`, never with `effect()`. Why: an `effect()` that writes a signal to \"compute\" a value creates a hidden dependency graph that loops or fires extra times — `computed()` is pull-based and memoized.\n- Rule: `effect()` is for side effects (logging, `localStorage`, imperative DOM, 3rd-party libs), not for keeping two signals in sync. Why: synced state belongs in `computed()` or `linkedSignal()`.\n\nComponent I\u002FO is signal-based: `input()`, `input.required()`, `output()`, `model()` for two-way.\n\n**Bad → Good**\n\n```typescript\n\u002F\u002F Bad — decorator I\u002FO, mutable, no type-safety on required\n@Input() userId!: string;\n@Output() saved = new EventEmitter\u003CUser>();\n\n\u002F\u002F Good — signal inputs\u002Foutputs\nuserId = input.required\u003Cstring>();          \u002F\u002F read as userId()\nsaved = output\u003CUser>();                     \u002F\u002F emit with saved.emit(user)\nname = model('');                           \u002F\u002F two-way: [(name)]=\"...\"\n```\n\n## Templates: built-in control flow\n\nUse `@if` \u002F `@for` \u002F `@switch` \u002F `@defer`. The legacy `*ngIf` \u002F `*ngFor` \u002F `*ngSwitch` structural directives are deprecated.\n\n```html\n@if (user(); as u) {\n  \u003Ch1>{{ u.name }}\u003C\u002Fh1>\n} @else {\n  \u003Capp-spinner \u002F>\n}\n\n@for (item of items(); track item.id) {\n  \u003Cli>{{ item.label }}\u003C\u002Fli>\n} @empty {\n  \u003Cli>No items\u003C\u002Fli>\n}\n\n@defer (on viewport) {\n  \u003Capp-heavy-chart [data]=\"rows()\" \u002F>\n} @placeholder {\n  \u003Cdiv class=\"skeleton\">\u003C\u002Fdiv>\n}\n```\n\n- Rule: every `@for` **must** declare `track`. Why: it is required syntax (the template won't compile without it) and it controls DOM reuse — `track item.id` over `track $index` when items have stable identity, or the DOM thrashes on reorder.\n- Rule: reach for `@defer` to lazy-load heavy sub-trees and enable incremental hydration. Why: it ships less JS up front without manual `loadComponent` plumbing.\n\n**Bad → Good**\n\n```html\n\u003C!-- Bad — legacy structural directive, no tracking -->\n\u003Cli *ngFor=\"let item of items\">{{ item.label }}\u003C\u002Fli>\n\n\u003C!-- Good — built-in control flow with track -->\n@for (item of items(); track item.id) { \u003Cli>{{ item.label }}\u003C\u002Fli> }\n```\n\n## Data fetching\n\nDefault to signal-based resources; reach for `HttpClient` + RxJS only when you need streams, cancellation, or operator composition.\n\n```typescript\nimport { httpResource } from '@angular\u002Fcommon\u002Fhttp';\nimport { resource } from '@angular\u002Fcore';\n\n\u002F\u002F httpResource — declarative GET wired to HttpClient; reactive to its URL signal\nusers = httpResource\u003CUser[]>(() => `\u002Fapi\u002Fusers?team=${this.team()}`);\n\u002F\u002F template: @if (users.isLoading()) {…} @else { @for (u of users.value(); track u.id) {…} }\n\u002F\u002F users.error()  -> error signal;  users.reload() -> refetch\n\n\u002F\u002F resource — any async loader (not just HTTP)\nprofile = resource({\n  params: () => ({ id: this.userId() }),\n  loader: ({ params }) => fetchProfile(params.id),\n});\n```\n\n- Rule: `httpResource()`\u002F`resource()` give you `value()`, `isLoading()`, `error()`, `reload()` for free — prefer them over a manual `subscribe` that you have to clean up. Why: less boilerplate, no leak, refetches automatically when its source signals change.\n- Rule: when you genuinely need a stream (websocket, debounced search, retry\u002FswitchMap), keep `HttpClient` + RxJS and bridge to a signal with `toSignal()`. Why: signals are not streams; do not fake backpressure with effects. `references\u002Fsignals-rxjs.md` has the signals-vs-RxJS decision matrix, `toSignal`\u002F`toObservable` interop recipes, `effect` pitfalls (infinite loops, untracked reads), and `takeUntilDestroyed`.\n\n## DI & services\n\n```typescript\n@Injectable({ providedIn: 'root' })\nexport class UserApi {\n  private http = inject(HttpClient);          \u002F\u002F field initializer — no constructor needed\n  list = () => this.http.get\u003CUser[]>('\u002Fapi\u002Fusers');\n}\n```\n\n- Rule: inject with `inject()`, not constructor parameters. Why: `inject()` works in field initializers and composes into plain functions (guards, factories); constructor DI is the legacy ergonomic.\n- Rule: `providedIn: 'root'` for app-wide singletons. Why: tree-shakable — unused services drop from the bundle.\n- Rule: HTTP cross-cutting concerns are functional interceptors: `provideHttpClient(withInterceptors([authInterceptor]))`. Why: class interceptors with `HTTP_INTERCEPTORS` are the older multi-provider pattern.\n\n## Routing\n\n```typescript\n\u002F\u002F app.routes.ts\nexport const routes: Routes = [\n  { path: 'users', loadComponent: () => import('.\u002Fusers\u002Fusers-list').then(m => m.UsersList) },\n  { path: 'users\u002F:id', loadComponent: () => import('.\u002Fusers\u002Fuser-detail').then(m => m.UserDetail),\n    canActivate: [authGuard] },\n];\n\nexport const authGuard: CanActivateFn = () => inject(AuthService).isLoggedIn();\n```\n\nEnable route-bound signal inputs with `withComponentInputBinding()` in `provideRouter`, then read route params as signal inputs:\n\n```typescript\nprovideRouter(routes, withComponentInputBinding());\n\u002F\u002F in UserDetail: id = input.required\u003Cstring>();  \u002F\u002F bound from the :id segment\n```\n\n- Rule: lazy-load routes with `loadComponent` (or `loadChildren` with a routes array). Why: smaller initial bundle, no NgModule needed.\n- Rule: guards\u002Fresolvers are functions (`CanActivateFn`, `ResolveFn`) using `inject()`. Why: class-based guards are deprecated.\n\n## State\n\n- Local\u002Ffeature state → a signal service (`@Injectable` holding `signal`\u002F`computed`). Simple, no library.\n- App-wide state → **NgRx SignalStore** (`signalStore`, `withState`, `withComputed`, `withMethods`, `withProps`) — signals-native, pairs cleanly with `resource()`.\n\n```typescript\nexport const CartStore = signalStore(\n  { providedIn: 'root' },\n  withState({ items: [] as Item[] }),\n  withComputed(({ items }) => ({ count: computed(() => items().length) })),\n  withMethods((store) => ({ add: (i: Item) => patchState(store, s => ({ items: [...s.items, i] })) })),\n);\n```\n\n- Note: **Signal Forms** is experimental (prototype since Angular 21.0.0-next.2). For production forms use reactive\u002Ftyped forms (`FormGroup`\u002F`FormControl` with typed values). Why: do not ship a prototype API to users.\n\n## CLI workflow\n\n```bash\nng new my-app                  # Angular 21: zoneless + standalone + Vitest by default\nng generate component user-card # standalone by default; no --standalone flag needed\nng generate service user-api\nng build                       # production build\nng test                        # Vitest (default runner in v21; Karma is deprecated)\nng update @angular\u002Fcore @angular\u002Fcli  # version bumps + automated migrations\n```\n\n## Testing\n\nUse Vitest + `TestBed`. Provide zoneless CD in tests and set signal inputs via `componentRef`.\n\n```typescript\nimport { TestBed } from '@angular\u002Fcore\u002Ftesting';\nimport { provideZonelessChangeDetection } from '@angular\u002Fcore';\n\nit('renders the user name', async () => {\n  TestBed.configureTestingModule({\n    providers: [provideZonelessChangeDetection()],\n  });\n  const fixture = TestBed.createComponent(UserCard);\n  fixture.componentRef.setInput('joined', new Date('2026-01-01'));\n  await fixture.whenStable();                       \u002F\u002F not detectChanges() — let CD settle\n  expect(fixture.nativeElement.textContent).toContain('2026');\n});\n```\n\n- Rule: set signal inputs with `fixture.componentRef.setInput('name', value)`, never by poking the instance field. Why: `setInput` flows through the input pipeline and marks the view dirty.\n- Rule: prefer `await fixture.whenStable()` over manual `detectChanges()` loops under zoneless. Why: it waits for the scheduler to flush instead of forcing a single synchronous pass.\n\n## Anti-patterns\n\n| Bad | Why it's wrong | Good |\n|-----|----------------|------|\n| `@NgModule` in new code | Standalone is the default; modules add ceremony and slow analysis | Standalone component with an `imports: []` array |\n| `*ngIf` \u002F `*ngFor` \u002F `*ngSwitch` | Legacy structural directives; deprecated | `@if` \u002F `@for (… ; track id)` \u002F `@switch` |\n| `@Input()` \u002F `@Output()` decorators | No required-input safety, not signal-reactive | `input()` \u002F `input.required()` \u002F `output()` \u002F `model()` |\n| `effect(() => this.total.set(a()*b()))` | Effect-to-derive-state loops and double-fires | `total = computed(() => a()*b())` |\n| `@for` without `track` | Won't compile; if forced, DOM thrashes on reorder | `track item.id` (stable identity) |\n| `subscribe()` in a component with no teardown | Memory leak; runs after the view is destroyed | `toSignal()` or `takeUntilDestroyed()` |\n| `ChangeDetectorRef.detectChanges()` to \"fix\" a stale view | Masks the real cause under zoneless | Read the value through a signal so CD tracks it |\n| Nested `subscribe()` inside `subscribe()` | Callback pyramid, lost cancellation | `switchMap`\u002F`concatMap`, one subscription |\n| Constructor DI only (`constructor(private x: X)`) | Legacy ergonomic; can't compose into functions | `private x = inject(X)` |\n\n`scripts\u002Fverify.sh` is a heuristic copy-banlist lint — it greps your Angular sources for the banned patterns above. It is a hint, not a compiler.\n",{"name":5,"tags":24,"origin":30,"recommends":31,"description":7},[5,25,26,27,28,29],"frontend","web","signals","typescript","spa","risco",[28,32,33],"testing-web","secure-coding","main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","06-前端与设计\u002Fangular-ericrisco__rsc-harness",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill angular",{"tool":48,"command":49},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill angular",{"tool":51,"command":52},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill angular","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F06-前端与设计\u002Fangular-ericrisco__rsc-harness\u002FSKILL.md",true,[56,62,66,70],{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"evals\u002Fcases.yaml","REFERENCE","参考文档",2013,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F06-前端与设计\u002Fangular-ericrisco__rsc-harness\u002Fevals\u002Fcases.yaml",{"path":63,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":64,"sourceHtmlUrl":65},"evals\u002FREADME.md",72,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F06-前端与设计\u002Fangular-ericrisco__rsc-harness\u002Fevals\u002FREADME.md",{"path":67,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":68,"sourceHtmlUrl":69},"references\u002Fmigration.md",4054,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F06-前端与设计\u002Fangular-ericrisco__rsc-harness\u002Freferences\u002Fmigration.md",{"path":71,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":72,"sourceHtmlUrl":73},"references\u002Fsignals-rxjs.md",4100,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F06-前端与设计\u002Fangular-ericrisco__rsc-harness\u002Freferences\u002Fsignals-rxjs.md",[75,82,87,94,101,108],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],{"skillNo":83,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":19},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":19},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":19},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]