Communitygithub.com

GAN风格工作流工具

受GAN启发的生成器-评估器多智能体工作流,用于自主构建高质量的应用程序。基于Anthropic

GAN风格工作流工具 是什么?

该技能实现了受GAN(生成对抗网络)启发的多智能体工作流,通过将生成与评估分离,形成一个对抗性反馈循环,从而驱动应用程序质量远超单个智能体。它包含三个角色:规划者将简要提示扩展为完整的产品规格;生成者按计划迭代实现功能;评估者利用Playwright MCP与真实运行的应用进行交互,从设计质量、原创性、工艺和功能四个维度进行严格评分。该工具适用于需要高视觉质量和完整功能的全栈项目,投资约50-200美元可获得接近生产级输出。它支持命令行、Shell脚本或手动调用Claude Code,并允许通过环境变量灵活配置模型、迭代次数和评分阈值。需要注意的是,该技能相比单智能体将花费约12-18倍的时间和14-22倍的成本,适合对质量有严格要求而非追求速度或低成本的场景。

兼容平台✓Claude Code✓Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/gan-style-harness

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

GAN 风格工作流工具 (GAN-Style Harness Skill)

灵感来源于 Anthropic's Harness Design for Long-Running Application Development (2026年3月24日)

一个多智能体工作流,将生成与评估分离,形成一个对抗性反馈循环,其驱动质量提升远超过单个智能体所能达到的水平。

核心洞察

当要求评估自己的工作时,智能体是病态的乐观主义者——它们会夸奖平庸的输出,并说服自己忽视真正的问题。然而,设计一个独立的评估者并使其变得极其严格,远比教会生成者自我批评要容易得多。

这与 GAN(生成对抗网络)的动态机制相同:生成者负责产出,评估者负责批评,这种反馈驱动着下一轮迭代。

何时使用

  • 根据一行提示构建完整的应用程序
  • 需要高视觉质量的前端设计任务
  • 需要工作功能而不仅仅是代码的全栈项目
  • 任何“AI 拼凑品”美学不可接受的任务
  • 您愿意投入 50-200 美元以获得生产质量输出的项目

何时不使用

  • 快速单文件修复(使用标准 claude -p)
  • 预算紧张的任务(低于 10 美元)
  • 简单重构(改用 de-sloppify 模式)
  • 已有良好规范且附带测试的任务(使用 TDD 工作流)

架构

                    ┌─────────────┐
                    │   PLANNER   │
                    │   (规划者)   │
                    │  (Sonnet)   │
                    └──────┬──────┘
                           │ 产品规格
                           │ (功能、冲刺、设计方向)
                           ▼
              ┌────────────────────────┐
              │                        │
              │   GENERATOR-EVALUATOR  │
              │     生成器-评估器       │
              │     反馈循环           │
              │                        │
              │  ┌──────────┐          │
              │  │GENERATOR │--构建--> │──┐
              │  │ (生成者)  │          │  │
              │  │ (Sonnet) │          │  │
              │  └────▲─────┘          │  │
              │       │                │  │ 实时应用
              │   反馈                 │  │
              │       │                │  │
              │  ┌────┴─────┐          │  │
              │  │EVALUATOR │<-测试--- │──┘
              │  │ (评估者)  │          │
              │  │ (Sonnet) │          │
              │  │+Playwright│         │
              │  └──────────┘          │
              │                        │
              │   5-15 次迭代          │
              └────────────────────────┘

三个智能体

1. 规划者 (Planner Agent)

角色: 产品经理——将一个简短的提示扩展为完整的产品规格。

关键行为:

  • 接收一行提示,生成包含 16 个功能、多个冲刺的规格文档
  • 定义用户故事、技术需求和视觉设计方向
  • 故意雄心勃勃——保守的规划会导致平庸的结果
  • 生成评估者后续将使用的评估标准

模型: 默认使用 Sonnet;通过设置 GAN_PLANNER_MODEL=opus 提升以进行更深入的规格扩展

2. 生成者 (Generator Agent)

角色: 开发者——根据规格实现功能。

