brainstorming
Structured design dialogue that validates ideas before implementation begins.
green-phase
Implement minimal code to make failing tests pass (GREEN phase of TDD). Write just enough code to pass tests, no more. Use after red-phase when tests are failing.
Full skill instructions
Skill Type: Actuator (TDD Workflow) Purpose: Write minimal code to make failing tests pass (GREEN phase) Prerequisites:
You are in the GREEN phase of TDD (RED → GREEN → REFACTOR).
Your goal is to write MINIMAL code to make the failing tests pass.
Key principle: Write the simplest code that works. Do NOT over-engineer. Refactoring comes later.
Read the test file to understand:
Example:
# tests/auth/test_login.py shows we need:
- login(email: str, password: str) -> LoginResult
- LoginResult with fields: success, user, error
- Email validation (BR-001)
- Password length validation (BR-002)
- Account lockout logic (BR-003)
Follow project conventions:
Python:
tests/auth/test_login.py → src/auth/login.py
tests/services/test_payment.py → src/services/payment.py
TypeScript:
src/auth/login.test.ts → src/auth/login.ts
src/services/payment.test.ts → src/services/payment.ts
Java:
src/test/java/auth/LoginTest.java → src/main/java/auth/Login.java
Write the simplest code that makes tests pass:
# src/auth/login.py
# Implements: <REQ-ID>
# Business Rules: BR-001, BR-002, BR-003
import re
from dataclasses import dataclass
from typing import Optional
from datetime import datetime, timedelta
@dataclass
class LoginResult:
success: bool
user: Optional['User'] = None
error: Optional[str] = None
class User:
def __init__(self, email: str, password_hash: str):
self.email = email
self.password_hash = password_hash
self.failed_attempts = 0
self.locked_until: Optional[datetime] = None
def check_password(self, password: str) -> bool:
# Simplified: In real code, use bcrypt
return self.password_hash == hash_password(password)
# Implements: <REQ-ID>
def login(email: str, password: str) -> LoginResult:
# Implements: BR-001 (email validation)
if not validate_email(email):
return LoginResult(success=False, error="Invalid email format")
# Implements: BR-002 (password minimum length)
if len(password) < 12:
return LoginResult(success=False, error="Password must be at least 12 characters")
# Get user from database (simplified)
user = get_user_by_email(email)
if not user:
return LoginResult(success=False, error="User not found")
# Implements: BR-003 (account lockout)
if user.locked_until and datetime.now() < user.locked_until:
return LoginResult(success=False, error="Account locked. Try again in 15 minutes")
# Check password
if not user.check_password(password):
user.failed_attempts += 1
# Implements: BR-003 (lock after 3 attempts)
if user.failed_attempts >= 3:
user.locked_until = datetime.now() + timedelta(minutes=15)
return LoginResult(success=False, error="Invalid password")
# Success - reset failed attempts
user.failed_attempts = 0
user.locked_until = None
return LoginResult(success=True, user=user)
# Implements: BR-001 (email validation)
def validate_email(email: str) -> bool:
pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
return re.match(pattern, email) is not None
def hash_password(password: str) -> str:
# Simplified: In real code, use bcrypt
return str(hash(password))
def get_user_by_email(email: str) -> Optional[User]:
# Simplified: In real code, query database
# For now, return mock user for testing
return User(email, hash_password("SecurePass123!"))
Key implementation principles:
Run the test suite:
# Python
pytest tests/auth/test_login.py -v
# TypeScript/JavaScript
npm test src/auth/login.test.ts
# Java
mvn test -Dtest=LoginTest
Expected output:
tests/auth/test_login.py::test_login_with_valid_credentials PASSED ✓
tests/auth/test_login.py::test_login_fails_with_invalid_email PASSED ✓
tests/auth/test_login.py::test_login_fails_with_short_password PASSED ✓
tests/auth/test_login.py::test_account_locked_after_3_failed_attempts PASSED ✓
4 tests passed in 0.12s
✅ All tests PASSING! This is what we want in GREEN phase.
⚠️ If tests still FAIL: Fix implementation and retry until all tests pass.
Check coverage:
# Python
pytest --cov=src/auth tests/auth/test_login.py --cov-report=term-missing
# TypeScript
npm test -- --coverage
# Java
mvn test jacoco:report
Expected: Coverage should be high (aim for 80%+ overall, 100% for critical paths).
Create commit with implementation:
git add src/auth/login.py
git commit -m "GREEN: Implement <REQ-ID>
Implement user login functionality with email/password.
Implements:
- <REQ-ID>: User login
- BR-001: Email validation (regex pattern)
- BR-002: Password minimum 12 characters
- BR-003: Account lockout after 3 failed attempts (15min)
Tests: 4 tests passing ✓
Coverage: 95%
"
Commit message format:
GREEN:When you complete the GREEN phase, show:
[GREEN Phase - <REQ-ID>]
Implementation: src/auth/login.py
Code Created:
✓ LoginResult dataclass
✓ User class
✓ login() function (<REQ-ID>)
✓ validate_email() function (BR-001)
✓ hash_password() helper
✓ get_user_by_email() helper
Business Rules Implemented:
✓ BR-001: Email validation (regex)
✓ BR-002: Password minimum 12 characters
✓ BR-003: Account lockout after 3 attempts
Running tests...
tests/auth/test_login.py::test_login_with_valid_credentials PASSED ✓
tests/auth/test_login.py::test_login_fails_with_invalid_email PASSED ✓
tests/auth/test_login.py::test_login_fails_with_short_password PASSED ✓
tests/auth/test_login.py::test_account_locked_after_3_failed_attempts PASSED ✓
Result: 4/4 tests PASSING ✓ (GREEN phase)
Coverage: 95% (38/40 lines covered)
Commit: GREEN: Implement <REQ-ID>
✅ GREEN Phase Complete!
Next: Invoke refactor-phase skill to improve code quality
Before invoking this skill, ensure:
If prerequisites not met:
red-phase skill firstAfter GREEN phase completes:
refactor-phase skill to improve code quality and eliminate tech debt# First implementation (naive, but works)
def login(email: str, password: str) -> LoginResult:
if email == "[email protected]" and password == "SecurePass123!":
return LoginResult(success=True)
return LoginResult(success=False)
Then improve to handle more cases until all tests pass.
Implement code to pass one test at a time:
test_login_with_valid_credentials passtest_login_fails_with_invalid_email passtest_login_fails_with_short_password passtest_account_locked_after_3_failed_attempts passStart with hard-coded values, then generalize:
# Step 1: Hard-coded (passes one test)
def validate_email(email: str) -> bool:
return email == "[email protected]"
# Step 2: Generalize (passes all tests)
def validate_email(email: str) -> bool:
pattern = r'^[a-zA-Z0-9._%+-]+@...'
return re.match(pattern, email) is not None
❌ Over-engineering: Don't add features not tested ❌ Premature optimization: Don't optimize before refactor phase ❌ Perfect code: Don't worry about code quality yet (refactor phase handles this) ❌ Skipping tests: All tests must pass before moving to refactor ❌ Adding untested code: Every line should be tested
✅ Do this instead:
Why minimal implementation?
GREEN phase mantra: "Make it work, then make it right"
Homeostasis Goal:
desired_state:
tests_passing: true
all_requirements_implemented: true
code_coverage: >= 80%
"Excellence or nothing" 🔥
Structured design dialogue that validates ideas before implementation begins.
Comprehensive design intelligence for web and mobile UI/UX across 10 technology stacks.
Comprehensive implementation plans for multi-step tasks, breaking down specs into bite-sized, testable steps.
Introduction to the obra skills system with mandatory skill invocation rules and best practices.
Execute a written implementation plan with critical review and task checkpoints.
Delegate independent tasks to specialized agents working concurrently with isolated context.
Isolated git worktrees with smart directory selection and safety verification.
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
Plan searchable and shareable content that drives traffic, builds authority, and generates leads.
README-first repository scanner that extracts commands and classifies reproduction candidates without executing them.
Brainstorm and prioritize marketing strategies tailored to your SaaS stage, budget, and goals.
Plan and optimize your website's page hierarchy, navigation, URL structure, and internal linking.
The world's fastest calendar for remote work
Capture, organize, and utilize your knowledge effortlessly.
Instant Summaries of Audio & Video Interviews with AnySummary
Transform PDFs into engaging mind maps.
Chat with any PDF instantly
Create an optimal daily plan using your voice
A productivity platform to centralize organizational knowledge and workflows with contextual AI assistance.
AskYourPDF Pricing Plans: Tailored to Your Needs