test-driven-development

test-driven-development is a skill for Claude Code, Codex from thoughtbot/rails-consultant. It costs 68 tokens per session (3,940 once invoked), scanned A, original, MIT.

A strict test-first workflow for Ruby on Rails applications. TDD means writing a failing test, adding the smallest code that makes it pass, then improving the code.

In plain words
What is it for?
Use it when adding features, fixing bugs, refactoring, or changing how a Rails application behaves.
Why use it?
It helps catch incorrect behavior early and keeps changes tied to clearly described results.

Skill for Claude CodeCodex

Part of the rails-consultant plugin — 12 skills shipped together

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 skills/thoughtbot/rails-consultant/test-driven-development
Any agent
npx skills add thoughtbot/rails-consultant --skill test-driven-development
Clone the repo
git clone --depth 1 https://github.com/thoughtbot/rails-consultant

Made for: Claude Code, Codex.

Or install rails-consultant, the plugin that ships this one along with the rest of its 12 skills.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/thoughtbot/rails-consultant/test-driven-development.svg)](https://agentmods.dev/skills/thoughtbot/rails-consultant/test-driven-development)
Your own site
<a href="https://agentmods.dev/skills/thoughtbot/rails-consultant/test-driven-development"><img src="https://agentmods.dev/badge/skills/thoughtbot/rails-consultant/test-driven-development.svg" alt="Measured on agentmods" height="20"></a>
Per session 68 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,940 The whole file, excluding the scripts and references it only reads on demand.
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.00068 $0.03940
Opus 5 $0.00034 $0.01970
Sonnet 5 $0.00014 $0.00788
Haiku 4.5 $0.00007 $0.00394

Measured 3d ago against content hash 03dcf33a19b9, 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 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.

skills/test-driven-development/SKILL.md · 494 lines

How it starts

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

Test-Driven Development (TDD)

Overview

Write the test first. Watch it fail. Write minimal code to pass.

Core principle: If you didn't watch the test fail, you don't know if it tests the right thing.

Violating the letter of the rules is violating the spirit of the rules.

The Iron Law

NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST

Write code before the test? Delete it. Start over.

No exceptions:

  • Don't keep it as "reference"
  • Don't "adapt" it while writing tests
  • Don't look at it
  • Delete means delete

Implement fresh from tests. Period.

Outside-In Development

Start every feature with a high-level test that describes behavior from the user's perspective. Run it, read the failure, and let that failure dictate your next move. As failures push you down the stack, write a new failing test at each layer you drop into — never write code for a layer without a failing test at that layer demanding it.

Read examples/outside-in-testing.md for a walkthrough of the philosophy and examples/testing-pyramid.md for how test types combine into an optimal suite.

One Change, One Run

After every change — writing a test, adding a route, creating a file, implementing a method — run the affected test immediately:

bundle exec rspec spec/features/guest_searches_for_items_spec.rb

The failure message is your instruction for what to do next. Don't batch changes and don't guess ahead: one change, one run, read the failure, decide. If you made two changes before running, you no longer know which one the test is reacting to.

Drop Down by Writing the Next Failing Test

A failure rarely means "write this exact line." It usually means "the layer below isn't there yet." When the active test's failure points to a layer that has behavior of its own — a controller action, an endpoint, a model method — drop down and write a failing test at that layer before building it.

Think of it as a stack of failing tests:

  • The active test is the one whose failure you're reading right now.
  • Its failure points to a missing lower layer → write a new failing test at that layer. It becomes the active test.
  • Drive that test with Red-Green-Refactor. If it forces you down another level, push another failing test.
  • When the active test goes green, pop it: rerun the test one layer up. Its next failure drives the next move.

Read the full file on GitHub · 494 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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 · 494 lines · 68 tokens per session scan A 03dcf33a19b9

Subscribe to this mod's changes

test-driven-development is a skill published in the GitHub repository thoughtbot/rails-consultant (23 stars, last pushed 1mo ago), licensed MIT. It adds 68 tokens to every session and 3,940 once invoked, about $0.0003 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.

Related

Other skills, from other repositories

upgrade-cleanup

Clean up after (or abandon) a Rails upgrade. Drop NextRails.next? and NextRails.current? branches and retire dual-boot scaffolding (Gemfile.next, Gemfile.next.lock, conditional Gemfile groups), keeping either the next or the current version. Trigger when the user says they are done with the upgrade, want to clean up…

ombulabs/claude-code_rails-upgrade-skill · 139 tokens

recursive-decomposition

Handle tasks that exceed the context window by decomposing them: size and filter the input, chunk it, run recursive sub-agents on independent parts, verify on small windows, and synthesise programmatically, following the Recursive Language Models (RLM) research by Zhang, Kraska and Khattab (2025). Use when a task…

massimodeluisa/recursive-decomposition-skill · 151 tokens

typescript-react-nextjs-patterns

Production-grade TypeScript reference for React & Next.js frontend development. Covers type narrowing, component Props, generic hooks, discriminated unions, as const, satisfies, Zod validation, TanStack Query, server/client boundaries, forms, state management, performance, accessibility, debugging, and code review.…

leejpsd/typescript-react-nextjs-patterns · 142 tokens

swarm

Run a multi-agent audit of a codebase by spawning specialized parallel subagents (security, performance, tests, architecture, dead-code), then synthesize their findings into a single prioritized action plan. Use this whenever the user runs /swarm, asks to "audit the repo," "review this codebase," "find issues across…

Zintellix/Claude-Skills · 138 tokens

crisp-execute

CRISP Execute — Sprint execution loop with change request management, security gates, product gates, and stakeholder reporting. Use after Phase S (Spec) is complete and crisp-state.json shows readyforexecute: true. Triggers on "start sprint", "begin build", "execute", "sprint 1", "run sprints", or when handed off from…

radekamirko/C.R.I.S.P · 82 tokens

phase1-clarify

The Mileva Method (CRISP) — Phase 1: Clarify. Problem definition, eliciting, painkiller test, buy vs build, AI justification gate, Go/No-Go. Use at the start of any AI implementation project. Triggers on "clarify", "phase 1", "start discovery", "define the problem", "what problem are we solving", or at the beginning…

radekamirko/C.R.I.S.P · 93 tokens