green

A guide for the Green phase of test-driven development (TDD), where you write the smallest amount of code needed to make one failing test pass. TDD is a cycle of writing a test, making it pass, and then improving the code.

In plain words
What is it for?
Use it to analyze one failing test, add only the required implementation, run the tests, and postpone optimization or cleanup until later.
Why use it?
It prevents you from building extra features before they are required. The focus stays on a simple implementation that satisfies the current test.

Command for Claude Code

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 commands/marcoemrich/agentic_coding_lab/green
Clone the repo
git clone --depth 1 https://github.com/marcoemrich/agentic_coding_lab

Made for: Claude Code.

Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 930 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 88% copy Near-identical to another mod 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.00000 $0.00930
Opus 5 $0.00000 $0.00465
Sonnet 5 $0.00000 $0.00186
Haiku 4.5 $0.00000 $0.00093

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

Security

Grade A, and why

green 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.

Origin

This is a copy

88% identical to green — 7 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

experiments/runs/2026-05-03_04-15-52_mars-rover-prose_v5-exact-single-context_haiku-4-5/.claude/commands/green.md · 135 lines

How it starts

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

TDD Green Phase

You are now in the Green Phase of TDD. Follow these instructions to make the failing test pass with MINIMAL code.

Your Mission

  1. Implement the minimal code necessary to make the failing test pass
  2. Use the simplest possible solution (hardcoded values are acceptable)
  3. Avoid adding features for future tests
  4. Verify all tests pass
  5. NO optimization, NO refactoring yet

Context: $ARGUMENTS

Green Phase Rules

  • Minimal code only: Just enough to pass the current test
  • Baby steps: Make the smallest possible change
  • No future features: Don't implement what future tests might need
  • Simple is better: Hardcoded returns are perfectly fine
  • Tests must pass: Verify all tests are green
  • No refactoring yet: Save improvements for Refactor phase

Process

Step 1: Analyze the Failing Test

Understand what the test expects:

  • What input does the test provide?
  • What output does it expect?
  • What is the simplest way to produce that output?

Step 2: Write Minimal Implementation

Implement only what's needed to make the current test pass:

// For first test "should return 0 for empty input":
export const calculate = (input: string): number => {
  return 0; // Minimal - just make the test pass
};

// For second test "should return number for single input":
export const calculate = (input: string): number => {
  if (input === "") return 0;
  return parseInt(input); // Still simple
};

// For third test "should add two numbers":
export const calculate = (input: string): number => {
  if (input === "") return 0;
  const numbers = input.split(",");
  if (numbers.length === 1) return parseInt(numbers[0]);
  return parseInt(numbers[0]) + parseInt(numbers[1]); // Only now add logic
};

Step 3: Run Tests

Run pnpm test:unit:basic and verify:

  • Current test now passes ✅
  • All previous tests still pass ✅

Step 4: Verify No Over-Implementation

Check yourself:

  • ❓ Did I implement features for future tests? → Remove them
  • ❓ Did I add logic not demanded by current test? → Remove it
  • ❓ Did I optimize prematurely? → Simplify
  • ❓ Did I refactor existing code? → Revert, save for Refactor phase

Read the full file on GitHub · 135 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 · 135 lines · 0 tokens per session scan A 2b6cdd5a8d00

Subscribe to this mod's changes

green is a command published in the GitHub repository marcoemrich/agentic_coding_lab (11 stars, last pushed 15d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 930 tokens. A static security scan graded it A with 0 findings. It is 88% identical to green, differing in 7 lines, and is treated as a copy.