angular-modernization

작성자: bitwarden

Angular 코드(예: 컴포넌트 및 디렉티브)를 자동 CLI 마이그레이션과 Bitwarden 특화 패턴을 모두 사용하여 모범 사례를 따르도록 현대화합니다. YOU…

npx skills add https://github.com/bitwarden/clients --skill angular-modernization

Angular Modernization

Transforms legacy Angular components to modern architecture using a two-step approach:

  1. Automated migrations - Angular CLI schematics for standalone, control flow, and signals
  2. Bitwarden patterns - ADR compliance, OnPush change detection, proper visibility, thin components

Workflow

Step 1: Run Angular CLI Migrations

⚠️ CRITICAL: ALWAYS use Angular CLI migrations when available. DO NOT manually migrate features that have CLI schematics.

Angular provides automated schematics that handle edge cases, update tests, and ensure correctness. Manual migration should ONLY be used for patterns not covered by CLI tools.

IMPORTANT:

  • Always run the commands using npx ng.
  • All the commands must be run on directories and NOT files. Use the --path option to target directories.
  • Run migrations in order (some depend on others)

1. Standalone Components

npx ng generate @angular/core:standalone --path=<directory> --mode=convert-to-standalone

NgModule-based → standalone architecture

2. Control Flow Syntax

npx ng generate @angular/core:control-flow

*ngIf, *ngFor, *ngSwitch@if, @for, @switch

3. Signal Inputs

npx ng generate @angular/core:signal-input-migration

@Input() → signal inputs

4. Signal Outputs

npx ng generate @angular/core:output-migration

@Output() → signal outputs

5. Signal Queries

npx ng generate @angular/core:signal-queries-migration

@ViewChild, @ContentChild, etc. → signal queries

6. inject() Function

npx ng generate @angular/core:inject-migration

Constructor injection → inject() function

7. Self-Closing Tag

npx ng generate @angular/core:self-closing-tag

Updates templates to self-closing syntax

8. Unused Imports

npx ng generate @angular/core:unused-imports

Removes unused imports

Step 2: Apply Bitwarden Patterns

See migration-patterns.md for detailed examples.

  1. Add OnPush change detection
  2. Apply visibility modifiers (protected for template access, private for internal)
  3. Convert local component state to signals
  4. Keep service observables (don't convert to signals)
  5. Extract business logic to services
  6. Organize class members correctly
  7. Update tests for standalone

Step 3: Validate

  • Fix linting and formatting using npm run lint:fix
  • Run tests using npm run test

If any errors occur, fix them accordingly.

Key Decisions

Signals vs Observables

  • Signals - Component-local state only (ADR-0027)
  • Observables - Service state and cross-component communication (ADR-0003)
  • Use toSignal() to bridge observables into signal-based components

Visibility

  • protected - Template-accessible members
  • private - Internal implementation

Other Rules

  • Always add OnPush change detection
  • No TypeScript enums (use const objects with type aliases per ADR-0025)
  • No code regions (refactor instead)
  • Thin components (business logic in services)

Validation Checklist

Before completing migration:

  • OnPush change detection added
  • Visibility modifiers applied (protected/private)
  • Signals for component state, observables for service state
  • Class members organized (see migration-patterns.md)
  • Tests updated and passing
  • No new TypeScript enums
  • No code regions

References

Bitwarden ADRs

Angular Resources

bitwarden의 다른 스킬

action-audit
bitwarden
사용자의 요청에서 모드를 결정합니다.
official
action-remediate
bitwarden
진행하기 전에 사용자가 조치할 감사 결과가 있는지 확인하세요. 이는 이전에 action-audit 스킬을 실행한 결과에서 나와야 합니다. 다음을 확인하세요:
official
addressing-code-review-comments
bitwarden
사용자가 로컬에서 풀 리퀘스트 리뷰 코멘트를 처리하면서 리뷰어 피드백을 평가, 구현 또는 응답 초안 작성에 도움을 요청할 때 사용합니다.
official
analyzing-code-security
bitwarden
이 스킬은 사용자가 "코드 보안 문제 분석", "OWASP 취약점 확인", "CWE Top 25 기준 코드 검토", "찾기…"를 요청할 때 사용해야 합니다.
official
analyzing-git-sessions
bitwarden
특정 기간이나 커밋 범위 내의 Git 커밋과 변경 사항을 분석하여 코드 리뷰, 회고, 작업 로그 또는 세션을 위한 구조화된 요약을 제공합니다.
official
architecting-solutions
bitwarden
기술 리드 관점에서 아키텍처, 시스템 설계, 아키텍처 리뷰, 블래스트 반경 평가, 트레이드오프 분석, 의사 결정을 다룹니다. 계획 시 사용하세요...
official
atlassian-reader
bitwarden
Atlassian Cloud에서 Jira 이슈, 에픽, 스토리, 스프린트, 보드 및 Confluence 페이지를 읽기 전용 범위의 API 토큰과 curl 명령어를 통해 컨텍스트로 읽어옵니다.
official
avoiding-false-positives
bitwarden
코드 리뷰 중 발견 사항을 검증할 때 이 스킬을 사용하세요. 각 발견 사항에 대해 거부 기준과 확인 검사를 실행합니다. 발견 사항이 어떤 검사에서든 실패하면…
official