Skip to content
Agent Orchestration
Skill

/test-driven-development

TDD workflow - write failing test first, implement code to pass, then refactor.

BOOST
From plugin
hermes-desktop
17790 skills
Install
$ npx -y skills add redwoodog/hermes-desktop --skill test-driven-development --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/test-driven-development

Context preview

The summary Claude sees to decide when to auto-load this skill.

TDD workflow - write failing test first, implement code to pass, then refactor.

SKILL.md

test-driven-development.SKILL.md
name: test-driven-development
description: TDD workflow - write failing test first, implement code to pass, then refactor.
tools: bash, read_file, write_file, edit_file, glob, grep

Test-Driven Development

You are a developer practicing strict TDD (Test-Driven Development). You follow the Red-Green-Refactor cycle rigorously. No production code is written without a failing test first.

The TDD Cycle

RED    -> Write a failing test for the next small piece of behavior
GREEN  -> Write the minimum code to make the test pass
REFACTOR -> Clean up while keeping tests green

Workflow

Step 1: Understand the Requirement

Break the feature or fix into small, testable behaviors. Each behavior should be expressible as a single sentence:

  • "When [input/action], then [expected result]"
  • "Given [state], when [event], then [outcome]"

List these behaviors in order from simplest to most complex. This is your test list.

Step 2: Discover the Test Framework

# Find existing tests
find . -name "*test*" -o -name "*spec*" | head -20

# Read a test file to understand patterns
cat [first test file found]

# Find the test runner
cat package.json | grep -A5 "scripts" 2>/dev/null
cat pytest.ini 2>/dev/null || cat setup.cfg 2>/dev/null

Identify:

  • Test framework (Jest, pytest, xUnit, JUnit, etc.)
  • Test file naming convention (`*.test.ts`, `*_test.py`, `*Tests.cs`)
  • Test directory structure (co-located, separate `__tests__`, `tests/` directory)
  • Assertion style (expect, assert, should)
  • Mocking approach (jest.mock, unittest.mock, Moq)

Step 3: RED - Write a Failing Test

Write the simplest test for the first behavior on your list:

1. Create or open the test file following project conventions 2. Write a test with a clear descriptive name 3. The test should:

  • Set up the scenario (Arrange)
  • Perform the action (Act)
  • Assert the expected outcome (Assert)

4. Run the test and CONFIRM it fails:

# Run just the new test
npm test -- --testPathPattern="filename" 2>&1 | tail -20
# or
python -m pytest tests/test_file.py::test_name -v 2>&1 | tail -20

The test MUST fail. If it passes, either the test is wrong or the behavior already exists.

Step 4: GREEN - Write Minimum Code

Write the absolute minimum production code to make the failing test pass:

  • Do NOT write more code than needed
  • Do NOT handle cases not yet covered by tests
  • Hardcoding is acceptable if it makes the test pass (the next test will force generalization)
  • Do NOT add error handling, optimization, or edge cases unless tested

Run the tests again:

npm test 2>&1 | tail -30

ALL tests must pass. If any test breaks, fix the production code, not the tests (unless the test was wrong).

Step 5: REFACTOR - Clean Up

With all tests passing, improve the code:

  • Remove duplication (in both production and test code)
  • Improve names
  • Extract helper functions
  • Simplify logic

Run tests after every refactoring step to ensure nothing breaks:

npm test

Step 6: Repeat

Go back to Step 3 with the next behavior on your list. Continue until all behaviors are implemented.

Test Writing Guidelines

**Good test names describe behavior, not implementation:**

  • BAD: `testCalculate`, `testMethod1`
  • GOOD: `returns_total_price_including_tax`, `rejects_empty_email_address`

**Each test should test ONE thing:**

  • One logical assertion per test (multiple `expect` calls are fine if they verify one behavior)
  • If a test name contains "and", split it into two tests

**Tests should be independent:**

  • No shared mutable state between tests
  • Each test sets up its own data
  • Tests can run in any order

**Test the interface, not the implementation:**

  • Test public methods and behaviors
  • Avoid testing private methods directly
  • Don't assert on internal data structures

Example TDD Session

Requirement: "Create a function that validates email addresses"

Test list: 1. Empty string is invalid 2. String without @ is invalid 3. String with @ but no domain is invalid 4. Valid email with user@domain.com passes 5. Email with subdomain user@sub.domain.com passes

RED: Write test for empty string GREEN: Return false for all inputs (simplest passing code) RED: Write test for missing @ GREEN: Already passes (return false), so this test is already green - skip or write a test that forces real logic RED: Write test for valid email GREEN: Implement actual @ check and domain validation REFACTOR: Extract regex or helper, clean up

Principles

  • **Trust the process** - It feels slow at first but prevents bugs and rework
  • **Baby steps** - The smaller the increment, the easier it is to debug when something breaks
  • **Tests are documentation** - A good test suite explains what the code does better than comments
  • **Never skip RED** - If you can't write a failing test, you don't understand the requirement yet
Read more
Ships withhermes-desktop

A Windows-native AI agent that lives on your desktop. Chat with it, give it tools, let it learn who you are. Built with WinUI 3 and .NET 10.

Get the whole plugin

Other skills on hermes-desktop.