360 Secure SkillHub
360 安全技能中心

fix-dedupe

在动手写修复前执行强制查重:扫描所有引用上含 fix/hotfix/patch 等关键字的提交,列出未合分支上超前于基线的候选修复,并配合 PR/MR 搜索与任务重试链核对,避免为已修问题引入第二种修法。

分类:开发
z-zihan
z-zihan
热度 31.39
最近更新 2026-12-05 04:18:16

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add z-zihan/fix-dedupe
兼容性
通用兼容
联网要求
需要联网
数据出网
可选出网
Metadata
name
fix-dedupe
version
1.0.0
homepage
https://github.com/z-Zihan/awesome-skills
allowed-tools
Bash(git log:*), Bash(git branch:*), Bash(git fetch:*), Bash(python3:*), Read, Grep
description
写修复前先查重:确认「这个问题是不是已经有人修了、用什么方式修的、修在哪」。 两个子命令扫全部引用的关键字提交(fix/hotfix/patch)与「在途未合分支上超前于 基线的候选修复」,配合 MR/PR 搜索与任务重试链核对,避免给同一个问题引入第二种 修法。Pre-fix duplicate check: search all refs for keyword commits and list candidate fixes sitting ahead of the base on unmerged branches, so you never ship a second, competing mechanism for an already-fixed problem. 触发词:修复查重, 有没有人修过, 重复修复, fix dedupe, 查在途修复, before I write a fix, 避免第二种修法, 已修检查, 合并前查重。

fix-dedupe — 写修复前的查重守卫

语言规则

检测用户使用的语言,全程使用同一语言输出。


中文版

核心用途

排障→定位根因→动手写修复,是 Agent 修构建失败/线上问题的标准路径。这条路径有个真实踩过的坑:等你写完修复、甚至推完分支,才发现别人已经用另一种方式修好了——两种修法并存会留下指向已删文件的豁免登记、互相矛盾的补丁;查重晚了还会污染任务列表(重试链里多出一串白跑的任务)。本 skill 把「查重」固化成动手前的强制动作。

适用场景与触发条件

  • 准备为一个故障/失败写任何代码修复之前(必做);
  • 收到「某某构建又失败了」,准备提任务/重试之前(先查失败是否已被后续提交修掉);
  • 接手别人排查到一半的问题,准备继续写补丁之前。

不触发:纯问答、纯诊断(不改代码)的场景。

执行步骤

  1. 任务/工单层:这个问题最早一次失败之后,有没有新的同分支任务成功?(有 → 问题可能已被修,看它的 sourceCommit 与失败任务的差)
  2. 全引用提交扫描:python3 scripts/fix_dedupe.py commits --repo <路径> --since-days 14 --keywords "fix,hotfix,patch,<领域词>" 退出码 1 = 列出了候选修复提交(hash/作者/分支/标题)。
  3. 在途分支扫描:python3 scripts/fix_dedupe.py inflight --repo <路径> --base origin/<基线分支> 列出「超前于基线、还没合」的候选修复——最常见的漏网处:修复只落在出事的分支或某个 feature 分支上,main/基线上没有。
  4. MR/PR 搜索(补 git 扫不到的元数据):gh pr list --search "<关键词>" / glab api "merge_requests?state=opened&search=<关键词>"。
  5. 决策:
    • 已有人用仓库标准机制修复且构建/测试通过 → 不引入第二种修法。缺口只剩「目标分支本身还没带上修复」时,cherry-pick 原提交(保留原作者)开 MR,不要重写。
    • 有人的修复在途未合 → 等合入再提交受影响任务,或如实说明「修复在途」。
    • 确认没人修 → 正常写修复,并在描述里注明查重结论。

输出

commits:候选提交列表(含所在引用装饰),退出码 1/0。inflight:按分支分组的超前候选 + 决策提示,退出码 1/0。

异常处理

  • 关键词要带领域词(如 notary、gate、marketplace),只查 "fix" 会漏掉不带前缀的修复提交。
  • --cherry-pick --right-only 已忽略等价补丁;若修复是重做版(内容不同),仍会列出。
  • 脚本只读(git log / branch),不会 fetch——先 git fetch --all 再跑 inflight,否则远端分支视图是旧的。

验收标准

  • 对一个「修复只落在 feature 分支」的仓库,inflight 必须把该分支列为候选(退出码 1)。
  • 对最近无修复提交的仓库,两个子命令都退出 0。

English

Purpose

The standard incident path is diagnose → root-cause → write a fix. A real trap: you finish your fix — sometimes even push the branch — before discovering someone already fixed it a different way. Two competing mechanisms leave inconsistent artifacts (exclusions pointing at deleted files, contradictory patches), and late dedupe pollutes job/retry chains. This skill makes dedupe a mandatory pre-fix step.

Steps

  1. Task layer: any newer successful run on the same branch after the failure? Its diff vs the failing sourceCommit may already contain the fix.
  2. commits — keyword scan across ALL refs (exit 1 = candidates listed).
  3. inflight — per-remote-branch commits ahead of the base matching keywords (the usual blind spot: the fix landed on the incident branch or a feature branch, not main).
  4. MR/PR search for metadata git can't see.
  5. Decide: standard fix already merged → do not add a second approach; cherry-pick the original commit (keep the author) only to fill the gap of an unreached branch. In-flight → wait, or report honestly. Nothing found → proceed, and note the dedupe result in your description.

Read-only (git log / branch); run git fetch --all first so remote views are fresh.