unit-test-coverage-95

unit-test-coverage-95 is a cursor rule for Cursor from AlphaBitCore/nexus-gateway. It costs 766 tokens per session, scanned A, original, Apache-2.0.

A binding rule requiring each Go package in the project's packages directory to reach at least 95% statement test coverage, unless it has an approved exception.

In plain words
What is it for?
Use it when adding or changing Go code to run coverage checks, review the exception list, and justify any package that cannot meet the target.
Why use it?
It stops commits and continuous-integration checks from accepting packages whose tested behavior falls below the project's required threshold.

Cursor rule 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 rules/alphabitcore/nexus-gateway/unit-test-coverage-95
Clone the repo
git clone --depth 1 https://github.com/AlphaBitCore/nexus-gateway

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 unit-test-coverage-95

README.md
[![agentmods](https://agentmods.dev/badge/rules/alphabitcore/nexus-gateway/unit-test-coverage-95.svg)](https://agentmods.dev/rules/alphabitcore/nexus-gateway/unit-test-coverage-95)
Your own site
<a href="https://agentmods.dev/rules/alphabitcore/nexus-gateway/unit-test-coverage-95"><img src="https://agentmods.dev/badge/rules/alphabitcore/nexus-gateway/unit-test-coverage-95.svg" alt="Measured on agentmods" height="20"></a>
Per session 766 This file is loaded in full into every session.
When invoked 766 The same file — it is already loaded in full.
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.00766 $0.00766
Opus 5 $0.00383 $0.00383
Sonnet 5 $0.00153 $0.00153
Haiku 4.5 $0.00077 $0.00077

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

Security

Grade A, and why

unit-test-coverage-95 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 3d 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.

.cursor/rules/unit-test-coverage-95.mdc · 52 lines

How it starts

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

Unit test coverage ≥95% (binding)

Canonical text lives in CLAUDE.md. This rule is the IDE-side surfacing; when this file disagrees with CLAUDE.md, CLAUDE.md wins.

The rule

Every Go package in packages/** must hit ≥95% statement coverage under go test -cover -count=1 ./..., OR be listed in scripts/.coverage-allowlist with a concrete category and rationale.

Enforcement

  • Pre-commit hook runs scripts/check-go-coverage.sh --staged on the Go packages with staged changes. Blocks the commit if any non-exempt package falls below 95%.
  • Full sweep runs npm run check:coverage (also covered by npm run check:all). CI is wired to fail on threshold misses.
  • Strict-allowlist mode: scripts/check-go-coverage.sh --strict-allowlist flags allowlisted packages that have since reached the threshold and can be removed from the file.

Allowlist policy

Adding a package to scripts/.coverage-allowlist requires:

  1. Explicit user approval in chat (echo the reason before committing).
  2. One of these categories in the trailing comment:
    • (A) cmd/* entry point — only main() wiring, no logic.
    • (B) Test helper (e.g. bufconn, testutil, idptest, storetest).
    • (C) DB-bound — tests require live PostgreSQL.
    • (D) OS-bound — tests need kernel APIs / system keychain / packet capture.
    • (E) Network-infra-bound — tests need real S3 / NATS / Redis Sentinel.
    • (F) Integration-only — existing tests live behind build tags.

Packages that are currently below threshold but on the open-source readiness roadmap may be allowlisted under the "Open-source readiness backlog" section, with a follow-up reference. The long-term goal is an empty allowlist.

Writing tests that count

Tests must assert observable business behavior and named failure modes — not just exercise code paths. Coverage padding (calling a function only to bump the percentage without assertions, or asserting only err == nil) defeats the rule's purpose.

Read the full file on GitHub · 52 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. 3d ago First seen · 52 lines · 766 tokens per session scan A bacf88369ba0

Subscribe to this mod's changes

unit-test-coverage-95 is a cursor rule published in the GitHub repository AlphaBitCore/nexus-gateway (22 stars, last pushed 8d ago), licensed Apache-2.0. It adds 766 tokens to every session, about $0.0038 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.