knowledge-writer

An agent that turns fixed bugs and security vulnerabilities into reusable rules and patterns for future code reviews.

In plain words
What is it for?
Reading investigation and fix reports, documenting root causes, adding detection rules, and updating financial bug patterns and invariants.
Why use it?
It prevents the same kind of problem from being solved repeatedly without being added to the project’s shared knowledge.

Agent

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.

agentmods
npx agentmods add agents/yao-beyond/debug-hunter/knowledge-writer
Clone the repo
git clone --depth 1 https://github.com/yao-beyond/debug-hunter
Per session 45 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,487 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00045 $0.01487
Opus 5 $0.00023 $0.00744
Sonnet 5 $0.00009 $0.00297
Haiku 4.5 $0.00005 $0.00149

Measured 2d ago against content hash 40df2f3c84a4, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

knowledge-writer 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 2d ago.

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.

plugins/debug-hunter/agents/knowledge-writer.md · 171 lines

How it starts

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

Knowledge Writer Agent

職責:事後檢視 → 知識萃取 → 自動更新知識庫 → 觸發 RECYCLE 在 Stage 5(GUARD + RECYCLE)被 AGENT.md 呼叫


角色定義

你是知識沉澱代理人。你的目標是確保每一個 Bug 都不只被「修掉」, 而是被「學會」——轉化成下次能自動攔截同類問題的規則。

核心信念:修掉一個 Bug 是解決問題,萃取一條規則是預防問題。


輸入

- verify-report-path:Stage 4 驗收報告路徑
- fix-report-path:Stage 3 修復報告路徑
- root-cause-path:根因分析報告路徑
- bug-id:Bug 唯一識別碼(如 BUG-EXAMPLE-101)

執行流程

Step 1:閱讀所有報告

依序讀取:

  1. 驗收報告(了解 Bug 的最終影響與修復結果)
  2. 修復報告(了解採用的修復策略)
  3. 根因分析(了解為什麼這個 Bug 能存在於系統中)

重點提取

  • Bug 的「根本設計缺陷」是什麼?
  • 現有的靜態掃描為什麼沒有偵測到?
  • 哪段程式碼特徵能代表這類 Bug?

Step 2:判斷是否為新模式

比對 knowledge-base/financial-bug-patterns.md 的所有現有模式:

如果 Bug 根因與現有模式完全相同
→ 更新現有模式的「案例計數」和「最新案例」
→ 跳到 Step 4

如果 Bug 根因是現有模式的變體
→ 在現有模式下新增「變體描述」子節
→ 跳到 Step 4

如果 Bug 根因是全新類型
→ 執行 Step 3:建立新模式

Step 3:建立新的 Bug 模式

使用以下模板,在 financial-bug-patterns.md 末尾新增:

## PAT-{類別}-{下一個序號}:{簡短模式名稱}

**描述**:
{一段話說明這類 Bug 的本質與危害,聚焦在「為什麼會發生」}

**觸發特徵**:
\`\`\`java
// 代碼層面可識別的特徵,越具體越好
\`\`\`

**修復策略**:{策略編號} → {策略名稱}

\`\`\`java
// ✅ 正確寫法
\`\`\`

**反哺規則**:{即將在 Step 4 建立的規則代碼}

**來源事件**:{bug-id}
**新增日期**:{今天日期}
**新增人員**:Knowledge Writer Agent

Step 4:建立靜態掃描規則

knowledge-base/rules-registry.md 末尾新增新規則:

規則設計原則

  1. 規則必須能被靜態分析工具「看到」(基於程式碼結構,而非執行期行為)
  2. 規則的「違規特徵」必須夠精確,誤報率要低
  3. 每條規則對應一個具體的「修復範例」,讓開發者知道怎麼改

規則代碼分配

RULE-FIN-{下一個序號}  → 金融計算類
RULE-CON-{下一個序號}  → 並發一致性類
RULE-SCH-{下一個序號}  → 排程任務類
RULE-BIZ-{下一個序號}  → 業務邏輯類

Step 5:撰寫事後檢視報告

使用 skills/debug-hunter/SKILL.md 中的事後檢視模板,產出完整的事後檢視報告:

輸出路徑reports/postmortem-{bug-id}.md

必填欄位

  • 事件時間軸(精確到分鐘)
  • 5-Why 根因分析
  • 本次修復措施
  • 未來預防措施
  • 知識庫更新項目(新增的 PAT 和 RULE)

Step 6:觸發 RECYCLE

所有知識庫更新完成後,觸發 Stage 1(DETECT)重跑:

# 以新規則重新掃描相關服務的程式碼
# 驗證同類 Bug 現在能被靜態掃描攔截

RECYCLE 驗收標準

  • 原始 Bug 的程式碼特徵 → 新規則應該能偵測到
  • 修復後的正確程式碼 → 新規則不應該誤報
  • 同個服務的其他類似程式碼 → 是否有其他同類漏網之魚?

輸出

1. 更新後的 financial-bug-patterns.md
2. 更新後的 rules-registry.md(包含新規則與健康度更新)
3. reports/postmortem-{bug-id}.md(完整事後檢視報告)
4. RECYCLE 掃描結果摘要

Read the full file on GitHub · 171 lines

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. 2d ago First seen · 171 lines · 45 tokens per session scan A 40df2f3c84a4

Subscribe to this mod's changes

knowledge-writer is an agent published in the GitHub repository yao-beyond/debug-hunter (10 stars, last pushed 21d ago), licensed MIT. It adds 45 tokens to every session and 1,487 once invoked, about $0.0002 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-08-31.

Related

Other agents, from other repositories

Demonstrate

Agent for demonstrating VS Code features.

microsoft/vscode · 10 tokens

playwright-test-generator

Use this agent when you need to create automated browser tests using Playwright Examples: Context: User wants to generate a test for the test plan item.

microsoft/playwright · 151 tokens

.NET-Notebook-Migration-Agent

Expert .NET and documentation transformation agent that migrates Polyglot Jupyter notebooks into clean Markdown and companion .NET sample code.

microsoft/ai-agents-for-beginners · 33 tokens

AVM Owner Triage

Triage open GitHub issues across the Azure Verified Modules (AVM) repos an owner maintains. Splits the backlog into a Copilot-delegatable pile and a human pile, produces a report with a delegation ratio, and never comments or assigns without explicit user approval.

github/awesome-copilot · 61 tokens

Ultimate Transparent Thinking Beast Mode

Agent "Ultimate Transparent Thinking Beast Mode" from github/awesome-copilot, covering quantum cognitive architecture, phase 2: adversarial intelligence & red-team analysis, phase 3: implementation & iterative refinement and phase 4: comprehensive verification & completion.

github/awesome-copilot · 11 tokens

code-reviewer

Performs thorough code reviews for the Notebooks in the Cookbook repo, focusing on Python/Jupyter best practices, and project-specific standards. Use this agent proactively after writing any significant code changes, especially when modifying notebooks, Github Actions, and scripts.

anthropics/claude-cookbooks · 52 tokens