red-green-refactor

red-green-refactor is a skill for Claude Code, Codex from rohitg00/skillkit. It costs 90 tokens per session (1,319 once invoked), scanned A, original, Apache-2.0.

A test-driven development method in which you write a failing test, add the smallest implementation that passes it, and then improve the code while keeping tests passing.

In plain words
What is it for?
Use it to develop features, fix bugs, or change behavior by following the red, green, and refactor steps.
Why use it?
It makes the required behavior explicit before implementation and helps catch regressions during refactoring.

Skill for Claude CodeCodex

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/rohitg00/skillkit/red-green-refactor
Any agent
npx skills add rohitg00/skillkit --skill red-green-refactor
Clone the repo
git clone --depth 1 https://github.com/rohitg00/skillkit

Made for: Claude Code, 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 red-green-refactor

README.md
[![agentmods](https://agentmods.dev/badge/skills/rohitg00/skillkit/red-green-refactor.svg)](https://agentmods.dev/skills/rohitg00/skillkit/red-green-refactor)
Your own site
<a href="https://agentmods.dev/skills/rohitg00/skillkit/red-green-refactor"><img src="https://agentmods.dev/badge/skills/rohitg00/skillkit/red-green-refactor.svg" alt="Measured on agentmods" height="20"></a>
Per session 90 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,319 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.00090 $0.01319
Opus 5 $0.00045 $0.00660
Sonnet 5 $0.00018 $0.00264
Haiku 4.5 $0.00009 $0.00132

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

Security

Grade A, and why

red-green-refactor 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 4d 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.

packages/core/src/methodology/packs/testing/red-green-refactor/SKILL.md · 169 lines

How it starts

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

Red-Green-Refactor Methodology

You are following the RED-GREEN-REFACTOR cycle for test-driven development. Every new feature, bug fix, or behavior change starts with a failing test.

The Cycle

1. RED Phase — Write a Failing Test

  1. Understand the requirement — what specific behavior must exist?
  2. Write one test asserting that behavior
  3. Run the test — it MUST fail (red)
  4. Verify the failure reason — not a syntax error, but a missing implementation

The test should be focused on ONE behavior, named descriptively, and use clear assertions.

Executable example (Jest):

// calculateTotal.test.js
const { calculateTotal } = require('./calculateTotal');

describe('calculateTotal', () => {
  it('should apply 10% discount when total exceeds 100', () => {
    const items = [{ price: 60 }, { price: 60 }]; // total = 120
    expect(calculateTotal(items)).toBe(108); // 120 * 0.90
  });
});

Running this now produces: Cannot find module './calculateTotal' — correct RED state.


2. GREEN Phase — Make the Test Pass

Write the minimum code needed to pass the test. Don't add anything extra.

// calculateTotal.js
function calculateTotal(items) {
  const total = items.reduce((sum, item) => sum + item.price, 0);
  return total > 100 ? total * 0.9 : total;
}
module.exports = { calculateTotal };

Run the test — it passes. GREEN achieved. Stop here; resist adding more logic.


3. REFACTOR Phase — Improve the Code

With a passing test as your safety net, clean up the implementation. Run tests after every change.

// calculateTotal.js — refactored for clarity
const DISCOUNT_THRESHOLD = 100;
const DISCOUNT_RATE = 0.9;

function calculateTotal(items) {
  const subtotal = items.reduce((sum, { price }) => sum + price, 0);
  return subtotal > DISCOUNT_THRESHOLD ? subtotal * DISCOUNT_RATE : subtotal;
}
module.exports = { calculateTotal };

Test still passes — GREEN maintained. Constants now communicate intent.


Read the full file on GitHub · 169 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. 4d ago First seen · 169 lines · 90 tokens per session scan A a20e71fb1428

Subscribe to this mod's changes

red-green-refactor is a skill published in the GitHub repository rohitg00/skillkit (1,480 stars, last pushed 3mo ago), licensed Apache-2.0. It adds 90 tokens to every session and 1,319 once invoked, about $0.0005 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

tdd

Use this skill to practice test-driven development — writing tests before implementation, using tests to drive design, and validating implementation against pre-written tests. Activates when implementing new functionality, refactoring code, or fixing bugs where regression coverage is needed.

karthikrshet/aiskills · 53 tokens

regression-test

Classify an iOS/Swift bug into its Apple-specific root-cause class (force unwrap, try!, fatalError, MainActor isolation, App Group mismatch, lifecycle) and sweep for sibling instances of that class. Complements a generic TDD/debugging skill (e.g. superpowers:test-driven-development, superpowers:systematic-debugging)…

markdavidgan/apple-dev-skills · 110 tokens

workflow-patterns

Systematic task implementation using TDD, phase checkpoints, and structured commits. Ensures quality through red-green-refactor cycles, 80% coverage gates, and verification protocols before proceeding.

wpank/ai · 41 tokens

test-driven-development

TDD: enforce RED-GREEN-REFACTOR, tests before code.

mateaix/mateclaw · 20 tokens

superpowers-zh

Use when constraining AI coding with Chinese TDD methodology, systematic debugging, code review, and verification workflows. Superpowers-zh: Chinese adaptation of the Superpowers AI-assisted programming skills and methodologies.

znlgis/opengis-skills · 45 tokens

drill-tdd

Use when implementing any feature or bugfix — enforces the Red-Green-Refactor drill with no production code allowed without a failing test first.

kucherenko/gangsta · 34 tokens