workflow-clean-code-angular
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<objective>
Guarantee that Angular code in the target scope meets the standard of a senior developer who crafted it by hand — clean, clear, no AI slop, proper architecture, correct signal patterns, and clear ViewModel separation.
</objective>
<philosophy>
This isn't a linter. Linters catch syntax. This skill catches **design decisions** — the kind of issues only a senior engineer spots during code review.
Three things that separate senior-crafted code from AI-generated code:
- Nothing unnecessary — no defensive checks for impossible scenarios, no abstractions with one consumer, no comments that restate the code
- Right responsibility in the right place — stores own data transformations, components coordinate UI, templates just bind
- Consistent patterns — every store follows the same anatomy, every component follows the same structure, no surprise conventions </philosophy>
<quick_start>
bash
/clean-code-angular feature/budget/ # Standard audit
/clean-code-angular -a --deep feature/ # Deep audit, auto mode
/clean-code-angular --quick core/ # Quick surface scan
/clean-code-angular --slop --vm feature/ # Focus: AI slop + ViewModel
/clean-code-angular diff main # Audit changes vs main
/clean-code-angular pending # Audit uncommitted changes</quick_start>
<parameters>
| Flag | Description |
|---|---|
| Auto mode — skip confirmations |
| Economy mode — no subagents, direct analysis only |
| Save — output reports to |
| Resume — continue from a previous run |
| Surface scan only (grep patterns, no semantic analysis) |
| Full depth: all domains including AI slop + ViewModel + cross-file |
| Force architecture analysis |
| Force signal patterns analysis |
| Force styling analysis |
| Force testing analysis |
| Force AI slop detection |
| Force ViewModel/DataModel analysis |
| Adversarial review — after team lead, a devil's advocate agent challenges every finding for false positives, missed issues, and severity inflation |
| Maximum depth: 15 specialists in 5 clusters, each with a cluster lead, plus grand tech lead and adversarial review. The nuclear option for critical code. |
Default depth (no flag): grep + targeted semantic analysis of key files.
enables all specialist domains.
</parameters>
<workflow>
```
SCAN ─────────────────► APPLY ─────────────► VERIFY
│ │ │
├─ Parse scope ├─ Load docs/refs ├─ Lint + type-check
├─ Launch specialists ├─ Apply fixes ├─ Run tests
│ (up to 10 agents) │ (parallel agents) ├─ Team lead final
├─ Team lead review ├─ Team lead │ craftsman review
├─ Adversarial review │ coherence check ├─ Adversarial final
│ (if --adv) └─ Track progress │ challenge (if --adv)
└─ Consolidated issues └─ Commit
```
</workflow>
--deep<agent_model>
<objective>
确保目标范围内的Angular代码达到资深开发人员手工编写的标准——整洁、清晰、无AI垃圾代码、架构合理、signal模式正确、ViewModel分离清晰。
</objective>
<philosophy>
这不是linter。Linter只会捕获语法问题。本工具可以捕获**设计决策**层面的问题——只有资深工程师在代码评审中才能发现的那类问题。
区分资深工程师编写的代码和AI生成代码的三个要点:
- 没有多余内容——不会为不可能发生的场景做防御性检查,没有只有一个使用者的抽象,没有重复描述代码的注释
- 权责分明——stores负责数据转换,组件协调UI,模板仅做绑定
- 模式统一——所有store遵循相同的结构,所有组件遵循相同的结构,没有突兀的约定 </philosophy>
<quick_start>
bash
/clean-code-angular feature/budget/ # Standard audit
/clean-code-angular -a --deep feature/ # Deep audit, auto mode
/clean-code-angular --quick core/ # Quick surface scan
/clean-code-angular --slop --vm feature/ # Focus: AI slop + ViewModel
/clean-code-angular diff main # Audit changes vs main
/clean-code-angular pending # Audit uncommitted changes</quick_start>
<parameters>
| Flag | 描述 |
|---|---|
| 自动模式——跳过确认步骤 |
| 经济模式——无子Agent,仅执行直接分析 |
| 保存——将报告输出到 |
| 恢复——从上一次运行的断点继续 |
| 仅表层扫描(grep模式匹配,无语义分析) |
| 全深度扫描:覆盖所有领域,包括AI垃圾代码、ViewModel、跨文件关联分析 |
| 强制开启架构分析 |
| 强制开启signal模式分析 |
| 强制开启样式分析 |
| 强制开启测试分析 |
| 强制开启AI垃圾代码检测 |
| 强制开启ViewModel/DataModel分析 |
| 对抗式评审——团队负责人审核完成后,由对抗Agent对所有发现进行校验,排查误报、遗漏问题和严重程度高估 |
| 最大深度扫描:5个集群共15名专业Agent,每个集群配备集群负责人,外加总技术负责人和对抗式评审,适用于核心代码的最高级别审计 |
默认深度(无参数):grep匹配 + 核心文件定向语义分析
参数开启所有专业领域分析
</parameters>
<workflow>
```
SCAN ─────────────────► APPLY ─────────────► VERIFY
│ │ │
├─ Parse scope ├─ Load docs/refs ├─ Lint + type-check
├─ Launch specialists ├─ Apply fixes ├─ Run tests
│ (up to 10 agents) │ (parallel agents) ├─ Team lead final
├─ Team lead review ├─ Team lead │ craftsman review
├─ Adversarial review │ coherence check ├─ Adversarial final
│ (if --adv) └─ Track progress │ challenge (if --adv)
└─ Consolidated issues └─ Commit
```
</workflow>
--deep<agent_model>
Agent Architecture
Agent架构
The skill scales agent count based on flags:
| Mode | Agents | Structure |
|---|---|---|
Economy ( | 0 | Direct tools only, no subagents |
| Standard | 3-10 + lead | Flat: specialists → team lead |
Deep ( | 10 + lead | All 10 domains → team lead |
Deep + Adv ( | 10 + lead + adv | All 10 domains → team lead → adversarial |
Ultra ( | 15 + 5 leads + grand lead + adv = 22 | 5 clusters → 5 cluster leads → grand tech lead → adversarial |
本工具会根据传入参数调整Agent数量:
| 模式 | Agent数量 | 结构 |
|---|---|---|
经济模式( | 0 | 仅使用直接工具,无任何子Agent |
| 标准模式 | 3-10 + 负责人 | 扁平结构:专业Agent → 团队负责人 |
深度模式( | 10 + 负责人 | 全10个领域Agent → 团队负责人 |
深度+对抗模式( | 10 + 负责人 + 对抗Agent | 全10个领域Agent → 团队负责人 → 对抗Agent |
极致模式( | 15 + 5集群负责人 + 总技术负责人 + 对抗Agent = 22 | 5个集群 → 5名集群负责人 → 总技术负责人 → 对抗Agent |
Standard/Deep Mode — Flat Architecture
标准/深度模式——扁平架构
Up to 10 domain-focused specialists launched in parallel. Count scales with scope size:
| Scope | Agents | Coverage |
|---|---|---|
| 1-4 files | 3 + lead | Architecture, Angular/Signals, TypeScript/Styling |
| 5-15 files | 5 + lead | + Store patterns, Component design |
| 16-30 files | 7 + lead | + Templates, AI slop |
| 31+ files | 10 + lead | All 10 domains |
最多10名专注不同领域的专业Agent并行启动,数量随扫描范围大小动态调整:
| 扫描范围 | Agent数量 | 覆盖领域 |
|---|---|---|
| 1-4个文件 | 3 + 负责人 | 架构、Angular/Signals、TypeScript/样式 |
| 5-15个文件 | 5 + 负责人 | 新增Store模式、组件设计 |
| 16-30个文件 | 7 + 负责人 | 新增模板、AI垃圾代码检测 |
| 31个以上文件 | 10 + 负责人 | 覆盖全部10个领域 |
The 10 Domains
10个分析领域
| # | Domain | Focus |
|---|---|---|
| 1 | Architecture & Dependencies | Layer violations, cross-feature imports, dependency direction |
| 2 | Signals & Reactivity | |
| 3 | Store Patterns | 6-section anatomy, cache-first, optimistic updates, resource usage |
| 4 | Component Design | OnPush, responsibility, size, |
| 5 | Template Quality | Control flow, expression complexity, wrapper bloat, accessibility |
| 6 | TypeScript Quality | |
| 7 | Styling | |
| 8 | AI Slop | Over-engineering, unnecessary comments, defensive theater, verbose naming |
| 9 | ViewModel & Data Flow | DataModel vs ViewModel, transformation location, duplicate derivations |
| 10 | Security, Performance & Code Health | XSS, workarounds/hacks, design smells, |
Testing quality is checked when or or is enabled. The testing specialist reads files in scope and evaluates against .
--testing--deep--ultra.spec.tsreferences/testing-patterns.md| # | 领域 | 聚焦点 |
|---|---|---|
| 1 | 架构与依赖 | 层级违反、跨功能模块导入、依赖方向错误 |
| 2 | Signals与响应式 | |
| 3 | Store模式 | 6段式结构、缓存优先、乐观更新、资源使用 |
| 4 | 组件设计 | OnPush、权责划分、大小、 |
| 5 | 模板质量 | 控制流、表达式复杂度、冗余包装、可访问性 |
| 6 | TypeScript质量 | |
| 7 | 样式 | |
| 8 | AI垃圾代码 | 过度设计、无意义注释、无效防御逻辑、冗长命名 |
| 9 | ViewModel与数据流 | DataModel与ViewModel区分、转换逻辑位置、重复派生 |
| 10 | 安全、性能与代码健康 | XSS、临时补丁、设计异味、 |
开启 、 或 参数时会额外检查测试质量,测试领域Agent会读取范围内的 文件,对照 进行评估。
--testing--deep--ultra.spec.tsreferences/testing-patterns.mdUltra Mode — Multi-Tier Cluster Architecture
极致模式——多层集群架构
15 specialists organized in 5 clusters, each with a dedicated cluster lead. Each specialist loads exactly the reference files it needs — no bloat.
Cluster 1: Architecture → Architecture Lead
| Agent | Focus | Loads |
|---|---|---|
| 1a | Layer violations, cross-feature imports | |
| 1b | DI patterns, functional interceptors, providers | |
| 1c | Lazy loading, routing, | |
Cluster 2: Signals & State → Reactivity Lead
| Agent | Focus | Loads |
|---|---|---|
| 2a | Signal patterns, computed, effect, afterRenderEffect | |
| 2b | Store anatomy, mutations, resource API | |
| 2c | RxJS valid vs anti-pattern, Observable/Signal bridge | |
Cluster 3: Code Quality → Quality Lead
| Agent | Focus | Loads |
|---|---|---|
| 3a | TypeScript, types, modern APIs (toSorted, structuredClone) | |
| 3b | AI slop detection (all 9 categories) | |
| 3c | Error handling, catch typing, resource error state | |
Cluster 4: UI & Templates → Frontend Lead
| Agent | Focus | Loads |
|---|---|---|
| 4a | Control flow, @defer, template expressions | |
| 4b | Styling, accessibility, NgOptimizedImage | |
| 4c | Pipes, ViewModel separation, formatting | |
Cluster 5: Testing & Security → Security Lead
| Agent | Focus | Loads |
|---|---|---|
| 5a | Test quality, harnesses, coverage | |
| 5b | Security, workarounds, zoneless violations | |
| 5c | Signal Forms, API validation, forms patterns | |
Flow:
15 specialists (parallel) → 5 cluster leads (parallel) → Grand Tech Lead → Adversarial15名专业Agent分为5个集群,每个集群配备专属负责人,每个Agent仅加载其需要的参考文件,无冗余加载。
集群1:架构 → 架构负责人
| Agent | 聚焦点 | 加载文件 |
|---|---|---|
| 1a | 层级违反、跨功能模块导入 | |
| 1b | DI模式、函数式拦截器、providers | |
| 1c | 懒加载、路由、 | |
集群2:Signals与状态 → 响应式负责人
| Agent | 聚焦点 | 加载文件 |
|---|---|---|
| 2a | Signal模式、computed、effect、afterRenderEffect | |
| 2b | Store结构、变更、资源API | |
| 2c | RxJS合法/反模式、Observable/Signal桥接 | |
集群3:代码质量 → 质量负责人
| Agent | 聚焦点 | 加载文件 |
|---|---|---|
| 3a | TypeScript、类型、现代API(toSorted、structuredClone) | |
| 3b | AI垃圾代码检测(全9个类别) | |
| 3c | 错误处理、catch类型、资源错误状态 | |
集群4:UI与模板 → 前端负责人
| Agent | 聚焦点 | 加载文件 |
|---|---|---|
| 4a | 控制流、@defer、模板表达式 | |
| 4b | 样式、可访问性、NgOptimizedImage | |
| 4c | 管道、ViewModel分离、格式化 | |
集群5:测试与安全 → 安全负责人
| Agent | 聚焦点 | 加载文件 |
|---|---|---|
| 5a | 测试质量、harness、覆盖率 | |
| 5b | 安全、临时补丁、无zone模式违反 | |
| 5c | Signal Forms、API校验、表单模式 | |
流转流程:
15 specialists (parallel) → 5 cluster leads (parallel) → Grand Tech Lead → AdversarialTeam Lead (Standard/Deep)
团队负责人(标准/深度模式)
Launched after specialists complete. A senior Angular architect who:
- Merges all specialist reports into one deduplicated list
- Removes false positives by reading the actual code
- Resolves contradictions between specialists
- Adds cross-cutting observations no single specialist caught
- Prioritizes the final issue list
- Verifies fix coherence in step-02
- Does final craftsman review in step-03
在所有专业Agent完成工作后启动,是资深Angular架构师,负责:
- 将所有专业Agent的报告合并为去重的问题列表
- 通过阅读实际代码移除误报问题
- 解决不同专业Agent之间的结论矛盾
- 补充单个专业Agent无法发现的跨领域问题
- 对最终问题列表进行优先级排序
- 在第二步校验修复逻辑的一致性
- 在第三步做最终工匠级评审
Cluster Leads (Ultra)
集群负责人(极致模式)
Each cluster lead receives ONLY its 3 specialists' reports. They:
- Deduplicate within their domain
- Resolve contradictions between their specialists
- Add domain-specific cross-cutting observations
- Output a focused domain report (max 10 issues per cluster)
每个集群负责人仅接收其管辖的3名专业Agent的报告,负责:
- 对所属领域内的问题进行去重
- 解决所属领域内专业Agent的结论矛盾
- 补充领域内的跨Agent观察结论
- 输出聚焦的领域报告(每个集群最多10个问题)
Grand Tech Lead (Ultra)
总技术负责人(极致模式)
Receives all 5 cluster lead reports. A principal Angular architect who:
- Merges all cluster reports into one unified list
- Resolves cross-cluster contradictions (e.g., Architecture says "move to core" but Quality says "inline it")
- Identifies systemic patterns across clusters (e.g., "every file has the same DI problem")
- Prioritizes by business impact, not just technical severity
- Caps at 30 issues, notes total if more
- Adds a "systemic diagnosis" section: what's the ROOT CAUSE behind the pattern of issues?
接收全部5个集群负责人的报告,是首席Angular架构师,负责:
- 将所有集群报告合并为统一的问题列表
- 解决跨集群的结论矛盾(例如架构组建议「移动到core模块」但质量组建议「内联」)
- 识别跨集群的系统性问题(例如「每个文件都存在相同的DI问题」)
- 按业务影响而非仅技术严重程度排序优先级
- 最多输出30个问题,超过时标注总问题数
- 增加「系统性诊断」章节:说明问题模式背后的根本原因
Adversarial Reviewer (--adv or --ultra)
对抗评审员(开启--adv或--ultra时)
Launched after the team/grand lead. A skeptical senior engineer who:
- Challenges each finding: "Is this really wrong? Could there be a valid architectural reason?"
- Hunts false positives: reads the actual code for each flagged issue and checks if context was missed
- Hunts missed issues: reads ALL files in scope looking for issues that ALL specialists + leads missed
- Questions severity: "Is this really Critical or just Important? Would a production user notice?"
- Checks RxJS false flags: verifies that valid RxJS patterns aren't flagged as signal anti-patterns
- Checks Angular version assumptions: verifies recommendations match Angular 21+
- Checks against project profile: verifies that no finding contradicts the project's documented conventions from {project_profile}
Output: a correction table listing upgrades, downgrades, removals, and additions to the lead's findings.
</agent_model>
<state_variables>
| Variable | Type | Description |
|---|---|---|
| string | Scope to analyze |
| string | Kebab-case identifier |
| boolean | Skip confirmations |
| boolean | No subagents |
| boolean | Save reports |
| quick / standard / deep | Analysis depth |
| boolean | Per-domain force flags |
| string[] | Files in scope |
| array | Consolidated issue list |
| string | Path to angular.json |
| number | Specialists to launch |
| boolean | Run adversarial review after team lead |
| boolean | Full 22-agent multi-tier architecture |
| object | Detected project conventions, libraries, and architecture decisions — used to filter false positives |
</state_variables>
<reference_files>
| File | When Loaded |
|---|---|
| Always (scanning checklist) |
| Always (correct patterns) |
| Always (official Angular conventions) |
| Architecture issues or |
| Deep mode, |
| Deep mode, |
| Testing issues or |
</reference_files>
<entry_point>
Load
steps/step-01-scan.md</entry_point>
<step_files>
| Step | File | Purpose |
|---|---|---|
| 01 | | Parse scope, launch specialists, team lead consolidation |
| 02 | | Load docs, apply fixes, team lead coherence check |
| 03 | | Quality gate, craftsman review, commit |
</step_files>
<execution_rules>
- Discover project context BEFORE scanning — read CLAUDE.md, package.json, angular.json, eslint config to build {project_profile}
- Filter ALL findings through {project_profile} — never flag patterns that match documented project conventions
- Load one step at a time
- Scale agent count to scope size (economy mode = 0 agents, direct tools only)
- Use the Grep tool for pattern detection (not bash grep)
- Scope-aware: only touch files within the specified scope
- Every finding: reference required
file:line - Every fix: source citation required
- Team lead reviews after scan AND after apply </execution_rules>
<success_criteria>
After this workflow, the scoped code reads as if a senior Angular developer wrote it by hand:
- Zero architecture violations
- Modern signal patterns throughout
- Stores follow 6-section anatomy with proper ViewModel selectors
- No AI slop — no unnecessary comments, abstractions, or defensive code
- Clean ViewModel separation — stores transform, components bind, templates stay simple
- Consistent patterns across all files in scope
- Quality check passes (lint + type-check + format)
- Tests pass
- If --adv: adversarial review found no missed issues or false positives </success_criteria>
在团队/总技术负责人完成工作后启动,是持怀疑态度的资深工程师,负责:
- 挑战每个发现:「这真的是问题吗?有没有合理的架构原因?」
- 排查误报:阅读每个标记问题的实际代码,检查是否遗漏了上下文信息
- 排查遗漏问题:阅读范围内所有文件,寻找所有专业Agent和负责人都没发现的问题
- 质疑严重程度:「这真的是严重问题还是只是建议?生产用户会感知到吗?」
- 检查RxJS误标记:确认合法的RxJS模式没有被标记为signal反模式
- 检查Angular版本假设:确认建议适配Angular 21+版本
- 对照项目配置检查:确认没有发现与 {project_profile} 中记录的项目约定冲突的问题
输出:修正表格,列出对负责人结论的升级、降级、移除和新增调整。
</agent_model>
<state_variables>
| 变量 | 类型 | 描述 |
|---|---|---|
| string | 待分析的范围 |
| string | 短横线分隔的任务标识 |
| boolean | 跳过确认步骤 |
| boolean | 无任何子Agent |
| boolean | 保存报告 |
| quick / standard / deep | 分析深度 |
| boolean | 各领域强制开启标记 |
| string[] | 范围内的文件列表 |
| array | 合并后的问题列表 |
| string | angular.json的路径 |
| number | 要启动的专业Agent数量 |
| boolean | 团队负责人评审完成后运行对抗评审 |
| boolean | 开启完整22Agent多层架构 |
| object | 识别到的项目约定、依赖库和架构决策,用于过滤误报 |
</state_variables>
<reference_files>
| 文件 | 加载时机 |
|---|---|
| 始终加载(扫描检查清单) |
| 始终加载(正确模式参考) |
| 始终加载(Angular官方约定) |
| 架构问题或开启 |
| 深度模式或开启 |
| 深度模式或开启 |
| 测试问题或开启 |
</reference_files>
<entry_point>
加载
steps/step-01-scan.md</entry_point>
<step_files>
| 步骤 | 文件 | 用途 |
|---|---|---|
| 01 | | 解析范围、启动专业Agent、团队负责人合并结果 |
| 02 | | 加载文档、应用修复、团队负责人一致性检查 |
| 03 | | 质量门禁、工匠级评审、提交 |
</step_files>
<execution_rules>
- 扫描前先获取项目上下文——读取CLAUDE.md、package.json、angular.json、eslint配置构建 {project_profile}
- 所有发现都要经过 {project_profile} 过滤——永远不要标记符合项目文档约定的模式为问题
- 一次只加载一个步骤
- Agent数量随扫描范围大小动态调整(经济模式=0个Agent,仅使用直接工具)
- 使用Grep工具做模式检测(而非bash grep)
- 范围感知:仅操作指定范围内的文件
- 每个发现都必须提供 引用
文件:行号 - 每个修复都必须提供来源引用
- 扫描完成和修复完成后都需要团队负责人评审 </execution_rules>
<success_criteria>
工作流执行完成后,范围内的代码读起来就像资深Angular开发人员手工编写的一样:
- 零架构违反
- 全程使用现代signal模式
- Stores遵循6段式结构,搭配正确的ViewModel选择器
- 无AI垃圾代码——没有多余注释、抽象或防御代码
- 清晰的ViewModel分离——stores做转换,组件做绑定,模板保持简洁
- 范围内所有文件模式统一
- 质量检查通过(lint + 类型检查 + 格式化)
- 测试通过
- 如果开启--adv:对抗评审未发现遗漏问题或误报 </success_criteria>