Communitygithub.com

Angular 開發者

生成 Angular 程式碼並提供架構指導。在建立專案、元件或服務,或針對響應式設計(signals、linkedSignal、resource)、表單、依賴注入、路由、SSR、無障礙(ARIA)、動畫、樣式(元件樣式、Tailwind CSS)、測試或 CLI 工具的最佳實踐時觸發。

Angular 開發者 是什麼?

此技能旨在為使用 Angular 框架的開發者提供全面的程式碼生成與架構指導。它涵蓋了 Angular 開發的各個方面,包括專案建立、元件生成、狀態管理(Signals、linkedSignal、resource)、表單處理、依賴注入、路由、無障礙設計(ARIA)、動畫與樣式、測試以及 CLI 工具使用。此技能會先分析專案的 Angular 版本,以確保提供的建議與最佳實踐符合該版本的特性。在生成程式碼後,它會自動執行 `ng build` 來驗證無建置錯誤,確保輸出正確無誤。它支援多種平台,例如 Claude Code、Cursor 或 Codex,並參考一系列 `references/*.md` 文件來取得詳細的實作指南。此技能也強調避免常見的反模式,例如在不正確的注入上下文使用 `inject()` 或在不適合的場合使用 `effect()`。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/angular-developer

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Angular 開發者指南

啟用時機

  • 在任何 Angular 專案或程式碼庫中工作時
  • 建立或初始化新的 Angular 專案、應用程式或函式庫時
  • 生成元件、服務、指令、管道、守衛或解析器時
  • 使用 Angular Signals、linkedSignal 或 resource 實作響應式設計時
  • 處理 Angular 表單(signal forms、反應式表單或樣板驅動表單)時
  • 設定依賴注入、路由、延遲載入或路由守衛時
  • 新增無障礙(ARIA)、動畫或元件樣式時
  • 編寫或偵錯 Angular 特定的測試(單元測試、元件測試工具、E2E)時
  • 設定 Angular CLI 工具或 Angular MCP 伺服器時
  1. 在提供指導前,務必先分析專案的 Angular 版本,因為最佳實踐和可用功能在不同版本之間可能會有顯著差異。如果使用 Angular CLI 建立新專案,除非使用者指定,否則不要指定版本。

  2. 生成程式碼時,請遵循 Angular 的樣式指南和最佳實踐,以確保可維護性和效能。使用 Angular CLI 來建構元件、服務、指令、管道和路由,以確保一致性。

  3. 完成程式碼生成後,請執行 ng build 以確保沒有建置錯誤。如果出現錯誤,請分析錯誤訊息並在繼續之前修復它們。不要跳過此步驟,因為這對於確保生成的程式碼正確且可運作至關重要。

建立新專案

如果使用者沒有提供指導,在建立新的 Angular 專案時,請使用以下預設值:

  1. 除非使用者另有指定,否則使用最新的穩定版 Angular。
  2. 僅當目標 Angular 版本支援 Signal Forms 時,才在新專案中優先使用 Signal Forms。了解更多

ng new 的執行規則: 當被要求建立新的 Angular 專案時,您必須依照以下嚴格步驟來確定正確的執行指令:

步驟 1:檢查使用者是否指定了版本。

  • 如果使用者要求特定版本(例如,Angular 15),請繞過本地安裝,嚴格使用 npx。
  • 指令: npx @angular/cli@<要求的版本> new <專案名稱>

步驟 2:檢查是否已安裝 Angular。

  • 如果沒有指定版本,請在終端機中執行 ng version 以檢查系統上是否已安裝 Angular CLI。
  • 如果指令成功並返回已安裝的版本,請直接使用本地/全域安裝。
  • 指令: ng new <專案名稱>

步驟 3:回退到最新版本。

  • 如果沒有指定版本,且 ng version 指令失敗(表示沒有 Angular 安裝),您必須使用 npx 來獲取最新版本。
  • 指令: npx @angular/cli@latest new <專案名稱>

元件

在處理 Angular 元件時,請根據任務查閱以下參考資料:

  • 基礎知識:結構、元資料、核心概念和樣板控制流程(@if、@for、@switch)。閱讀 components.md
  • 輸入:基於 Signal 的輸入、轉換和 model inputs。閱讀 inputs.md
  • 輸出:基於 Signal 的輸出和自訂事件最佳實踐。閱讀 outputs.md
  • 宿主元素:Host bindings 和屬性注入。閱讀 host-elements.md

如果您需要上述參考資料中未提供的更深入文件,請閱讀 https://angular.dev/guide/components 上的文件。

響應式設計與資料管理

在管理狀態和資料響應式時,請使用 Angular Signals 並查閱以下參考資料:

  • Signals 概述:核心 signal 概念(signal、computed)、響應式上下文和 untracked。閱讀 signals-overview.md
  • 相依狀態 (linkedSignal):建立連結到來源 signal 的可寫入狀態。閱讀 linked-signal.md
  • 非同步響應式 (resource):將非同步資料直接擷取到 signal 狀態中。閱讀 resource.md
  • 副作用 (effect):日誌記錄、第三方 DOM 操作 (afterRenderEffect),以及何時不應使用 effect。閱讀 effects.md

表單

