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.
npx skills add hmj1026/dhpk --skill dhpk-legacy-characterization-testsgit clone --depth 1 https://github.com/hmj1026/dhpkWrote 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.
[](https://agentmods.dev/skills/hmj1026/dhpk/dhpk-legacy-characterization-tests)<a href="https://agentmods.dev/skills/hmj1026/dhpk/dhpk-legacy-characterization-tests"><img src="https://agentmods.dev/badge/skills/hmj1026/dhpk/dhpk-legacy-characterization-tests/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.
<a href="https://agentmods.dev/skills/hmj1026/dhpk/dhpk-legacy-characterization-tests"><img src="https://agentmods.dev/badge/skills/hmj1026/dhpk/dhpk-legacy-characterization-tests.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00108 | $0.02802 |
| Opus 5.5 | $0.00043 | $0.01121 |
| Sonnet 5.5 | $0.00022 | $0.00560 |
| Haiku 4.5 | $0.00011 | $0.00280 |
Grade A, and why
dhpk-legacy-characterization-tests 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 yesterday.
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.
How it starts
The opening of the file, as written. The whole thing — 238 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Legacy Code Characterization Skill
概述 — source: observed behavior and existing tests are SSOT; this skill owns workflow, not production semantics
針對無測試或低測試覆蓋率的 legacy code,撰寫 characterization tests(特徵測試)以鎖定現有行為,為後續重構提供安全網。
此技術來自 Michael Feathers 的《Working Effectively with Legacy Code》。核心思想: 先觀察程式實際在做什麼,把觀察到的輸出寫成 assertion,讓它通過(GREEN),再開始重構。
When to Use
- 準備重構超過 300 行的 legacy class / controller
- 需要為關鍵業務邏輯建立回歸測試,但無法修改現有結構
- 測試覆蓋率提升計畫中的 legacy 模組
- 提取 Service / Repository 前的行為快照
When NOT to Use
- 新功能開發(用 TDD 流程)
- 已有充分測試的模組
- 純 bug fix 且根因明確
Characterization Test 生命週期
Characterization tests 不是永久存在的,有明確三段生命週期:
- 鎖定(Lock):寫 characterization test,執行確認 GREEN → 行為已鎖定
- 重構(Refactor):安全重構目標程式碼,測試持續 GREEN 代表行為不變
- 提取(Extract):重構完成後,抽出 pure unit test 承接輸出契約;characterization test 可退役或保留為回歸
典型路徑:
LegacyClassCharacterizationTest(鎖定原始行為)→ 抽出XxxNormalizer→XxxNormalizerTest(pure unit 承接)→ characterization test 退役
工作流程
Phase 1: 行為盤點
- 閱讀目標檔案,列出所有公開方法
- 識別外部依賴(DB query、外部 API、全域 state、singleton)
- 標記高風險方法(涉及金額、付款、庫存、資料寫入)
- 確認既有測試覆蓋狀況
- Render surface 盤點:當某功能使先前恆為空的欄位開始存放真實資料時,列出消費該欄位的所有 render surface(畫面/編輯、列印、匯出),不僅是編輯/API 路徑 — 未被任何測試演練的 surface 可能藏有列印排版錯位等潛在格式 bug
- 產出方法清單 + 依賴清單
格式:
| 方法 | 行數 | 依賴 | 風險等級 | 現有測試 |
|------|------|------|---------|---------|
| actionCheckout | 45-120 | DB, PaymentAPI | HIGH | 無 |
| calcDiscount | 30-55 | 無 | LOW | 無 |
大型 class(trait-heavy / 數千行)注意事項:
- 不嘗試整體覆蓋;以高風險方法優先
- 多 trait 混入時,明確標記測試覆蓋的是哪個 trait 的行為
- 優先選擇邊界清楚的 public methods,避免深度依賴 HTTP 或 global state
Phase 2: 測試策略選擇
根據依賴類型選擇測試層級:
| 依賴類型 | 建議層級 | 特性 |
|---|---|---|
| 純計算(無外部依賴) | Unit test | 最快、最穩定 |
| 需要 DB,但可 mock | Unit test + stub | 隔離 DB,測試邏輯 |
| 需要真實 DB 讀寫 | Integration test | 使用 transaction rollback 隔離 |
| 需要外部 API | Integration/Unit + mock | mock 外部 API,觀察本地邏輯 |
| 需要完整 HTTP 流程 | Functional / E2E | 成本最高,謹慎使用 |
選擇原則:盡量往上移(unit 優先),只有在真正需要真實環境時才選 integration/functional。
What ships with it
3 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.
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.
- yesterday Changed · +1 lines c408b77413f2
- 1mo ago First seen · 237 lines · 108 tokens per session scan A 5038b17c2eb2
dhpk-legacy-characterization-tests is a skill published in the GitHub repository hmj1026/dhpk (2 stars, last pushed today), licensed MIT. It adds 108 tokens to every session and 2,802 once invoked, about $0.0004 per session on Opus 5.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-05.
Other skills, from other repositories
verify
A four-layer check for deciding whether a software feature is truly finished: code checks, runtime tests, end-to-end tests, and user-reported confirmation.
validation-sample
A skill for building a reference test set of 50–100 realistic scenarios for checking an agent or product. It separates user inputs from expected answers to prevent answer leakage and requires at least 90% before shipping.
opsx:tdd
Adds a TDD gate to OpenSpec — write REAL failing tests from specs//.md before implementation. Run after opsx:propose and before opsx:apply. Solid RED — never expect.fail placeholders.
evaluator-write-qa-parallel
Internal Auto-Harness evaluator skill for parallel sprint QA and QA report writing. Use only inside the Evaluator subagent during evaluatorqaparallel.
evaluator-write-qa
Internal Auto-Harness evaluator skill for sprint QA and QA report writing. Use only inside the Evaluator subagent during qa mode.
evaluator-write-retest-parallel
Internal Auto-Harness evaluator skill for parallel sprint retest and retest report writing. Use only inside the Evaluator subagent during evaluatorretestparallel.