Skip to content
Skillv1.0.0

tdd

Red-green-refactor TDD using vertical slices — tests specify observable behavior through public interfaces

by akillness(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from akillness/jeo-skills (.agent-skills/tdd/SKILL.md). Install upstream with npx skills add akillness/jeo-skills --skill tdd. Copyright stays with the author.

TDD — Test-Driven Development

Build features and fix bugs using the test-first red-green-refactor cycle. Tests specify observable behavior through public interfaces — they survive internal refactors.

Core philosophy

Tests should verify behavior through public interfaces, not implementation details.

Good tests read like specifications. They tell you what the system does, not how it does it.

When to use this skill

  • User requests test-first development or red-green-refactor
  • Building new features where behavior should drive design
  • Fixing bugs where a regression test should come first
  • Any work where test design should precede implementation

When not to use this skill

  • Writing tests after implementation → use testing-strategies
  • Debugging existing failures → use debugging or diagnose
  • Broad test-policy decisions → use testing-strategies

Anti-pattern: horizontal slices

❌ Write all tests upfront before any implementation.

This produces tests that verify imagined behavior, not actual behavior. They become insensitive to real changes because they were written before design decisions were made.

Correct approach: vertical slices

✅ One test → minimal implementation → repeat.

Each slice is a thin cut through the full behavior. Completed slices are independently demoable.

Workflow

Step 1 — Planning

Before writing any code:

  • Confirm the interface design with the user
  • Identify which behaviors matter most (prioritize)
  • Get approval on the test approach before coding

Step 2 — Tracer bullet

Write the first test for the most important behavior:

RED: write a failing test for one behavior
GREEN: write the minimum code to make it pass
COMMIT: the behavior is now specified and verified

The tracer bullet proves the test infrastructure works and establishes the pattern.

Step 3 — Incremental loop

Repeat for each subsequent behavior:

RED → GREEN → (optional REFACTOR) → next RED

Rules:

  • Write only enough code to pass the current test
  • Do not anticipate future requirements
  • Each test must fail before the implementation exists
  • Each test must pass after the minimal implementation

Step 4 — Refactor

After all behaviors are tested and passing:

  • Extract duplication into shared helpers
  • Deepen modules (simple interface, rich behavior)
  • Run tests after each refactor step
  • Never refactor while tests are red

Per-cycle checklist

Before moving to the next cycle, verify the test:

  • Describes observable behavior (not implementation internals)
  • Uses only public interfaces
  • Would survive an internal refactor of the implementation
  • Fails for the right reason before implementation
  • Passes with minimal, non-speculative code

Example

// RED: write the failing test first
test('formats currency with symbol', () => {
  expect(formatCurrency(1000, 'USD')).toBe('$1,000.00')
})

// GREEN: write minimal passing code
function formatCurrency(amount: number, currency: string): string {
  return new Intl.NumberFormat('en-US', {
    style: 'currency',
    currency,
  }).format(amount)
}

// REFACTOR if needed, then move to next behavior

Instructions

  1. Identify the task trigger and expected output.
  2. Follow the workflow steps in this skill from top to bottom.
  3. Validate outputs before moving to the next step.
  4. Capture blockers and fallback path if any step fails.

Examples

  • Example: Apply this skill to a small scope first, then scale to full scope after validation passes.

Best practices

  • Keep outputs deterministic and auditable.
  • Prefer small reversible changes over broad risky edits.
  • Record assumptions explicitly.

References

  • Project standards: .agent-skills/skill-standardization/SKILL.md
  • Validator script: .agent-skills/skill-standardization/scripts/validate_skill.sh

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/akillness-jeo-skills-tdd/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

akillness-jeo-skills-tdd.ocm.jsonjson
{
  "ocm": "1",
  "id": "akillness-jeo-skills-tdd",
  "kind": "skill",
  "name": "tdd",
  "description": "Red-green-refactor TDD using vertical slices — tests specify observable behavior through public interfaces",
  "publisher": "akillness",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding"
    ],
    "tags": [
      "skill-md",
      "tdd",
      "test-driven-development",
      "red-green-refactor",
      "vertical-slices",
      "behavior-verification",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Red-green-refactor TDD using vertical slices — tests specify observable behavior through public interfaces"
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/akillness/jeo-skills",
      "path": ".agent-skills/tdd/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/akillness/jeo-skills/blob/HEAD/.agent-skills/tdd/SKILL.md",
      "key": "akillness/jeo-skills/.agent-skills/tdd/SKILL.md"
    },
    "compatibility": "Language-agnostic. Works for unit, integration, and component tests. Best for new feature development and bug fixes. Not for writing test suites after the fact (use testing-strategies) or for debuggin",
    "allowed_tools": [
      "Read",
      "Grep",
      "Glob",
      "Bash",
      "Write",
      "Edit"
    ]
  },
  "instructions": "# TDD — Test-Driven Development\n\nBuild features and fix bugs using the test-first red-green-refactor cycle. Tests specify observable behavior through public interfaces — they survive internal refactors.\n\n## Core philosophy\n\n> Tests should verify behavior through public interfaces, not implementation details.\n\nGood tests read like specifications. They tell you *what* the system does, not *how* it does it.\n\n## When to use this skill\n\n- User requests test-first development or red-green-refactor\n- Building new features where behavior should drive design\n- Fixing bugs where a regression test should",
  "cost": {
    "context_tokens": 969
  }
}

Fetch it by URL: GET /api/v1/registry/akillness-jeo-skills-tdd/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.