bug-fix-tdd-guard

bug-fix-tdd-guard is a cursor rule for Cursor from TashanGKD/tashan-cursor-skills. It costs 128 tokens per session (2,155 once invoked), scanned A, original, MIT.

A rule for fixing software bugs with test-driven development, or TDD: first reproduce the bug, then write a test that fails, then make the smallest code change that passes it, and finally run the full checks.

In plain words
What is it for?
Use it when fixing a tracked bug or a priority bug. It guides reproduction, failure-test creation, minimal repair, full CI testing, and bug-tracker updates.
Why use it?
It prevents guesswork, fixes that do not really solve the bug, missing regression tests, unrelated refactoring, and forgotten tracker updates.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it when fixing a tracked bug or a priority bug. It guides reproduction, failure-test creation, minimal repair, full CI testing, and bug-tracker updates.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/tashangkd/tashan-cursor-skills/bug-fix-tdd-guard
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.

Clone the repo
git clone --depth 1 https://github.com/TashanGKD/tashan-cursor-skills

Made for: Cursor.

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 bug-fix-tdd-guard

README.md
[![agentmods](https://agentmods.dev/badge/rules/tashangkd/tashan-cursor-skills/bug-fix-tdd-guard/github.svg)](https://agentmods.dev/rules/tashangkd/tashan-cursor-skills/bug-fix-tdd-guard)
Your own site
<a href="https://agentmods.dev/rules/tashangkd/tashan-cursor-skills/bug-fix-tdd-guard"><img src="https://agentmods.dev/badge/rules/tashangkd/tashan-cursor-skills/bug-fix-tdd-guard/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 bug-fix-tdd-guard

Your own site · 80×15
<a href="https://agentmods.dev/rules/tashangkd/tashan-cursor-skills/bug-fix-tdd-guard"><img src="https://agentmods.dev/badge/rules/tashangkd/tashan-cursor-skills/bug-fix-tdd-guard.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 128 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,155 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.00128 $0.02155
Opus 5 $0.00064 $0.01077
Sonnet 5 $0.00026 $0.00431
Haiku 4.5 $0.00013 $0.00215

Measured 10d ago against content hash 90c0bb0d1d8b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

bug-fix-tdd-guard 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 10d 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.

rules/bug-fix-tdd-guard.mdc · 194 lines

How it starts

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

TDD 修复约束(bug-fix-tdd-guard)

核心问题:修复 Bug 时最容易犯的错误:

  1. 猜测性修复(没复现就改代码)→ 假修复,Bug 还在
  2. 没有回归测试 → 同一个 Bug 几周后复活
  3. 借机重构 → 修一个出另一个
  4. 修完没更新追踪台 → 协调者不知道状态变了

触发条件

以下任一条满足,且任务为开发类(修复代码):

  • 对话上下文包含「修复Bug」「fix bug」「TC-XXX」「BUG-YYYYMMDD-NN」
  • 当前任务来自 bug-fix-loop-coordinator 的 dispatch
  • 用户说「修复追踪台里的XX」「帮我修一下TC-XXX」
  • 开发角色激活时上下文有「P0修复」「P1修复」等字样

激活后立即执行(强制序列,不可跳过任何步骤)

Step F1 【先复现,不要动代码】
        在本地/测试环境稳定复现该 Bug:
        - 执行追踪台中记录的复现步骤
        - 确认能稳定触发(不是偶发的flaky)
        
        IF 无法复现:
          → 不要修改任何代码
          → 更新追踪台:「复现失败,更新复现步骤需要确认」
          → 告知 bug-fix-loop-coordinator:「TC-XXX 无法复现,需要更多信息」
          → 停止

Step F2 【写失败测试(RED)——在改代码之前】
        编写能捕获到这个 Bug 的测试用例:
        - 测试必须在修复前失败(证明捕获了问题)
        - 测试粒度:尽量选单元测试或集成测试,不要写E2E(太慢,太脆)
        - 测试命名:test_fix_TC_XXX_[bug描述简写]
        
        运行测试,确认它失败:
        IF 测试通过(没有失败):
          → 说明测试没有捕获到Bug,重新设计测试
          → 不允许进入 Step F3
          
        证明测试捕获到Bug后,继续。

Step F3 【写最小修复代码(GREEN)】
        原则(来自调研文档 TECH-008):
        ✅ 只改让测试通过所需的最少代码
        ✅ 只在明确需要修改的地方改动
        ❌ 禁止:借机重构无关代码
        ❌ 禁止:一次修复多个Bug(每个Bug独立执行)
        ❌ 禁止:修改超出该Bug影响范围的代码
        
        写完后运行测试:
        IF 测试仍然失败:
          → 检查修复逻辑,重新分析根因
          → 最多3次尝试,仍不通过则标记「需人工介入」

Step F4 【全量CI回归(必须通过才能继续)】
        运行全量测试套件:
        - Layer 0(无LLM):所有单元测试 + 集成测试
        - Layer 1(有LLM,时间允许时):核心链路
        
        IF 有其他测试失败(影响半径):
          → 分析是否是本次改动引起
          → 是 → 修复相关代码,确保不破坏已有功能
          → 不是(flaky test)→ 记录,不阻止,继续
        
        IF CI 全绿:继续 Step F5

Step F5 【更新技术问题追踪台(必须执行)】
        Read: 项目群/[项目]/技术架构师/技术问题追踪台.md
        
        将对应Bug条目的状态更新为:
        「已修复([日期],修复说明:[一句话说明改了什么],TDD证据:测试文件路径)」
        
        IF 找不到对应条目:
          → 向 bug-fix-loop-coordinator 报告异常

Step F6 【向修复记录追加条目】
        Append to: 项目群/[项目]/内部总控/修复记录.md
        
        格式(见 bug-fix-loop-coordinator Step 3.5 的格式模板):
        - Bug ID
        - 根因(一句话)
        - 修复内容
        - TDD证据(失败测试路径 + 通过证明)
        - CI状态

Step F7 【通知协调者】
        输出给 bug-fix-loop-coordinator:
        「✅ TC-XXX 修复完成
         - 失败测试:[测试路径]
         - 修复文件:[文件路径]
         - CI状态:全绿
         - 追踪台已更新
         
         等待回归测试验证。」

Read the full file on GitHub · 194 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. 10d ago First seen · 194 lines · 128 tokens per session scan A 90c0bb0d1d8b

Subscribe to this mod's changes

bug-fix-tdd-guard is a cursor rule published in the GitHub repository TashanGKD/tashan-cursor-skills (20 stars, last pushed 5mo ago), licensed MIT. It adds 128 tokens to every session and 2,155 once invoked, about $0.0006 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-30.