关键行为:

  • 按结构化冲刺工作(使用更新模型时也可连续模式)
  • 在编写代码前与评估者协商“冲刺合同”
  • 使用全栈工具:React、FastAPI/Express、数据库、CSS
  • 管理 git 以进行迭代间的版本控制
  • 阅读评估者反馈并在下一次迭代中融入

模型: 默认使用 Sonnet;通过设置 GAN_GENERATOR_MODEL=opus 提升以获得最大编码能力

3. 评估者 (Evaluator Agent)

角色: 质量工程师——测试实时运行的应用程序,而不仅仅是代码。

关键行为:

  • 使用 Playwright MCP 与实时应用交互
  • 点击功能、填写表单、测试 API 端点
  • 根据四个标准进行评分(可配置):
    1. 设计质量 — 看起来是否像一个协调的整体?
    2. 原创性 — 是否做出了自定义决策而非使用模板/AI 模式?
    3. 工艺 — 字体、间距、动画、微交互?
    4. 功能性 — 所有功能是否实际可用?
  • 返回带有分数和具体问题的结构化反馈
  • 被设计为极其严格——绝不表扬平庸的工作

模型: 默认使用 Sonnet;通过设置 GAN_EVALUATOR_MODEL=opus 提升以获得更强的判断力和工具使用能力

评估标准

默认的四个标准,每个评分 1-10:

## 评估细则

### 设计质量 (权重: 0.3)
- 1-3: 通用、模板化、“AI 拼凑品”美学
- 4-6: 合格但不突出,遵循常规
- 7-8: 独特、连贯的视觉识别
- 9-10: 可以冒充专业设计师的作品

### 原创性 (权重: 0.2)
- 1-3: 默认颜色、库存布局、没有个性
- 4-6: 有一些自定义选择,大部分是标准模式
- 7-8: 清晰的创意愿景,独特的方法
- 9-10: 令人惊讶、愉悦、真正新颖

### 工艺 (权重: 0.3)
- 1-3: 布局损坏、缺少状态、无动画
- 4-6: 能工作但感觉粗糙,间距不一致
- 7-8: 精致、流畅的过渡、响应式
- 9-10: 像素完美、令人愉悦的微交互

### 功能性 (权重: 0.2)
- 1-3: 核心功能损坏或缺失
- 4-6: 快乐路径可用,边缘情况失败
- 7-8: 所有功能都工作,错误处理良好
- 9-10: 无懈可击,处理每个边缘情况

评分

  • 加权得分 = 总和(标准得分 * 权重)
  • 通过阈值 = 7.0(可配置)
  • 最大迭代次数 = 15(可配置,通常 5-15 次足够)

使用方法

通过命令

# 完整三智能体工作流
/project:gan-build "Build a project management app with Kanban boards, team collaboration, and dark mode"

# 自定义配置
/project:gan-build "Build a recipe sharing platform" --max-iterations 10 --pass-threshold 7.5

# 前端设计模式(仅生成者+评估者,无规划者)
/project:gan-design "Create a landing page for a crypto portfolio tracker"

通过 Shell 脚本

# 基础用法
./scripts/gan-harness.sh "Build a music streaming dashboard"

# 带选项
GAN_MAX_ITERATIONS=10 \
GAN_PASS_THRESHOLD=7.5 \
GAN_EVAL_CRITERIA="functionality,performance,security" \
./scripts/gan-harness.sh "Build a REST API for task management"

通过 Claude Code(手动)

# 步骤 1: 规划
claude -p --model sonnet "You are a Product Planner. Read PLANNER_PROMPT.md. Expand this brief into a full product spec: 'Build a Kanban board app'. Write spec to spec.md"

# 步骤 2: 生成(迭代 1)
claude -p --model sonnet "You are a Generator. Read spec.md. Implement Sprint 1. Start the dev server on port 3000."

# 步骤 3: 评估(迭代 1)
claude -p --model sonnet --allowedTools "Read,Bash,mcp__playwright__*" "You are an Evaluator. Read EVALUATOR_PROMPT.md. Test the live app at http://localhost:3000. Score against the rubric. Write feedback to feedback-001.md"

