tdd-skill

tdd-skill is a cursor rule for Codex from KaelSensei/MagicAIBuilder. It costs 642 tokens per session, scanned A, original, MIT.

A set of rules for test-driven development (TDD), a method where you write a failing test before the code that makes it pass. It guides an AI agent through testing, implementation, and later refactoring.

In plain words
What is it for?
Use it when building software one behavior at a time with automated tests. It helps define a small test, implement the smallest clean solution, and then refine the design separately.
Why use it?
It keeps each change focused and prevents the agent from adding unneeded abstractions or future features. It also separates making the test pass from deeper design improvements.

Cursor rule for Codex

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/kaelsensei/magicaibuilder/tdd-skill
Clone the repo
git clone --depth 1 https://github.com/KaelSensei/MagicAIBuilder

Made for: Codex.

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 tdd-skill

README.md
[![agentmods](https://agentmods.dev/badge/rules/kaelsensei/magicaibuilder/tdd-skill.svg)](https://agentmods.dev/rules/kaelsensei/magicaibuilder/tdd-skill)
Your own site
<a href="https://agentmods.dev/rules/kaelsensei/magicaibuilder/tdd-skill"><img src="https://agentmods.dev/badge/rules/kaelsensei/magicaibuilder/tdd-skill.svg" alt="Measured on agentmods" height="20"></a>
Per session 642 This file is loaded in full into every session.
When invoked 642 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.00642 $0.00642
Opus 5 $0.00321 $0.00321
Sonnet 5 $0.00128 $0.00128
Haiku 4.5 $0.00064 $0.00064

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

Security

Grade A, and why

tdd-skill 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 5d 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.

.agents/rules/tdd-skill.mdc · 74 lines

How it starts

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

TDD Skill

TDD follows Kent Beck's short feedback loop. With an AI agent, the Green step is more deliberate: do not ask for intentionally dirty code and plan a cleanup pass. Ask for the smallest production-quality implementation that satisfies the test, then reserve deeper design changes for a separate refining refactor.

Cycle: Red -> Super Green -> Refining Refactoring

1. Red

  1. State one observable behavior and one reason it matters.
  2. Add the smallest deterministic test that expresses that behavior.
  3. Run that focused test and confirm it fails for the expected reason.

The test is the scope boundary. Do not add future enum values, factories, interfaces, abstractions, or error cases that no current test requires.

2. Super Green

Implement only enough behavior to pass the new test and preserve existing tests. The implementation should already be production-clean in its local context:

  • Use names, boundaries, and placement that are correct now.
  • Keep the diff small and avoid speculative generalization.
  • Follow the project's type, error-handling, accessibility, and performance rules.
  • Preserve the existing public contract unless the test explicitly changes it.

Super Green does not mean advanced design or skipping the TPP. Progress behavior in small steps: constant -> scalar -> invariant -> conditional -> loop. Clean code and behavioral complexity are separate axes.

3. Refining Refactoring

Refactor only after the focused and regression tests are green. Keep behavior unchanged, make one coherent design improvement at a time, and rerun the tests after each meaningful step. Refactoring may deepen the design, clarify a domain boundary, or remove duplication; it is not a required second pass for code that was deliberately written badly.

Test Boundary

Prefer sociable tests at the stable public boundary: a use case, route handler, store action, or component behavior with real in-process collaborators. Verify observable outcomes rather than private calls or implementation details.

Read the full file on GitHub · 74 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. 5d ago First seen · 74 lines · 642 tokens per session scan A ce5f915bf5db

Subscribe to this mod's changes

tdd-skill is a cursor rule published in the GitHub repository KaelSensei/MagicAIBuilder (2 stars, last pushed 3d ago), licensed MIT. It adds 642 tokens to every session, about $0.0032 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.