ワンクリックで
tdd-workflow
Test-Driven Development workflow for PortKit. Follows RED-GREEN-REFACTOR cycle with explicit task tracking.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Test-Driven Development workflow for PortKit. Follows RED-GREEN-REFACTOR cycle with explicit task tracking.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Run interactive brainstorming across verifiers environments, evaluations, GEPA, and RL training. Use when the user wants ideation, literature scanning, concept teaching, roadmap planning, or research program design grounded in local CLI sources, verifiers, and RL trainer code.
Discover and inspect verifiers environments through the Prime ecosystem. Use when asked to find environments on the Hub, compare options, inspect metadata, check action status, pull local copies for inspection, or choose environment starting points before evaluation, training, or migration work.
Create or migrate verifiers environments for the Prime Lab ecosystem. Use when asked to build a new environment from scratch, port an eval or benchmark from papers or other libraries, start from an environment on the Hub, or convert existing tasks into a package that exposes load_environment and installs cleanly with prime env install.
Run and analyze evaluations for verifiers environments using prime eval. Use when asked to smoke-test environments, run benchmark sweeps, resume interrupted evaluations, compare models, inspect sample-level outputs, or produce evaluation summaries suitable for deciding next steps.
Audit and optimize verifiers environments for async performance. Use when asked to profile, speed up, or review an environment for concurrency bottlenecks, event loop blocking, or scaling issues under high rollout counts.
Optimize environment system prompts with GEPA through prime gepa run. Use when asked to improve prompt performance without gradient training, compare baseline versus optimized prompts, run GEPA from CLI or TOML configs, or interpret GEPA outputs before deployment.
| name | tdd-workflow |
| description | Test-Driven Development workflow for PortKit. Follows RED-GREEN-REFACTOR cycle with explicit task tracking. |
| version | 1.0.0 |
| author | PortKit Team |
Test-Driven Development following best-practice AI agent patterns.
┌─────────────────────────────────────────────────────────┐
│ TDD Cycle │
├─────────────────────────────────────────────────────────┤
│ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ RED │ → │ GREEN │ → │ REFACTOR │ → loop │
│ └─────────┘ └─────────┘ └─────────┘ │
│ │
│ Write Make it Improve │
│ failing pass code │
│ test │
└─────────────────────────────────────────────────────────┘
cat .factory/tasks.md
Add to .factory/tasks.md:
## In Progress
- 🔄 TDD: Implement {feature_name}
## Pending
- ⏳ TDD: Write RED test for {feature}
- ⏳ TDD: Implement GREEN code for {feature}
- ⏳ TDD: REFACTOR code for {feature}
# tests/unit/test_<feature>.py
class TestFeatureName:
"""RED: Write test BEFORE implementation."""
async def test_<scenario>_<expected>(self):
"""Test that feature does X when Y."""
# ARRANGE - Set up test data
# ACT - Call the function
# ASSERT - Verify expected behavior
# Start with the SIMPLEST passing case
# Then add edge cases
assert result == expected
Key Rules for RED:
test_user_create_duplicate_email_raises_errorRule: Write MINIMUM code to make test pass. No optimization yet.
# Implementation - Keep it SIMPLE
async def process_feature(input_data: InputModel) -> OutputModel:
# Direct implementation, no over-engineering
return OutputModel(result=input_data.value)
Anti-patterns in GREEN:
❌ Don't add logging yet
❌ Don't add validation yet (unless test requires it)
❌ Don't optimize - just make it work
❌ Don't add features not tested
Now that tests exist, you CAN:
async def process_feature(input_data: InputModel) -> OutputModel:
# Now add proper error handling
if not input_data.value:
raise ValueError("Value cannot be empty")
# Add logging
logger.info(f"Processing feature: {input_data.value}")
# Return result
return OutputModel(result=input_data.value)
}
"""
Unit tests for {module_name}.
Tests follow TDD RED-GREEN-REFACTOR cycle.
See: .skills/tdd-workflow/SKILL.md
"""
import pytest
from src.services.example import ExampleService
class TestExampleService:
"""Tests for ExampleService."""
@pytest.fixture
def service(self):
"""Service instance with mocked dependencies."""
return ExampleService()
test_<feature>_<scenario>_<expected>
Examples:
- test_user_create_success_returns_user
- test_user_create_duplicate_email_raises_conflict
- test_user_get_by_id_not_found_returns_none
- test_conversion_job_timeout_triggers_retry
# ✅ CORRECT - Mock at dependency boundary
@pytest.fixture
def mock_db():
with patch("src.services.user_service.get_db") as mock:
yield mock
# ❌ WRONG - Mock implementation internals
@pytest.fixture
def mock_user():
with patch("src.models.user.User.name", "test"):
yield mock_user
# Run tests for a module (TDD loop)
cd backend && python3 -m pytest src/tests/unit/test_<module>.py -v
# Run single test
cd backend && python3 -m pytest src/tests/unit/test_<module>.py::TestClass::test_name -v
# Run with coverage
cd backend && python3 -m pytest src/tests/unit/test_<module>.py --cov=src.services.<module>
# Run all unit tests (before commit)
cd backend && python3 -m pytest src/tests/unit/ -q --tb=no
Before marking task complete:
❌ Write implementation BEFORE tests (Test-After)
❌ Skip tests to "save time"
❌ Test implementation details (brittle tests)
❌ Mock everything (integration test for complex flows)
❌ Single massive test (split into focused tests)
When implementing with TDD:
Create:
src/tests/unit/test_<feature>.py - Testssrc/services/<feature>.py - ImplementationModify:
src/services/__init__.py - Export new servicesrc/api/<feature>.py - API endpoints (after tests pass).factory/tasks.md - Update task status