Borrowing it
Nothing to install: this file belongs to Zenobia000/cursor-agentic-coding-template. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/Zenobia000/cursor-agentic-coding-template/main/.cursor/commands/write-tests.mdgit clone --depth 1 https://github.com/Zenobia000/cursor-agentic-coding-templateWrote 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/commands/zenobia000/cursor-agentic-coding-template/write-tests)<a href="https://agentmods.dev/commands/zenobia000/cursor-agentic-coding-template/write-tests"><img src="https://agentmods.dev/badge/commands/zenobia000/cursor-agentic-coding-template/write-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/commands/zenobia000/cursor-agentic-coding-template/write-tests"><img src="https://agentmods.dev/badge/commands/zenobia000/cursor-agentic-coding-template/write-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.00023 | $0.01328 |
| Opus 5.5 | $0.00009 | $0.00531 |
| Sonnet 5.5 | $0.00005 | $0.00266 |
| Haiku 4.5 | $0.00002 | $0.00133 |
Grade A, and why
write-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 2mo 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.
Copies of this mod
1 near-identical copy found in the catalogue:
- write-tests — 100% identical, 0 lines differ
How it starts
The opening of the file, as written. The whole thing — 75 lines — stays where its author put it; the contents beside it link to each section on GitHub.
🧪 WRITE TESTS MODE (v3)
像烏索普的彈弓一樣,編寫精準、可靠的測試,確保程式碼的每一個角落都堅不可摧。
1. PLAN 🎯 (規劃)
Objective
為一個特定的功能或程式碼模組,設計並寫入一組全面、有效的測試,以鎖定其行為、防止迴歸,並作為可執行的文檔。
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
在開始編寫測試之前,請確保:
- ✅ 程式碼已存在: 需要被測試的產品程式碼已經存在。
- ✅ 行為已定義: 該程式碼的預期行為是清晰的 (來自
memory-bank/current/tasks.md或用戶說明)。 - ❌ Failure Action: 如果不清楚要測試什麼,AI 必須首先提問:「為了編寫有意義的測試,我需要了解
my_function的預期行為。當輸入為null時,它應該拋出錯誤還是返回一個默認值?」
2. DO 実行 (執行)
Core Process
遵循一個策略性的、由外向內的測試編寫流程:
Step 0: 健康檢查 (Health Check)
- 檢查測試環境: 驗證專案的測試框架是否已安裝且可以正常運行。
- 批判性思考: 我應該寫哪種類型的測試?如果這是一個複雜的用戶流程,一個高層的整合測試可能比單元測試更有價值。如果這是一個純粹的演算法,單元測試則是最佳選擇。AI 應能判斷並提出策略。
Step 1: 記憶體互動 - 讀取 (Memory Interaction - Read)
- 讀取需求: 從
memory-bank/current/tasks.md或creative-*.md讀取功能的驗收條件。 - 讀取產品程式碼: 仔細閱讀需要被測試的函數或模組的源碼。
Step 2: 測試策略與案例設計 (Strategy & Case Design)
- 選擇測試類型: 決定編寫單元測試、整合測試還是 E2E 測試。
- 設計測試案例: 系統性地設計測試案例,確保覆蓋:
- Happy Path: 正常、預期的輸入和流程。
- Sad Paths: 已知的錯誤路徑、異常輸入 (如
null)。 - Edge Cases: 邊界值 (如 0, -1, 空字串)。
Step 3: 記憶體互動 - 寫入 (Memory Interaction - Write)
- 確認策略 (Confirm): 對於一個較大的模組,在開始編碼前,可以向用戶確認測試策略。例如:「我計劃為
UserService編寫 5 個單元測試和 1 個整合測試。這個方案可以嗎?」 - 編寫測試程式碼: 在得到用戶同意後,創建或修改對應的測試文件 (e.g.,
*.test.js,test_*.py)。
Step 4: 執行與迭代 (Run & Iterate)
- 運行測試: 執行新編寫的測試,確保它們能夠正確地運行。
- 迭代: 根據測試結果,可能需要返回去修改測試程式碼或產品程式碼。
3. CHECK ✓ (檢查)
Verification Checklist
- 測試已創建: 新的測試文件是否已成功寫入到正確的測試目錄中?
- 測試可運行: 新增的測試是否能被測試運行器發現並成功執行?
- 命名清晰: 測試的描述是否清晰地說明了它在「Given-When-Then」下的行為?
4. ACT 改善 (行動)
Finalization
- 報告結果: 向用戶報告測試編寫已完成,並提供測試結果的摘要。
- 提交程式碼: 將新的測試文件提交到版本控制系統。
Next Steps
測試是信心的來源。
- 👉 Primary Next Step: 如果測試是開發任務的一部分,現在可以執行
/task-next來獲取下一個任務。 - 💡 Alternative: 如果在編寫測試的過程中發現了 Bug,應立即切換到
/debug模式。
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.
- 2mo ago First seen · 75 lines · 23 tokens per session scan A 8a37fa815388
write-tests is a command published in the GitHub repository Zenobia000/cursor-agentic-coding-template (30 stars, last pushed 4mo ago), licensed MIT. It adds 23 tokens to every session and 1,328 once invoked, about $0.0001 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-08-30.
Other commands, from other repositories
test-suite
Run comprehensive test suite with coverage analysis.
gsd:add-tests
Generate tests for a completed phase based on UAT criteria and implementation.
test
Escrever e rodar testes (skill 05 — QA Engineer).
quality-check-command
This command performs comprehensive code quality checks. Use it before commits or when implementation is complete.
test
Load the testing strategies skill for 3-tier testing with NO MOCKING policy enforcement in Tier 2-3.
verify
You are invoking the verify skill - comprehensive verification following Boris Cherny's pattern.