在大多數新應用程式中,優先使用 signal forms。在決定表單策略時,請分析專案並考慮以下指導原則:

  • 如果應用程式版本支援 Signal Forms 且這是新表單,則優先使用 signal forms。

  • 對於較舊的應用程式或現有表單,請比照應用程式當前的表單策略。

  • Signal Forms:使用 signals 進行表單狀態管理。閱讀 signal-forms.md

  • 樣板驅動表單:適用於簡單表單。閱讀 template-driven-forms.md

  • 反應式表單:適用於複雜表單。閱讀 reactive-forms.md

依賴注入

在 Angular 中實作依賴注入時,請遵循以下指導原則:

  • 基礎知識:依賴注入概述、服務和 inject() 函式。閱讀 di-fundamentals.md
  • 建立和使用服務:建立服務、providedIn: 'root' 選項,以及注入到元件或其他服務中。閱讀 creating-services.md
  • 定義依賴提供者:自動與手動提供、InjectionToken、useClass、useValue、useFactory 和作用域。閱讀 defining-providers.md
  • 注入上下文:inject() 在何處允許使用、runInInjectionContext 和 assertInInjectionContext。閱讀 injection-context.md
  • 分層注入器:EnvironmentInjector 與 ElementInjector、解析規則、修飾詞(optional、skipSelf)以及 providers 與 viewProviders。閱讀 hierarchical-injectors.md

Angular Aria

在為以下任何模式建立可存取的無頭自訂元件時:Accordion、Listbox、Combobox、Menu、Tabs、Toolbar、Tree、Grid,請查閱以下參考資料:

  • Angular Aria 元件:建立無頭、可存取的元件(Accordion、Listbox、Combobox、Menu、Tabs、Toolbar、Tree、Grid)和樣式化 ARIA 屬性。閱讀 angular-aria.md

路由

在 Angular 中實作導航時,請查閱以下參考資料:

  • 定義路由:URL 路徑、靜態與動態區段、萬用字元和重新導向。閱讀 define-routes.md
  • 路由載入策略:立即載入與延遲載入,以及上下文感知載入。閱讀 loading-strategies.md
  • 使用 Outlet 顯示路由:使用 <router-outlet>、巢狀 outlet 和具名 outlet。閱讀 show-routes-with-outlets.md
  • 導航到路由:使用 RouterLink 進行宣告式導航,和使用 Router 進行程式化導航。閱讀 navigate-to-routes.md
  • 控制路由存取權限:實作 CanActivate、CanMatch 和其他守衛以確保安全。閱讀 route-guards.md
  • 資料解析器:在路由啟動前使用 ResolveFn 預先擷取資料。閱讀 data-resolvers.md
  • 路由器生命週期和事件:導航事件的時間順序和偵錯。閱讀 router-lifecycle.md
  • 渲染策略:CSR、SSG(預渲染)和具有水合作用的 SSR。閱讀 rendering-strategies.md
  • 路由轉場動畫:啟用和自訂 View Transitions API。閱讀 route-animations.md

如果您需要更深入的文件或更多上下文,請造訪官方 Angular Routing 指南。

樣式與動畫

在 Angular 中實作樣式和動畫時,請查閱以下參考資料:

  • 在 Angular 中使用 Tailwind CSS:將 Tailwind CSS 整合到 Angular 專案中。閱讀 tailwind-css.md
  • Angular 動畫:使用原生 CSS(建議)或傳統 DSL 來實現動態效果。閱讀 angular-animations.md
  • 元件樣式:元件樣式和封裝的最佳實踐。閱讀 component-styling.md

測試

在撰寫或更新測試時,請根據任務查閱以下參考資料:

  • 基礎知識:單元測試、非同步模式和 TestBed 的最佳實踐。閱讀 testing-fundamentals.md
  • 元件測試工具:用於穩健元件互動的標準模式。閱讀 component-harnesses.md
  • 路由器測試:使用 RouterTestingHarness 進行可靠的導航測試。閱讀 router-testing.md
  • 端到端 (E2E) 測試:使用 Cypress 或 Playwright 進行 E2E 測試的最佳實踐。閱讀 e2e-testing.md

工具

在使用 Angular 工具時,請查閱以下參考資料:

  • Angular CLI:建立應用程式、生成程式碼(元件、路由、服務)、提供服務和建置。閱讀 cli.md
  • Angular MCP 伺服器:可用的工具、配置和實驗性功能。閱讀 mcp.md

反模式

  • 使用 null 或 undefined 作為 signal form 欄位的初始值 — 應改用 ''、0 或 []
  • 在未先呼叫欄位的情況下存取表單欄位狀態標誌:form.field.valid() — 應使用 form.field().valid()
  • 在目標 Angular 版本支援 Signal Forms 時,對新表單使用較舊的表單 API
  • 在 [formField] 輸入上設定 min、max、value、disabled 或 readonly HTML 屬性 — 應改為將這些定義為 schema 規則
  • 在注入上下文之外呼叫 inject() — 必要時請使用 runInInjectionContext
  • 對應使用 computed() 的衍生狀態使用 effect()
  • 在巢狀 @for 迴圈中引用 $parent.$index — Angular 不支援 $parent;請改用 let outerIdx = $index

相關技能

  • tdd-workflow — 適用於 Angular 元件和服務的測試驅動開發工作流程
  • security-review — Web 應用程式的安全檢查清單,包含 Angular 特定的注意事項
  • frontend-patterns — 提供有關 React/Next.js 方法上下文的一般前端模式

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

api-connector-builder

Build a new API connector or provider by matching the target repo

相關技能