# Pagerguild Guilde Plugins Tdd Red Phase

> TDD Red Phase: Write Failing Tests First

- Skill: `tomevault-io/pagerguild-guilde-plugins-tdd-red-phase` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/pagerguild-guilde-plugins-tdd-red-phase`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/pagerguild-guilde-plugins-tdd-red-phase/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/pagerguild-guilde-plugins-tdd-red-phase

---


# TDD Red Phase: Write Failing Tests First

You are in the **RED** phase of Test-Driven Development.

## Your Goal

Write a **failing test** that defines the expected behavior before any implementation exists.

## Red Phase Rules

1. **Test First**: Write the test BEFORE any implementation code
2. **Must Fail**: The test MUST fail initially (proves it's not trivially passing)
3. **One Behavior**: Each test should verify ONE specific behavior
4. **Descriptive Name**: Test name should describe the expected behavior

## Test Naming Convention

```
test_<function>_<scenario>_<expected_result>

Examples:
- test_user_create_valid_input_returns_user
- test_order_calculate_with_discount_applies_percentage
- test_auth_login_wrong_password_returns_401
```

## Test Structure (AAA Pattern)

```python
def test_feature_scenario_expected():
    # Arrange - Set up test data and preconditions
    input_data = {...}

    # Act - Execute the code under test
    result = function_under_test(input_data)

    # Assert - Verify the expected outcome
    assert result == expected_value
```

## Language-Specific Test Files

| Language | Test File Pattern | Example |
|----------|------------------|--------|
| Go | `*_test.go` | `user_test.go` |
| Python | `test_*.py` | `test_user.py` |
| TypeScript | `*.test.ts` | `user.test.ts` |
| Rust | `tests/*.rs` or inline `#[cfg(test)]` | `tests/user.rs` |

## Workflow

1. **Identify the behavior** to implement
2. **Write the test** that verifies this behavior
3. **Run the test** - it MUST fail (red)
4. **Verify failure reason** - should fail because code doesn't exist yet

## Commands

```bash
# Set phase to RED
bash scripts/tdd-enforcer.sh phase red

# Check current phase
bash scripts/tdd-enforcer.sh phase

# Run tests (expect failure)
bash scripts/tdd-enforcer.sh run <file>
```

## After Red Phase

Once your test is written and **failing for the right reason**:

```bash
# Move to GREEN phase
bash scripts/tdd-enforcer.sh phase green
```

Then write the minimal implementation to make the test pass.

## Common Mistakes to Avoid

- Writing implementation before tests
- Writing tests that pass immediately (trivial tests)
- Testing multiple behaviors in one test
- Vague test names like `test_user` or `test_1`

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/pagerguild) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-16 -->

