test-coverage-guard

test-coverage-guard is a cursor rule for Cursor from TashanGKD/tashan-cursor-skills. It costs 90 tokens per session (1,242 once invoked), scanned A, original, MIT.

A testing rule that checks whether every planned test has a recorded status before an agent says testing is complete. It uses a coverage-state file listing tests as pending or otherwise accounted for.

In plain words
What is it for?
Use it in a testing workflow to block completion or deployment claims while tests remain pending, and to require reasons for skipped tests.
Why use it?
Running a test script does not necessarily cover every test required by the specification. This rule prevents unfinished tests from being treated as completed.

Cursor rule for Cursor

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

Good fit Use it in a testing workflow to block completion or deployment claims while tests remain pending, and to require reasons for skipped tests.

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

README.md
[![agentmods](https://agentmods.dev/badge/rules/tashangkd/tashan-cursor-skills/test-coverage-guard.svg)](https://agentmods.dev/rules/tashangkd/tashan-cursor-skills/test-coverage-guard)
Your own site
<a href="https://agentmods.dev/rules/tashangkd/tashan-cursor-skills/test-coverage-guard"><img src="https://agentmods.dev/badge/rules/tashangkd/tashan-cursor-skills/test-coverage-guard.svg" alt="Measured on agentmods" height="20"></a>
Per session 90 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,242 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.00090 $0.01242
Opus 5 $0.00045 $0.00621
Sonnet 5 $0.00018 $0.00248
Haiku 4.5 $0.00009 $0.00124

Measured 8d ago against content hash 93046ff85807, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

test-coverage-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 8d 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/test-coverage-guard.mdc · 113 lines

How it starts

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

测试覆盖完整性守门规则(test-coverage-guard)

核心问题:测试智能体把「执行了可执行脚本」等价于「完成了测试规格文档要求的所有测试」。 这两者不等价——脚本是文档的子集,而不是全集。


触发条件

以下任一条件出现,立即触发此规则(在输出之前检查):

  • 输出内容含「测试完成」「测试通过」「测试结束」
  • 输出内容含「等待你的决策」「等待上线」「可以上线」
  • 输出内容含「进入 DevOps」「触发 DevOps」
  • 输出内容含「关卡C 通过」「通过」(在测试语境中)

触发后立即执行(输出之前)

Step 1: 查找覆盖状态文件
  Glob: 项目群/[项目]/测试工程师/test-coverage-state.md
  
  IF 文件不存在:
    → 这意味着 Step 0.4 没有执行(覆盖基线未建立)
    → 输出:「⛔ [test-coverage-guard] 覆盖状态文件不存在。
              测试在未建立覆盖基线的情况下运行,无法验证完整性。
              请先执行 Step 0.4(测试覆盖基线建立),重新开始测试。」
    → 停止当前声明,等待处理
  
  IF 文件存在:继续 Step 2

Step 2: 统计待执行项目
  Read: test-coverage-state.md
  提取所有状态为「🔲待执行」的行
  pending_count = 🔲状态行数
  
  IF pending_count > 0:
    → 禁止当前「测试完成」声明
    → 输出:「⛔ [test-coverage-guard] 测试未全量完成
    
              ⚠️ 仍有 {pending_count} 个测试项目未执行:
              {列出所有🔲待执行的测试ID和描述}
              
              选择:
              A. 立即执行这 {pending_count} 条测试(推荐)
              B. 明确标记为「跳过」并说明理由(需逐条说明)
              C. 请求用户决策(暂停循环)
              
              在此解决之前,不允许进入 DevOps。」
    → 等待处理,不继续当前声明
  
  IF pending_count == 0:
    → 所有测试有明确状态,允许继续
    → 在继续的声明开头附加:
      「✅ [test-coverage-guard] 覆盖验证通过(全部 N 条有明确状态)」

「脚本子集」问题的专项检测

如果检测到以下模式,额外输出警告:

模式:测试智能体执行了 run_tests.py 或 pytest
且:没有对照「测试规格文档」做差集检查

检测到此模式时,输出:
「⚠️ [test-coverage-guard] 检测到「脚本执行」模式:
   run_tests.py/pytest 只是测试规格文档的可执行子集。
   请确认:主测试文档中的所有测试ID是否都已在覆盖状态文件中?
   
   如未验证 → 请先运行 Step 0.4 建立基线并对照差集。」

与现有规则的关系

规则 关系
session-bootstrap.mdc B3.5 本规则是测试版的专项守门,解决测试特有的「脚本≠文档」问题
role-测试工程师 Step 6.4 本规则是 Step 6.4 的前置守门,在 Skill 层的门禁之前提供 Rule 层保障
role-测试工程师 Step 0.4 本规则依赖 Step 0.4 生成的 test-coverage-state.md

变更记录

v1.0 — 2026-03-25 — 初始创建

根因: 对话 53b74d66(项目架构文档编写,753条消息)事后分析发现: 测试智能体在 Message 745 宣布「测试完成,等待你的决策」,但实际上有 26 个测试用例未执行(Layer 3 AI质量、E2E完整链路、幂等性等)。根本原因是:

  1. 没有「执行了多少 = 文档要求了多少」的校验机制
  2. 长对话导致记忆压缩,AI 忘记了文档要求的全量测试项目
  3. Skill 层的 Step 6.5 DevOps门禁已有,但缺少「测试完整性」专项门禁

本规则作为 Rule 层(比 Skill 层更早触发)的守门,从根本上阻断「未全量测试→声称完成」的行为链。

Read the full file on GitHub · 113 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. 8d ago First seen · 113 lines · 90 tokens per session scan A 93046ff85807

Subscribe to this mod's changes

test-coverage-guard is a cursor rule published in the GitHub repository TashanGKD/tashan-cursor-skills (20 stars, last pushed 5mo ago), licensed MIT. It adds 90 tokens to every session and 1,242 once invoked, about $0.0005 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.