debug

A command for investigating and fixing a known software bug through a structured, test-first process. It requires clear reproduction steps, creates a failing regression test, finds the cause, and verifies the repair.

In plain words
What is it for?
Use it to reproduce a bug, inspect errors and related code, write a failing unit or integration test, repair the cause, and run the relevant checks.
Why use it?
It turns an unclear debugging task into an evidence-based process and leaves a test that checks the bug does not return.

Command for Cursor

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 commands/zenobia000/cursor-agentic-coding-template/debug
Clone the repo
git clone --depth 1 https://github.com/Zenobia000/cursor-agentic-coding-template

Made for: Cursor.

Per session 17 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,149 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.00017 $0.01149
Opus 5 $0.00009 $0.00575
Sonnet 5 $0.00003 $0.00230
Haiku 4.5 $0.00002 $0.00115

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

Security

Grade A, and why

debug 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.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

  • debug — 100% identical, 0 lines differ
.cursor/commands/debug.md · 73 lines

What it actually says

🐛 DEBUG MODE (v3)

像羅賓解讀歷史正文一樣,系統化地解析 Bug,找到根本原因,並徹底修復它。

1. PLAN 🎯 (規劃)

Objective

準確地重現、分析、定位並修復一個已知的 Bug,並寫入一個新的回歸測試 (Regression Test) 來鎖定此 Bug,確保其不再復現。

Guiding Rules

在執行此指令時,AI Agent 必須遵循以下規則:

  • 主要規則: .cursor/rules/principles/global.mdc
  • 測試優先: .cursor/rules/testing/overview.mdc
  • 程式碼品質: .cursor/rules/backend/overview.mdc.cursor/rules/frontend/overview.mdc
  • 核心隔離: .cursor/rules/isolation_rules/main.mdc

Prerequisites Check

在開始除錯之前,請確保:

  • 清晰的 Bug 報告: 已提供預期行為、實際行為、可重現步驟和完整的錯誤訊息。
  • 可運行的環境: 開發環境已就緒,可穩定重現 Bug。
  • Failure Action: 如果重現步驟不清晰,AI 必須首先要求提供更詳細的資訊。

2. DO 実行 (執行)

Core Process

採用測試驅動除錯 (Test-Driven Debugging) 的方法論:

Step 0: 健康檢查 (Health Check)

  • 檢查可重現性: 驗證提供的重現步驟是否真的能觸發 Bug。
  • 批判性思考: 這個 Bug 是穩定出現 (Bohrbug) 還是偶爾出現 (Heisenbug)?如果是後者,AI 應告知用戶這會增加除錯難度,並尋求更多線索。

Step 1: 記憶體互動 - 讀取 (Memory Interaction - Read)

  • 讀取錯誤: 仔細分析錯誤訊息、堆疊追蹤和相關日誌。
  • 讀取程式碼: 閱讀堆疊追蹤中涉及的相關程式碼。

Step 2: 編寫失敗的測試 (Write a Failing Test)

  • 首要目標: 寫入一個新的單元測試或整合測試,該測試能夠精確地重現 Bug。
  • 驗證失敗: 運行此測試,並確認它如預期般失敗

Step 3: 分析與修復 (Analyze & Fix)

  • 形成假設: 基於失敗的測試和程式碼,提出關於 Bug 根本原因的假設。
  • 實驗與定位: 使用日誌、斷點等方式驗證假設,直到定位根本原因。
  • 寫入修復: 修改產品程式碼以修復 Bug。

Step 4: 驗證修復 (Verify the Fix)

  • 運行測試: 再次運行在 Step 2 中編寫的測試,確認它現在能夠通過
  • 運行全量測試: 運行整個專案的測試套件,確保修復沒有引入任何迴歸問題。

3. CHECK ✓ (檢查)

Verification Checklist

  • 回歸測試已添加: 是否已創建了一個新的、能夠捕獲此 Bug 的測試?
  • 所有測試通過: 整個測試套件是否都已成功運行?
  • 根本原因已找到: 是否明確了 Bug 的根本原因?

4. ACT 改善 (行動)

Finalization

  • 向用戶確認: 在修改產品程式碼之前,可以先向用戶展示失敗的測試和計劃中的修復方案。
  • 提交修復: 將修復程式碼和新的測試作為一個原子提交到版本控制系統。

Next Steps

Bug 修復是提升系統健壯性的絕佳機會。

  • 👉 Primary Next Step: 繼續執行 /implement/task-next 來處理下一個任務。
  • 💡 Alternative: 如果此 Bug 暴露了某個模組的設計缺陷,可以執行 /creative 來為該模組的重構進行技術設計。

DEBUG MODE (v3) 已啟動。正在檢查可重現性,準備編寫失敗的測試...

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 · 73 lines · 17 tokens per session scan A 2d3b84eb79ea

Subscribe to this mod's changes

debug is a command published in the GitHub repository Zenobia000/cursor-agentic-coding-template (30 stars, last pushed 2mo ago), licensed MIT. It adds 17 tokens to every session and 1,149 once invoked, about $0.0001 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.