bugfix-crate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<EXTREMELY-IMPORTANT>
This skill is a strict red-green-refactor repair loop.
Non-negotiable rules:
- Fix one finding at a time.
- For behavioral bugs, write the failing regression test before the fix.
- Run crate tests and clippy after every fix.
- Do not mark a finding fixed without the required verification.
- Use the skill for crate-specific coding conventions before changing Rust code.
rust
<EXTREMELY-IMPORTANT>
该技能是严格的红-绿-重构修复循环。
不可协商的规则:
- 一次修复一个问题。
- 对于行为类bug,在修复前编写失败的回归测试。
- 每次修复后运行crate测试和clippy。
- 未完成必要验证前,不得标记问题已修复。
- 修改Rust代码前,使用技能了解特定crate的编码规范。
rust
bugfix-crate
bugfix-crate
Inputs
输入
- : Path to the crate findings file
$issues_file
- : crate问题文件的路径
$issues_file
Goal
目标
Work through a crate issue file sequentially and leave behind:
- a verified fix for each resolved finding
- regression coverage for each behavioral fix
- a passing crate test suite
- an updated issue file showing what was fixed, deferred, or rejected as not-a-bug
按顺序处理crate问题文件,最终完成以下内容:
- 为每个已解决的问题提供经过验证的修复方案
- 为每个行为修复添加回归测试覆盖
- 使crate测试套件全部通过
- 更新问题文件,标注哪些问题已修复、已延期或被判定为非bug
Step 0: Establish the baseline
步骤0:建立基准状态
Before editing:
- read the entire issue file
- determine the target crate name and path
- invoke for relevant conventions
rust - read crate-local or testing guidance if present
CLAUDE.md - run baseline
cargo test -p <crate> - run baseline
cargo clippy -p <crate> -- -D warnings
Success criteria: The crate, issue file, and baseline state are explicit before the first fix.
开始编辑前:
- 通读整个问题文件
- 确定目标crate的名称和路径
- 调用技能获取相关编码规范
rust - 若存在crate本地的或测试指南,需阅读相关内容
CLAUDE.md - 运行基准测试:
cargo test -p <crate> - 运行基准代码检查:
cargo clippy -p <crate> -- -D warnings
成功标准:在进行首次修复前,明确crate、问题文件和基准状态的具体信息。
Step 1: Process one finding at a time
步骤1:逐一处理每个问题
For each unresolved finding:
- read the cited file and surrounding context
- determine whether it is behavioral, API, dead-code, doc-only, deferred, or not-a-bug
- if it is a behavioral or API fix, write the failing test first
- verify the test fails before changing the implementation
Do not batch findings.
Success criteria: Each finding has a concrete resolution path before any fix lands.
针对每个未解决的问题:
- 阅读引用的文件及上下文内容
- 判断该问题属于行为类、API类、死代码类、仅文档类、需延期处理类还是非bug类
- 若为行为类或API类修复,先编写失败测试
- 在修改实现前,验证测试确实会失败
不得批量处理问题。
成功标准:在进行任何修复前,每个问题都有明确的解决路径。
Step 2: Apply the smallest correct fix
步骤2:应用最小化的正确修复
Make the minimum code change that addresses the root cause.
Rules:
- do not batch adjacent refactors
- do not weaken existing tests
- do not hide warnings with
#[allow(...)] - if you uncover another real bug in the touched area, fix it in the same pass and add it to the issue file
Success criteria: The fix addresses the root cause without broad collateral edits.
做出能够解决根本原因的最小代码变更。
规则:
- 不得批量进行相邻代码重构
- 不得弱化现有测试
- 不得使用隐藏警告
#[allow(...)] - 若在修改区域发现其他真实bug,需在本次处理中修复并添加到问题文件中
成功标准:修复方案能够解决根本原因,且不会产生大范围的附带修改。
Step 3: Verify and mark status
步骤3:验证并标记状态
After each fix:
- run
cargo test -p <crate> - run
cargo clippy -p <crate> -- -D warnings - update the issue file:
- for verified fixes
**[FIXED]** - for real out-of-scope fixes
Deferred: <reason> - for invalid findings
Not a bug: <reason>
Do not mark a finding fixed before the verification pass completes.
Success criteria: The issue file and crate state stay in sync after every finding.
每次修复完成后:
- 运行
cargo test -p <crate> - 运行
cargo clippy -p <crate> -- -D warnings - 更新问题文件:
- 已验证的修复标注为
**[FIXED]** - 真实但超出范围的问题标注为
Deferred: <原因> - 无效问题标注为
Not a bug: <原因>
- 已验证的修复标注为
在验证流程完成前,不得标记问题已修复。
成功标准:每次处理完问题后,问题文件与crate状态保持一致。
Step 4: Finish only when the issue file is resolved
步骤4:仅当问题文件全部处理完成时结束
At the end:
- confirm every finding has a terminal status
- confirm the crate still passes tests and clippy
- summarize resolved, deferred, and rejected findings
Success criteria: The issue file is fully triaged and the crate is green.
最终阶段:
- 确认每个问题都有最终状态
- 确认crate仍能通过测试和clippy检查
- 总结已解决、已延期和已驳回的问题
成功标准:问题文件已完成全面分类,且crate处于全部通过的状态。
Guardrails
约束规则
- Do not use worktree agents for same-crate fixing.
- Do not run this skill proactively; it is explicit-user-only.
- Do not mark behavioral bugs fixed without regression coverage.
- Do not replace a real fix with comments, warnings, or documentation.
- Do not batch multiple findings in one verification loop.
- 修复同一crate问题时,不得使用工作区代理。
- 不得主动运行该技能;仅在用户明确调用时使用。
- 未添加回归测试覆盖的行为类bug,不得标记为已修复。
- 不得用注释、警告或文档替代真实修复。
- 不得在一次验证循环中批量处理多个问题。
Output Contract
输出约定
Report:
- crate and issue file processed
- baseline test and clippy state
- per-finding outcome
- final test and clippy state
- any newly discovered findings added during repair
需提交以下报告:
- 已处理的crate和问题文件
- 基准测试和clippy检查状态
- 每个问题的处理结果
- 最终测试和clippy检查状态
- 修复过程中发现的新问题