x-bug2rag

x-bug2rag is a skill for Claude Code, Codex from KtKID/x-dev-pipeline. It costs 255 tokens per session (3,642 once invoked), scanned A, original, MIT.

A knowledge-capture tool that turns reusable bug explanations into a local RAG collection, meaning a searchable store of text that an agent can retrieve later. It records the trigger, incorrect implementation, correct implementation, and observable difference.

In plain words
What is it for?
Use it to add suitable bug lessons, initialize or combine a user's knowledge collection, create searchable indexes and Markdown sections, validate them, and retrieve entries by ID.
Why use it?
It keeps useful failure mechanisms from being lost after a bug is fixed, while filtering out one-off incidents and ordinary programming advice. The resulting entries can help future reviews construct small counterexamples.

Skill for Claude CodeCodex

Written for Claude Code and Codex: shipped in a Claude Code plugin, but also agents/openai.yaml present.

Part of the x-dev-pipeline plugin — 22 skills shipped together

Good fit Use it to add suitable bug lessons, initialize or combine a user's knowledge collection, create searchable indexes and Markdown sections, validate them, and retrieve entries by ID.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/ktkid/x-dev-pipeline/x-bug2rag
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add KtKID/x-dev-pipeline --skill x-bug2rag
Clone the repo
git clone --depth 1 https://github.com/KtKID/x-dev-pipeline

Made for: Claude Code, Codex.

Or install x-dev-pipeline, the plugin that ships this one along with the rest of its 22 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for x-bug2rag

README.md
[![agentmods](https://agentmods.dev/badge/skills/ktkid/x-dev-pipeline/x-bug2rag/github.svg)](https://agentmods.dev/skills/ktkid/x-dev-pipeline/x-bug2rag)
Your own site
<a href="https://agentmods.dev/skills/ktkid/x-dev-pipeline/x-bug2rag"><img src="https://agentmods.dev/badge/skills/ktkid/x-dev-pipeline/x-bug2rag/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for x-bug2rag

Your own site · 80×15
<a href="https://agentmods.dev/skills/ktkid/x-dev-pipeline/x-bug2rag"><img src="https://agentmods.dev/badge/skills/ktkid/x-dev-pipeline/x-bug2rag.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 255 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,642 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00255 $0.03642
Opus 5 $0.00128 $0.01821
Sonnet 5 $0.00051 $0.00728
Haiku 4.5 $0.00026 $0.00364

Measured today against content hash 83e367bcac93, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

x-bug2rag scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

The scan reads SKILL.md. This mod also ships 4 executable files (scripts/corpus_aggregate.py, scripts/home_corpus.py, scripts/triage_store.py, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/x-bug2rag/SKILL.md · 281 lines

How it starts

The opening of the file, as written. The whole thing — 281 lines — stays where its author put it; the contents beside it link to each section on GitHub.

x-bug2rag · bug → RAG 经验沉淀

把"一次性 bug"转成"可召回的失败机制"。错题库记的不是 bug 本身,而是 bug 暴露的失败机制:触发条件 + 错误实现长什么样 + 正确实现长什么样 + 可观察差异。这种结构跨项目可复现,召回后能直接构造对/错实现的最小反例。

记什么 / 不记什么

错题库是召回素材,不是 bug tracker。一条经验值得记,当且仅当它能脱离具体项目,被未来的 spec/代码 review 召回并直接用于构造反例。

值得记(同时满足)

  1. 是失败机制,不是一次性事件:能说清"在什么场景下、错实现长什么样、对实现长什么样、两者可观察差异是什么"。

  2. 跨项目可复现:把项目名、库名、具体业务名词换掉,经验依然成立。

  3. 落入泛用类别之一(详见 references/triage-rules.md):

    类别 典型失败机制
    状态机 恢复只校验形状不校验转换、状态跳跃、非法历史态被接受
    并发/时序 重试与首次并发、消息乱序、读写交错、部分失败
    幂等/唯一 重试产生重复副作用、键冲突、去重漏网
    边界/默认值 空集合、单元素、off-by-one、默认值被绕过
    权限/越权 身份切换后权限残留、横向越权、共享状态污染
    资源生命周期 超时分支漏清理、句柄泄漏、资源耗尽
    持久化一致性 多阶段提交中断、索引与正文不一致、崩溃恢复窗口
    数据敏感 日志/错误信息泄漏 PII、secret 进日志、错误码可枚举

抛弃信号(任一命中即弃)

  • 纯领域事实:业务规则、API 限额、产品约束——这是 spec 该写的,不是经验。
  • 一次性运维/环境 bug:磁盘满、机器挂了、配置手抖——不可重述,召回不到。
  • 编程常识:判 null、边界检查、基本类型转换——LLM 自己会,浪费召回预算。
  • 时效性强、易腐烂:某库升级后行为变了、某版本特定 bug——半年后召回到反而是误导。
  • 补不齐必填字段:场景/错误实现/正确实现/可观察差异任一无法说清——召回素材不完整,等于没记。

corpus 条目格式

每条 ## AR-NNN,字段顺序固定。前三位补零,条目超过 999 后自然增长为 AR-1000。ID 由脚本自动分配,LLM 不手写。

## AR-NNN
关键词:<召回语义锚点,3-6 个,逗号分隔>
Risk:<一句具体失败机制,主语+条件+后果>
场景:<触发条件、上下文、前置状态>
错误实现:<常见错误做法长什么样>
正确实现:<对的实现长什么样>
可观察差异:<错实现 vs 对实现的可观察区分点>
分类:<上述 8 类之一>
来源:<项目/报告/issue,可选>

字段必须自包含:召回后 LLM 只读这一段就能构造反例,不需要再翻原 bug。Risk 句禁止空泛("可能有 bug""要小心"),必须落到具体机制。

用户级默认 corpus

所有平台都通过 Python 的 Path.home() 定位用户 Home,默认 corpus 固定为:

~/.x-dev-pipeline/rag/risk-catalog.md

新用户设置分成两个独立操作。第一步只创建用户 RAG 目录:

BUG2RAG_SKILL_DIR="<当前已加载的 x-bug2rag/SKILL.md 所在目录>"

python3 "${BUG2RAG_SKILL_DIR}/scripts/home_corpus.py" init --json

第二步把插件已有 risk-catalog.md 原样复制到用户目录:

python3 "${BUG2RAG_SKILL_DIR}/scripts/home_corpus.py" \
  import-existing \
  --json

import-existing 默认从同一插件的 x-adversarial-risk/references/risk-catalog.md 读取。目标文件已有相同内容时返回 copied: false;目标文件已有其他内容时停止覆盖。测试新用户流程时用 --home <temporary-home> 隔离真实用户数据。

两种 corpus 存储模式

单文件模式

Read the full file on GitHub · 281 lines

Files

What ships with it

7 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today First seen · 281 lines · 255 tokens per session scan A 83e367bcac93

Subscribe to this mod's changes

x-bug2rag is a skill published in the GitHub repository KtKID/x-dev-pipeline (12 stars, last pushed today), licensed MIT. It adds 255 tokens to every session and 3,642 once invoked, about $0.0013 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-09.