test-driven-development

A set of rules for Test-Driven Development (TDD), a method where you write a failing test before writing the code that should pass it.

In plain words
What is it for?
It guides work on helpers, business rules, calculations, validators, game rules, and other reusable or critical C++ code through the Red-Green-Refactor cycle.
Why use it?
It reduces the risk of implementing critical logic without a clear check for its expected behavior.

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/stramp/lost-mines-phandelver/test-driven-development
Clone the repo
git clone --depth 1 https://github.com/Stramp/Lost-Mines-Phandelver

Made for: Cursor.

Per session 4,668 This file is loaded in full into every session.
When invoked 4,668 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.04668 $0.04668
Opus 5 $0.02334 $0.02334
Sonnet 5 $0.00934 $0.00934
Haiku 4.5 $0.00467 $0.00467

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

Security

Grade A, and why

test-driven-development 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.

.cursor/rules/test-driven-development.mdc · 569 lines

How it starts

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

🧪 Test-Driven Development (TDD) Rule

🎯 Objetivo

ALWAYS seguir o paradigma Test-Driven Development (TDD) para código crítico e reutilizável, garantindo que testes sejam escritos ANTES da implementação, seguindo o ciclo Red-Green-Refactor.

🚨 REGRA PRINCIPAL - TEST-FIRST 🚨

ALWAYS escrever testes ANTES da implementação quando:

  • Criando nova função helper/utility (em Utils/ ou Helpers/)
  • Implementando lógica de negócio (cálculos, validações, transformações)
  • Criando novos motores (*Motor.cpp - PointBuy, Multiclass, RaceBonus)
  • Criando novos validators (*Validator.cpp)
  • Adicionando cálculos complexos (modificadores, proficiências, atributos)
  • Implementando regras de negócio (regras D&D, multiclassing, point buy)
  • Refatorando código crítico (escrever testes primeiro para garantir comportamento)

NEVER implementar código crítico sem testes correspondentes.

🔄 O Ciclo Red-Green-Refactor

1. Red: Escrever Teste que Falha

ALWAYS começar escrevendo o teste que define o comportamento esperado:

// ✅ CORRETO - Teste primeiro
BEGIN_DEFINE_SPEC(FPointBuyMotorSpec, "MyProject2.CreateSheet.PointBuy",
                  EAutomationTestFlags::ProductFilter | EAutomationTestFlags::ApplicationContextMask)
    FPointBuyMotor* Motor;
END_DEFINE_SPEC(FPointBuyMotorSpec)

void FPointBuyMotorSpec::Define()
{
    Describe("CalculatePointBuyCost", [this]()
    {
        It("deve calcular custo correto para score 15 (9 pontos)", [this]()
        {
            // Arrange
            int32 Score = 15;

            // Act
            int32 Result = FPointBuyMotor::CalculatePointBuyCost(Score);

            // Assert
            TestEqual("Custo para score 15 deve ser 9", Result, 9);
        });
    });
}

Por que começar pelo teste:

  • Define o contrato antes da implementação
  • Força pensar na interface primeiro
  • Garante que o teste pode detectar erros
  • Confirma que a infraestrutura de teste funciona

Read the full file on GitHub · 569 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. 2d ago First seen · 569 lines · 4,668 tokens per session scan A 16e437da49fa

Subscribe to this mod's changes

test-driven-development is a cursor rule published in the GitHub repository Stramp/Lost-Mines-Phandelver (2 stars, last pushed 9mo ago), licensed MIT. It adds 4,668 tokens to every session, about $0.0233 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-31.