codex-iterative-fix

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<!-- S0 META-IDENTITY -->
<!-- S0 META-IDENTITY -->

Codex Iterative Fix Skill

Codex迭代修复Skill



LIBRARY-FIRST PROTOCOL (MANDATORY)

库优先协议(强制性要求)

Before writing ANY code, you MUST check:
在编写任何代码之前,你必须检查:

Step 1: Library Catalog

步骤1:库目录

  • Location:
    .claude/library/catalog.json
  • If match >70%: REUSE or ADAPT
  • 位置:
    .claude/library/catalog.json
  • 匹配度>70%:复用或适配

Step 2: Patterns Guide

步骤2:模式指南

  • Location:
    .claude/docs/inventories/LIBRARY-PATTERNS-GUIDE.md
  • If pattern exists: FOLLOW documented approach
  • 位置:
    .claude/docs/inventories/LIBRARY-PATTERNS-GUIDE.md
  • 若存在对应模式:遵循文档记录的方法

Step 3: Existing Projects

步骤3:现有项目

  • Location:
    D:\Projects\*
  • If found: EXTRACT and adapt
  • 位置:
    D:\Projects\*
  • 若找到相关内容:提取并适配

Decision Matrix

决策矩阵

MatchAction
Library >90%REUSE directly
Library 70-90%ADAPT minimally
Pattern existsFOLLOW pattern
In projectEXTRACT
No matchBUILD (add to library after)

匹配度操作
库匹配>90%直接复用
库匹配70-90%最小程度适配
存在对应模式遵循模式
项目中已有提取使用
无匹配项构建(完成后添加至库中)

Kanitsal Cerceve (Evidential Frame Activation)

Kanitsal Cerceve(证据框架激活)

Kaynak dogrulama modu etkin.
来源验证模式已激活。

Purpose

用途

Use Codex CLI's autonomous iteration capability to fix failing tests and debug issues until they pass. This skill leverages Codex's strength at long-horizon coding tasks.
利用Codex CLI的自主迭代能力修复失败的测试并调试问题,直至测试通过。该Skill充分发挥了Codex在长周期编码任务中的优势。

When to Use This Skill

何时使用该Skill

  • Multiple tests failing that need iterative fixing
  • Debugging issues requiring trial-and-error
  • Refactoring with test validation
  • CI/CD failures needing automated fixes
  • Build errors requiring multiple attempts
  • 多个测试失败,需要迭代修复
  • 需反复试验的调试问题
  • 需测试验证的代码重构
  • 需要自动修复的CI/CD失败
  • 需多次尝试修复的构建错误

When NOT to Use This Skill

何时不使用该Skill

  • Research tasks (use multi-model-discovery)
  • Understanding codebase (use gemini-codebase-onboard)
  • Critical production code (use sandbox mode first)
  • Architecture decisions (use llm-council)
  • 研究类任务(请使用multi-model-discovery)
  • 了解代码库(请使用gemini-codebase-onboard)
  • 关键生产代码(请先使用沙箱模式)
  • 架构决策(请使用llm-council)

Workflow

工作流程

Phase 1: Initial Assessment

第一阶段:初始评估

  1. Identify failing tests/errors
  2. Determine scope of fixes needed
  3. Choose appropriate mode:
    • full-auto
      : Standard autonomous mode
    • sandbox
      : For risky changes
    • yolo
      : When speed is critical
  1. 识别失败的测试/错误
  2. 确定所需修复的范围
  3. 选择合适的模式:
    • full-auto
      :标准自主模式
    • sandbox
      :用于高风险修改
    • yolo
      :对速度要求极高时

Phase 2: Codex Execution

第二阶段:Codex执行

bash
undefined
bash
undefined

Standard iterative fix

标准迭代修复

./scripts/multi-model/codex-yolo.sh "Fix all failing tests" task-id "." 15 full-auto
./scripts/multi-model/codex-yolo.sh "Fix all failing tests" task-id "." 15 full-auto

With sandbox protection

带沙箱保护

./scripts/multi-model/codex-yolo.sh "Fix tests" task-id "." 10 sandbox
./scripts/multi-model/codex-yolo.sh "Fix tests" task-id "." 10 sandbox

Via delegate.sh

通过delegate.sh调用

./scripts/multi-model/delegate.sh codex "Fix all failing tests and verify they pass" --full-auto
undefined
./scripts/multi-model/delegate.sh codex "Fix all failing tests and verify they pass" --full-auto
undefined

Phase 3: Verification

第三阶段:验证

  1. Codex runs tests after each fix
  2. Iterates until all tests pass
  3. Claude reviews final changes
  4. Summary of what was fixed
  1. Codex在每次修复后运行测试
  2. 迭代直至所有测试通过
  3. Claude审核最终修改
  4. 生成修复内容摘要

Success Criteria

成功标准

  • All targeted tests passing
  • No new regressions introduced
  • Changes reviewed and validated
  • Clear documentation of fixes
  • 所有目标测试已通过
  • 未引入新的回归问题
  • 修改内容已审核并验证
  • 修复内容文档清晰

Example Usage

