test-driven

test-driven is a cursor rule for Cursor from oakensoul/nextjs-cursor-prompts. It costs 0 tokens per session (1,714 once invoked), scanned A, original, MIT.

A rule that requires test-driven development, a method where you write a failing test, add the smallest code that passes it, and then improve the code.

In plain words
What is it for?
Use it when building critical code that needs a clear specification and high confidence.
Why use it?
It makes the expected behavior explicit before implementation and requires edge cases and error conditions to be tested.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when building critical code that needs a clear specification and high confidence.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/oakensoul/nextjs-cursor-prompts/test-driven
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/oakensoul/nextjs-cursor-prompts

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-driven

README.md
[![agentmods](https://agentmods.dev/badge/rules/oakensoul/nextjs-cursor-prompts/test-driven/github.svg)](https://agentmods.dev/rules/oakensoul/nextjs-cursor-prompts/test-driven)
Your own site
<a href="https://agentmods.dev/rules/oakensoul/nextjs-cursor-prompts/test-driven"><img src="https://agentmods.dev/badge/rules/oakensoul/nextjs-cursor-prompts/test-driven/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 test-driven

Your own site · 80×15
<a href="https://agentmods.dev/rules/oakensoul/nextjs-cursor-prompts/test-driven"><img src="https://agentmods.dev/badge/rules/oakensoul/nextjs-cursor-prompts/test-driven.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,714 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.00000 $0.01714
Opus 5 $0.00000 $0.00857
Sonnet 5 $0.00000 $0.00343
Haiku 4.5 $0.00000 $0.00171

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

Security

Grade A, and why

test-driven 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 6d 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/test-driven.mdc · 234 lines

How it starts

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

Test-Driven Development Rule

This rule enforces a test-first development process for critical code that requires high confidence and clear specification.

🎯 TDD PRINCIPLES:

  1. RED - Write a failing test first
  2. GREEN - Write minimal code to make it pass
  3. REFACTOR - Improve code while keeping tests green
  4. REPEAT - Continue the cycle for each new feature

🚫 FORBIDDEN ACTIONS:

  1. DO NOT write implementation before tests - tests define the specification
  2. DO NOT skip failing test phase - must see red before green
  3. DO NOT write complex logic without tests - break into testable units
  4. DO NOT modify multiple features in one TDD cycle
  5. DO NOT ignore edge cases - test error conditions and boundaries
  6. DO NOT skip refactoring phase - clean up code after each cycle
  7. DO NOT commit failing tests - complete the cycle before committing

REQUIRED TDD PROCESS:

1. DEFINE the specification through tests

  • Write test cases that describe expected behavior
  • Include happy path, edge cases, and error conditions
  • Use descriptive test names that explain the requirement
  • Start with the simplest test case

2. IMPLEMENT minimally to pass tests

  • Write only enough code to make tests pass
  • Avoid over-engineering or premature optimization
  • Keep implementation focused on test requirements
  • Don't add features not covered by tests

3. REFACTOR safely with test coverage

  • Improve code structure while tests remain green
  • Extract functions, improve naming, optimize performance
  • Run tests after each refactoring step
  • Maintain the external interface defined by tests

4. EXTEND incrementally with new test cycles

  • Add one new test for the next requirement
  • Follow the same RED-GREEN-REFACTOR cycle
  • Build complexity gradually through multiple iterations
  • Maintain test coverage as features grow

🎯 WHEN TO APPLY TDD:

High-Value Targets:

  • Business logic functions - calculations, validations, algorithms
  • API endpoints - request/response handling, data transformation
  • Data processing utilities - parsing, formatting, conversion
  • Authentication/authorization - security-critical functionality
  • Integration points - external API clients, database operations

Read the full file on GitHub · 234 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. 6d ago First seen · 234 lines · 0 tokens per session scan A de2831213e1f

Subscribe to this mod's changes

test-driven is a cursor rule published in the GitHub repository oakensoul/nextjs-cursor-prompts (4 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,714 tokens. 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-09-03.