npx skills add https://github.com/rysweet/amplihack --skill n-version-workflow针对关键实现执行 N 版本编程工作流,生成多个独立的解决方案并进行比较,以选择最佳方法。
适用于:
不适用于:
N(版本数量):
3 - 标准任务的默认值4-6 - 需要高置信度的关键功能2 - 快速验证方法选择标准(优先级顺序):
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
代理多样性配置:
conservative - 经过验证的模式和安全性innovative - 新颖的方法和优化minimalist - 极致的简洁性pragmatic - 平衡权衡以获得实用的解决方案performance-focused - 为速度和效率进行优化输出: 单个权威规范文档
N=3 的示例:
比较矩阵:
| 版本 | 正确性 | 安全性 | 简洁性 | 理念符合性 | 性能 | 代码行数 |
|---------|-------------|----------|------------|------------|-------------|---------------|
| v1 | 通过 | 通过 | 7/10 | 8/10 | 150ms | 180 |
| v2 | 通过 | 通过 | 9/10 | 9/10 | 180ms | 95 |
| v3 | 失败 | 不适用 | 10/10 | 7/10 | 不适用 | 65 |
评估流程:
决策树:
综合示例:
已选择:v1 和 v2 的混合方案
- 核心逻辑来自 v2(极致的简洁性)
- 错误处理来自 v1(全面的覆盖)
- 测试方法来自 v2(专注、最小化)
- 文档风格来自 v1(详尽)
理由:v2 的极简核心与 v1 的鲁棒错误处理相结合,
在简洁性和生产就绪性之间提供了最佳平衡。
文档模板:
"""
N 版本实现选择
生成的版本数:3
选择:v1(保守)和 v2(务实)的混合方案
理由:
- v1 在错误处理和边缘情况覆盖方面更优
- v2 在架构清晰度和可测试性方面更好
- v3 未通过正确性测试(边缘情况处理)
此实现结合了 v2 的核心逻辑与 v1 的防御性编程方法,
以实现生产环境下的鲁棒性。
应用的选择标准:
1. 正确性:v1=通过,v2=通过,v3=失败
2. 安全性:全部通过
3. 简洁性:v2 排名最高
4. 理念符合性:v1 和 v2 并列
5. 性能:差异可忽略
"""
n_version_analysis.mdamplihack.memory.discoveries 中的 store_discovery() 将学到的模式存储在内存中成本: N 倍的计算资源和时间 收益: 显著降低关键错误的风险 最适合: 错误代价高昂的功能(安全性、数据完整性)
任务: 实现基于 JWT 的身份验证 配置: N=4(关键安全功能) 配置: conservative, security-focused, pragmatic, minimalist
结果:
选择: v2 和 v3 的混合方案
理由: 安全性不能妥协,但 v3 更简洁的 API 设计在不牺牲安全性的前提下提高了可用性。
任务: 高效处理大型 CSV 文件 配置: N=3(性能关键) 配置: pragmatic, performance-focused, minimalist
结果:
选择: v2(性能导向)
理由: 性能要求证明了复杂性的合理性。v2 的流式处理方法满足了吞吐量要求,而 v1 和 v3 无法扩展。
此工作流强制执行:
启用时,此工作流替换 DEFAULT_WORKFLOW 的步骤 4-5(研究/设计和实现)。所有其他步骤(需求、测试、CI/CD)保持不变。
每周安装次数
86
仓库
GitHub 星标数
43
首次出现
2026 年 1 月 23 日
安全审计
安装于
opencode79
claude-code76
codex74
cursor72
gemini-cli71
github-copilot70
Execute N-version programming workflow for critical implementations where multiple independent solutions should be generated and compared to select the best approach.
USE FOR:
AVOID FOR:
N (Number of Versions):
3 - Default for standard tasks4-6 - Critical features requiring high confidence2 - Quick validation of approachSelection Criteria (priority order):
Agent Diversity Profiles:
conservative - Proven patterns and safetyinnovative - Novel approaches and optimizationsminimalist - Ruthless simplicitypragmatic - Balance trade-offs for practical solutionsperformance-focused - Optimize for speed and efficiencyOutput: Single authoritative specification document
Example for N=3:
Comparison Matrix:
| Version | Correctness | Security | Simplicity | Philosophy | Performance | Lines of Code |
|---------|-------------|----------|------------|------------|-------------|---------------|
| v1 | PASS | PASS | 7/10 | 8/10 | 150ms | 180 |
| v2 | PASS | PASS | 9/10 | 9/10 | 180ms | 95 |
| v3 | FAIL | N/A | 10/10 | 7/10 | N/A | 65 |
Evaluation Process:
Decision Tree:
Example Synthesis:
Selected: Hybrid of v1 and v2
- Core logic from v2 (ruthless simplicity)
- Error handling from v1 (comprehensive coverage)
- Testing approach from v2 (focused, minimal)
- Documentation style from v1 (thorough)
Rationale: v2's minimalist core paired with v1's robust
error handling provides optimal balance of simplicity
and production-readiness.
Documentation Template:
"""
N-Version Implementation Selection
Generated Versions: 3
Selection: Hybrid of v1 (conservative) and v2 (pragmatic)
Rationale:
- v1 had superior error handling and edge case coverage
- v2 had cleaner architecture and better testability
- v3 failed correctness tests (edge case handling)
This implementation combines v2's core logic with v1's
defensive programming approach for production robustness.
Selection Criteria Applied:
1. Correctness: v1=PASS, v2=PASS, v3=FAIL
2. Security: All passed
3. Simplicity: v2 ranked highest
4. Philosophy: v1 and v2 tied
5. Performance: Negligible difference
n_version_analysis.mdstore_discovery() from amplihack.memory.discoveriesCost: N times the compute resources and time Benefit: Significantly reduced risk of critical errors Best For: Features where bugs are expensive (security, data integrity)
Task: Implement JWT-based authentication Configuration: N=4 (critical security feature) Profiles: conservative, security-focused, pragmatic, minimalist
Result:
Selection: Hybrid of v2 and v3
Rationale: Security cannot be compromised, but v3's cleaner API design improved usability without sacrificing security.
Task: Process large CSV files efficiently Configuration: N=3 (performance-critical) Profiles: pragmatic, performance-focused, minimalist
Result:
Selection: v2 (performance-focused)
Rationale: Performance requirements justified complexity. v2's streaming approach met throughput requirements while v1 and v3 could not scale.
This workflow enforces:
This workflow replaces Steps 4-5 (Research/Design and Implementation) of the DEFAULT_WORKFLOW when enabled. All other steps (requirements, testing, CI/CD) remain the same.
Weekly Installs
86
Repository
GitHub Stars
43
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode79
claude-code76
codex74
cursor72
gemini-cli71
github-copilot70
站立会议模板:敏捷开发每日站会指南与工具(含远程团队异步模板)
10,500 周安装