# 步骤 4: 生成(迭代 2 — 读取反馈)
claude -p --model sonnet "You are a Generator. Read spec.md and feedback-001.md. Address all issues. Improve the scores."

# 重复步骤 3-4 直到达到通过阈值

随模型能力演进

随着模型改进,工作流应简化。遵循 Anthropic 的演进:

阶段 1 — 较弱模型(Sonnet 级)

  • 需要完整的冲刺分解
  • 在冲刺之间重置上下文(避免上下文焦虑)
  • 最少 2 个智能体:初始化者 + 编码智能体
  • 大量脚手架补偿模型限制

阶段 2 — 有能力的模型(Opus 4.5 级)

  • 完整的 3 智能体工作流:规划者 + 生成者 + 评估者
  • 在每个实现阶段前进行冲刺合同
  • 复杂应用分解为 10 个冲刺
  • 上下文重置仍然有用,但不再关键

阶段 3 — 前沿模型(Opus 4.6 级)

  • 简化工作流:单次规划传递,连续生成
  • 评估减少为单次最终传递(模型更智能)
  • 无需冲刺结构
  • 自动压缩处理上下文增长

关键原则: 工作流的每个组件都编码了对模型无法单独完成之事的假设。当模型改进时,重新测试这些假设。去掉不再需要的部分。

配置

环境变量

变量默认值描述
GAN_MAX_ITERATIONS15生成者-评估者最大循环次数
GAN_PASS_THRESHOLD7.0通过所需的加权得分 (1-10)
GAN_PLANNER_MODELsonnet规划智能体的模型
GAN_GENERATOR_MODELsonnet生成智能体的模型
GAN_EVALUATOR_MODELsonnet评估智能体的模型
GAN_EVAL_CRITERIAdesign,originality,craft,functionality逗号分隔的评估标准
GAN_DEV_SERVER_PORT3000实时应用的端口
GAN_DEV_SERVER_CMDnpm run dev启动开发服务器的命令
GAN_PROJECT_DIR.项目工作目录
GAN_SKIP_PLANNERfalse跳过规划者,直接使用规格
GAN_EVAL_MODEplaywrightplaywright、screenshot 或 code-only

评估模式

模式工具最适合
playwright浏览器 MCP + 实时交互带 UI 的全栈应用
screenshot截图 + 视觉分析静态网站、仅设计类应用
code-only测试 + 代码检查 + 构建API、库、CLI 工具

反模式

  1. 评估者过于宽容 — 如果评估者在第一次迭代中通过了所有内容,那么您的评分细则太宽松了。收紧评分标准,并为常见的 AI 模式添加明确的惩罚。

  2. 生成者忽略反馈 — 确保反馈以文件形式传递,而不是内联。生成者应在每次迭代开始时读取 feedback-NNN.md。

  3. 无限循环 — 始终设置 GAN_MAX_ITERATIONS。如果生成者在 3 次迭代后无法突破得分平台,应停止并标记为人工审查。

  4. 评估者测试表面化 — 评估者必须使用 Playwright 与 实时应用交互,而不仅仅是截图。点击按钮、填写表单、测试错误状态。

  5. 评估者表扬自己的修复 — 绝不让评估者建议修复后又评估这些修复。评估者只负责批评;生成者负责修复。

  6. 上下文耗尽 — 对于长时间会话,使用 Claude Agent SDK 的自动压缩功能或在主要阶段之间重置上下文。

结果:预期效果

基于 Anthropic 公布的结果:

指标单智能体GAN 工作流提升幅度
时间20 分钟4-6 小时长 12-18 倍
成本9 美元125-200 美元多 14-22 倍
质量勉强可用接近生产级质变
核心功能损坏全部可用不适用
设计通用 AI 拼凑品独特、精致不适用

权衡是显而易见的: 约多花 20 倍的时间和成本,换来质的飞跃。这适用于质量至上的项目。

参考资料

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/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

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.

相关技能