示例用法

Example 1: Test Suite Failures

示例1:测试套件失败

text
User: "CI is failing with 12 test errors"

Codex Process:
1. Run tests, capture failures
2. Analyze first failure
3. Implement fix
4. Re-run tests
5. Repeat until all pass

Output:
- Fixed: 12 tests
- Changes: 8 files modified
- Root causes: Missing null checks, outdated mocks
text
用户: "CI因12个测试错误而失败"

Codex流程:
1. 运行测试,捕获失败情况
2. 分析第一个失败问题
3. 实施修复
4. 重新运行测试
5. 重复直至全部通过

输出:
- 已修复: 12个测试
- 修改: 8个文件被修改
- 根本原因: 缺少空值检查、模拟数据过时

Example 2: Type Errors

示例2:类型错误

text
User: "TypeScript build has 47 type errors"

Codex Process:
1. Run tsc, capture errors
2. Fix type errors systematically
3. Re-run after each batch
4. Verify build succeeds

Output:
- Fixed: 47 type errors
- Patterns: Missing types, incorrect generics
- Added: 3 new type definitions
text
用户: "TypeScript构建存在47个类型错误"

Codex流程:
1. 运行tsc,捕获错误
2. 系统地修复类型错误
3. 每批修复后重新运行
4. 验证构建成功

输出:
- 已修复: 47个类型错误
- 模式: 缺少类型定义、泛型使用错误
- 新增: 3个新的类型定义

Modes Explained

模式说明

ModeCommandUse CaseRisk
full-auto
--full-auto
Standard iterationMedium
sandbox
--sandbox workspace-write
Risky refactorsLow
yolo
--yolo
Speed criticalHigh
模式命令使用场景风险
full-auto
--full-auto
标准迭代场景中等
sandbox
--sandbox workspace-write
高风险重构
yolo
--yolo
速度优先场景

Integration with Meta-Loop

与元循环的集成

META-LOOP IMPLEMENT PHASE:
    |
    +---> codex-iterative-fix
    |         |
    |         +---> Codex: Run tests
    |         +---> Codex: Fix failures
    |         +---> Codex: Iterate until pass
    |
    +---> Continue to TEST phase (verification)
META-LOOP 实施阶段:
    |
    +---> codex-iterative-fix
    |         |
    |         +---> Codex: 运行测试
    |         +---> Codex: 修复失败问题
    |         +---> Codex: 迭代直至通过
    |
    +---> 进入测试阶段(验证)

Memory Integration

内存集成

Results stored at:
  • Key:
    multi-model/codex/iterative-fix/{project}/{task_id}
  • Tags: WHO=codex-iterative-fix, WHY=autonomous-fixing
结果存储位置:
  • 键:
    multi-model/codex/iterative-fix/{project}/{task_id}
  • 标签: WHO=codex-iterative-fix, WHY=autonomous-fixing

Invocation Pattern

调用模式

bash
undefined
bash
undefined

Via router (automatic detection)

通过路由器(自动检测)

./scripts/multi-model/multi-model-router.sh "Fix all failing tests"
./scripts/multi-model/multi-model-router.sh "Fix all failing tests"

Direct Codex call

直接调用Codex

bash -lc "codex --full-auto exec 'Fix all failing tests and verify they pass'"
undefined
bash -lc "codex --full-auto exec 'Fix all failing tests and verify they pass'"
undefined

Guardrails

防护规则

NEVER:
  • Run on production without review
  • Skip final verification
  • Ignore new test failures
  • Exceed iteration limit without human check
ALWAYS:
  • Review changes before commit
  • Document what was fixed
  • Check for regressions
  • Store results in Memory-MCP
绝对禁止:
  • 在未审核的情况下在生产环境运行
  • 跳过最终验证步骤
  • 忽略新出现的测试失败
  • 未经过人工检查就超出迭代次数限制
必须执行:
  • 提交前审核修改内容
  • 记录修复的问题
  • 检查是否存在回归问题
  • 将结果存储至Memory-MCP

Related Skills

相关技能

  • codex-safe-experiment
    : Sandbox experimentation
  • smart-bug-fix
    : Systematic debugging
  • testing-quality
    : Test generation
  • multi-model-discovery
    : Find existing fixes
<!-- S4 SUCCESS CRITERIA -->
  • codex-safe-experiment
    : 沙箱实验
  • smart-bug-fix
    : 系统化调试
  • testing-quality
    : 测试用例生成
  • multi-model-discovery
    : 查找现有修复方案
<!-- S4 SUCCESS CRITERIA -->

Verification Checklist

验证清单

  • All targeted tests passing
  • No new regressions
  • Changes reviewed
  • Memory-MCP updated
  • Documentation complete
<!-- PROMISE -->
[commit|confident] <promise>CODEX_ITERATIVE_FIX_COMPLETE</promise>
  • 所有目标测试已通过
  • 无新的回归问题
  • 修改内容已审核
  • Memory-MCP已更新
  • 文档已完善
<!-- PROMISE -->
[commit|confident] <promise>CODEX_ITERATIVE_FIX_COMPLETE</promise>