Test driven development

From workspace-dex/open-agent · View interactive version

Test driven development is an AI agent skill from the GitHub repository workspace-dex/open-agent. Red-Green-Refactor: write tests first, then code to make them pass.

How to use this skill

Skill file

Test-Driven Development

The Cycle

1. RED    → Write failing test
2. GREEN  → Write minimal code to pass
3. REFACTOR → Clean up while keeping tests green

When to Use TDD

How to Write Tests

1. Name Clearly

def test_user_can_login_with_valid_credentials():
    ...

def test_login_fails_with_wrong_password():
    ...

2. Test One Thing

3. AAA Pattern

def test_something():
    # Arrange
    setup_state()
    
    # Act
    result = do_something()
    
    # Assert
    assert result == expected

4. Meaningful Assertions

# Bad
assert user.is_valid()

# Good  
assert user.has_permission("read")
assert user.email_verified == True

Common Mistakes

Quick Wins

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.