api-workshop
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAPI Workshop
API研讨会
A debate-driven multi-agent workshop for designing and reviewing APIs. Five specialized
agents propose designs and challenge each other to produce a well-reasoned API specification.
这是一个用于API设计与评审的辩论式多Agent研讨会。五个专业Agent会提出设计方案并相互质疑,最终产出一份论证充分的API规范。
Prerequisites
前置条件
Agents will need access to API design patterns and standards. The file
provides OpenAPI templates, design principles, and debate prompts.
REFERENCE.mdAgent需要能够获取API设计模式与标准。文件提供了OpenAPI模板、设计原则以及辩论提示语。
REFERENCE.mdInputs
输入信息
The user provides:
- API Description (required) — What the API should do, or URL to existing spec
- Context (optional) — Business domain, constraints, existing systems
- Focus areas (optional) — Which aspects matter most (see Agent Roster below)
- Format preference (optional) — OpenAPI 3.x, GraphQL schema, AsyncAPI
If the user provides a URL to an existing spec, agents will review it rather than
design from scratch.
用户需要提供:
- API描述(必填)—— API需实现的功能,或现有规范的URL
- 上下文信息(可选)—— 业务领域、约束条件、现有系统情况
- 重点关注领域(可选)—— 哪些方面最为重要(参见下方Agent角色列表)
- 格式偏好(可选)—— OpenAPI 3.x、GraphQL schema、AsyncAPI
如果用户提供现有规范的URL,Agent会直接评审该规范,而非从零开始设计。
Agent Roster
Agent角色列表
Each agent brings a specialized perspective and debates with others:
| # | Agent | Focus | Challenges |
|---|---|---|---|
| 1 | API Designer | Consumer UX, discoverability, naming | "Is this intuitive for developers?" |
| 2 | Domain Modeler | Correct modeling, consistency, DDD | "Does this match the domain?" |
| 3 | Security Auditor | Auth/authz, data exposure, OWASP | "What are the security risks?" |
| 4 | Performance Analyst | Efficiency, caching, over/under-fetching | "Will this scale?" |
| 5 | Tech Lead | Standards compliance, versioning, docs | "Does this follow best practices?" |
每个Agent都具备专业视角,并会与其他Agent展开辩论:
| # | Agent | 关注重点 | 质疑方向 |
|---|---|---|---|
| 1 | API Designer | 用户体验、可发现性、命名规范 | "这对开发者来说是否直观?" |
| 2 | Domain Modeler | 建模准确性、一致性、领域驱动设计(DDD) | "这是否与业务领域匹配?" |
| 3 | Security Auditor | 认证/授权、数据暴露、OWASP标准 | "存在哪些安全风险?" |
| 4 | Performance Analyst | 效率、缓存机制、数据过度/不足获取 | "该API能否横向扩展?" |
| 5 | Tech Lead | 标准合规性、版本控制、文档 | "这是否遵循最佳实践?" |
Workflow
工作流程
Phase 1: Context Gathering (Main Agent)
阶段1:上下文收集(主Agent)
Before spawning the workshop agents:
- If given a description: Extract requirements, constraints, and success criteria
- If given a URL: Fetch the existing API spec and summarize it
- Identify domain entities: List the core resources/types involved
- Clarify open questions: Ask user if anything is ambiguous
- Create initial context document:
workspace/api-context.md
在启动研讨会Agent之前:
- 若提供功能描述:提取需求、约束条件与成功标准
- 若提供URL:获取现有API规范并生成摘要
- 识别领域实体:列出涉及的核心资源/类型
- 澄清模糊问题:询问用户是否存在不明确的内容
- 创建初始上下文文档:
workspace/api-context.md
Phase 2: Initial Proposals (Sub-agents 1-5)
阶段2:初始方案提议(子Agent 1-5)
Spawn all five agents in parallel. Each receives:
- The context document from Phase 1
- Their agent instructions (from )
agents/*.md - The API design reference ()
REFERENCE.md
Each agent independently:
- Proposes an initial design approach
- Creates example endpoint/schema definitions
- Writes their rationale and concerns
- Saves to
workspace/proposals/<agent-name>.md
并行启动所有五个Agent。每个Agent会收到:
- 阶段1生成的上下文文档
- 各自的Agent指令(来自)
agents/*.md - API设计参考文档()
REFERENCE.md
每个Agent独立完成以下工作:
- 提出初始设计思路
- 创建示例端点/ schema定义
- 撰写设计理由与关注点
- 保存至
workspace/proposals/<agent-name>.md
Phase 3: Cross-Examination (Main Agent Orchestrates)
阶段3:交叉质询(主Agent统筹)
For each significant design decision, run a mini-debate:
-
API Style (REST vs GraphQL vs RPC)
- API Designer proposes based on UX
- Performance Analyst challenges based on query patterns
- Tech Lead weighs standardization concerns
-
Authentication Strategy (OAuth2, API keys, JWT)
- Security Auditor proposes approach
- API Designer challenges if it adds friction
- Tech Lead validates against standards
-
Versioning Strategy (URI, header, content negotiation)
- Tech Lead proposes approach
- API Designer challenges impact on consumers
- Domain Modeler validates semantic compatibility
-
Resource Design (granularity, relationships, operations)
- Domain Modeler proposes structure
- Performance Analyst challenges N+1 issues
- API Designer validates developer experience
-
Error Handling (status codes, error formats, problem details)
- Security Auditor proposes secure defaults
- API Designer ensures clarity for consumers
- Tech Lead validates RFC 7807 compliance
For each debate:
- Present the question and stakes
- Let 2-3 agents argue their positions
- Synthesize the decision with rationale
- Document trade-offs considered
针对每个重要设计决策,开展小型辩论:
-
API风格(REST vs GraphQL vs RPC)
- API Designer基于用户体验提出方案
- Performance Analyst基于查询模式提出质疑
- Tech Lead考量标准化相关问题
-
认证策略(OAuth2、API keys、JWT)
- Security Auditor提出方案
- API Designer质疑是否会增加使用门槛
- Tech Lead验证是否符合标准
-
版本控制策略(URI、请求头、内容协商)
- Tech Lead提出方案
- API Designer质疑对用户的影响
- Domain Modeler验证语义兼容性
-
资源设计(粒度、关联关系、操作)
- Domain Modeler提出结构方案
- Performance Analyst质疑N+1查询问题
- API Designer验证开发者体验
-
错误处理(状态码、错误格式、问题详情)
- Security Auditor提出安全默认方案
- API Designer确保对用户清晰易懂
- Tech Lead验证是否符合RFC 7807标准
针对每场辩论:
- 提出议题与影响
- 让2-3个Agent阐述各自立场
- 综合决策并说明理由
- 记录已考虑的权衡因素
Phase 4: Synthesis (Main Agent)
阶段4:方案整合(主Agent)
After all debates complete:
- Reconcile proposals: Merge agent input into coherent design
- Resolve conflicts: Make final calls on contested decisions
- Document rationale: Explain why each choice was made
- Identify risks: Note what could go wrong and mitigations
- Generate specification: Create complete API spec in requested format
所有辩论完成后:
- 协调方案:将各Agent的输入整合为连贯的设计
- 解决冲突:对有争议的决策做出最终判断
- 记录设计理由:解释每个选择的依据
- 识别风险:标注可能出现的问题与缓解措施
- 生成规范文档:按照用户要求的格式创建完整的API规范
Phase 5: Output
阶段5:输出成果
Generate the final deliverable following the template in :
REFERENCE.md- Executive Summary: High-level design decisions and rationale
- Architecture: API style, auth, versioning, error handling
- Specification: Complete OpenAPI/GraphQL schema
- Design Rationale: Why each major decision was made
- Trade-offs: What was considered and rejected
- Implementation Notes: Tips for backend developers
- Client Examples: Sample requests/responses in multiple languages
Save to and present to the user.
workspace/api-specification.md根据中的模板生成最终交付物:
REFERENCE.md- 执行摘要:高层设计决策与理由
- 架构说明:API风格、认证、版本控制、错误处理
- 规范文档:完整的OpenAPI/GraphQL schema
- 设计理由:每个重大决策的依据
- 权衡因素:已考虑并否决的方案
- 实现提示:给后端开发者的建议
- 客户端示例:多语言的请求/响应示例
保存至并提交给用户。
workspace/api-specification.mdDebate Topics
辩论议题
The workshop should address these key decisions:
研讨会需要解决以下关键决策:
API Style
API风格
- REST: Resource-oriented, HTTP semantics, wide tooling
- GraphQL: Flexible queries, type-safe, learning curve
- RPC: Simple, efficient, less discoverable
- REST:面向资源、HTTP语义、工具生态丰富
- GraphQL:查询灵活、类型安全、学习曲线较陡
- RPC:简单直接、效率高、可发现性差
Versioning
版本控制
- URI versioning: (explicit, breaks caching)
/v1/users - Header versioning: (clean URIs, harder to test)
Accept: application/vnd.api+json;version=1 - Content negotiation: Media types control breaking changes
- URI版本控制:(直观明确,破坏缓存)
/v1/users - 请求头版本控制:(URI简洁,测试难度高)
Accept: application/vnd.api+json;version=1 - 内容协商:通过媒体类型控制破坏性变更
Authentication
认证方式
- OAuth2: Standard, complex setup, great for delegated auth
- API keys: Simple, less secure, good for server-to-server
- JWT: Stateless, revocation challenges, flexible claims
- OAuth2:标准化、配置复杂、适用于委托授权场景
- API keys:简单易用、安全性较低、适用于服务器间通信
- JWT:无状态、吊销难度大、声明灵活
Pagination
分页机制
- Offset/limit: Simple, inconsistent under writes
- Cursor-based: Consistent, opaque, harder to jump to page N
- Keyset: Efficient, requires indexed sort key
- 偏移/限制:简单、数据写入时结果不一致
- 基于游标:结果一致、游标不透明、难以直接跳转到第N页
- 基于键集:高效、需要排序键索引
Error Handling
错误处理
- Problem Details (RFC 7807): Structured, extensible, standard
- Custom format: Tailored to domain, non-standard
- HTTP status only: Simple, lacks detail
- 问题详情(RFC 7807):结构化、可扩展、标准化
- 自定义格式:贴合业务领域、非标准化
- 仅HTTP状态码:简单、缺乏详细信息
Output Structure
输出目录结构
workspace/
├── api-context.md # Phase 1 context gathering
├── proposals/
│ ├── api-designer.md
│ ├── domain-modeler.md
│ ├── security-auditor.md
│ ├── performance-analyst.md
│ └── tech-lead.md
├── debates/
│ ├── api-style-debate.md
│ ├── auth-strategy-debate.md
│ ├── versioning-debate.md
│ ├── resource-design-debate.md
│ └── error-handling-debate.md
└── api-specification.md # Final deliverableworkspace/
├── api-context.md # 阶段1:上下文收集文档
├── proposals/
│ ├── api-designer.md
│ ├── domain-modeler.md
│ ├── security-auditor.md
│ ├── performance-analyst.md
│ └── tech-lead.md
├── debates/
│ ├── api-style-debate.md
│ ├── auth-strategy-debate.md
│ ├── versioning-debate.md
│ ├── resource-design-debate.md
│ └── error-handling-debate.md
└── api-specification.md # 最终交付物Coordinator Responsibilities
统筹Agent职责
- Gather context and clarify requirements with user
- Spawn proposal agents in parallel
- Orchestrate debates on key design decisions
- Ensure all agents engage (not just API Designer)
- Synthesize final specification with rationale
- Present deliverable to user
- Offer to generate client SDKs or mock server if requested
- 收集上下文信息并与用户澄清需求
- 并行启动方案提议Agent
- 统筹关键设计决策的辩论
- 确保所有Agent参与(而非仅API Designer)
- 整合最终规范文档并附上设计理由
- 向用户提交交付物
- 若用户请求,可提供客户端SDK或模拟服务器生成服务
Customization
自定义配置
The user can customize the workshop by:
- Skipping agents: "Skip performance, focus on security"
- Adding constraints: "Must support GraphQL subscriptions"
- Specifying style: "Design a REST API following JSON:API spec"
- Setting priorities: "Optimize for developer experience over efficiency"
- Providing examples: "Similar to Stripe's API" or "Here's our existing API"
- Requesting specific debates: "Debate whether we need versioning at all"
Adapt the agent roster and debate topics accordingly.
用户可通过以下方式自定义研讨会:
- 跳过特定Agent:"跳过性能Agent,重点关注安全性"
- 添加约束条件:"必须支持GraphQL subscriptions"
- 指定API风格:"设计遵循JSON:API规范的REST API"
- 设置优先级:"优先优化开发者体验而非效率"
- 提供参考示例:"类似Stripe的API"或"这是我们现有的API"
- 请求特定辩论:"辩论我们是否真的需要版本控制"
根据用户需求调整Agent角色列表与辩论议题。
Example Invocations
调用示例
/api-workshop design an API for a task management system
/api-workshop review https://api.example.com/openapi.json
/api-workshop design a GraphQL API for e-commerce with subscriptions
/api-workshop compare REST vs GraphQL for our social networkThe workshop adapts to whether you're designing new, reviewing existing, or comparing alternatives.
/api-workshop design an API for a task management system
/api-workshop review https://api.example.com/openapi.json
/api-workshop design a GraphQL API for e-commerce with subscriptions
/api-workshop compare REST vs GraphQL for our social network研讨会会根据用户需求自动适配,无论是设计新API、评审现有API还是对比不同方案。