Back to list
doanchienthangdev

developing-test-driven

by doanchienthangdev

Omega Vibecode Kit

2🍴 1📅 Jan 21, 2026

SKILL.md


name: developing-test-driven description: AI agent practices test-first development with the Red-Green-Refactor cycle for confident, well-designed code. Use when implementing features, fixing bugs, or establishing testing practices. category: methodology related_skills:

  • methodology/test-enforcement
  • methodology/test-task-generation
  • testing/vitest
  • testing/pytest related_commands:
  • /dev:tdd
  • /dev:feature-tested
  • /dev:test-write
  • /quality:verify-done

Developing Test-Driven

Quick Start

  1. Red - Write a failing test that defines desired behavior
  2. Green - Write minimal code to make the test pass
  3. Refactor - Improve code while keeping tests green
  4. Repeat - Continue with next behavior (1-5 minute cycles)

Features

FeatureDescriptionGuide
Red-Green-RefactorCore TDD cycleFail -> Pass -> Improve -> Repeat
Test PatternsEffective test structuresArrange-Act-Assert, Given-When-Then
Test FixturesReusable test setupbeforeEach, factories, builders
Mocking StrategiesIsolate dependenciesInject deps, mock boundaries only
Parameterized TestsTest multiple inputsit.each for input variations
Coverage AnalysisVerify thoroughnessStatements, branches, functions

Common Patterns

// RED-GREEN-REFACTOR CYCLE

// RED: Write failing test
it('rejects passwords shorter than 8 characters', () => {
  const result = validatePassword('short');
  expect(result.valid).toBe(false);
  expect(result.errors).toContain('Password must be at least 8 characters');
});

// GREEN: Minimal implementation
function validatePassword(password: string) {
  const errors = [];
  if (password.length < 8) {
    errors.push('Password must be at least 8 characters');
  }
  return { valid: errors.length === 0, errors };
}

// REFACTOR: Extract rules (tests stay green)
const rules = [
  { test: (p) => p.length >= 8, message: 'Must be 8+ chars' },
  { test: (p) => /[A-Z]/.test(p), message: 'Must have uppercase' },
];
function validatePassword(password: string) {
  const errors = rules.filter(r => !r.test(password)).map(r => r.message);
  return { valid: errors.length === 0, errors };
}
// ARRANGE-ACT-ASSERT Pattern
it('increases total when item added', () => {
  // ARRANGE
  const cart = new ShoppingCart();
  const item = { id: '1', price: 10.00 };

  // ACT
  cart.addItem(item);

  // ASSERT
  expect(cart.total).toBe(10.00);
});

// PARAMETERIZED TESTS
it.each([
  ['simple@example.com', true],
  ['user.name@domain.org', true],
  ['invalid', false],
  ['@nodomain.com', false],
])('validates %s as %s', (email, expected) => {
  expect(isValidEmail(email)).toBe(expected);
});

// BUILDER PATTERN for test data
const user = new UserBuilder().admin().inactive().build();
# Mocking Guidelines
MOCK (external boundaries):
- External APIs (payment, email)
- Third-party services
- System clock, random
- Network requests

DON'T MOCK (your code):
- Pure functions
- Data transformations
- Business logic
- Internal services
# Coverage Analysis
| Type | Target | Notes |
|------|--------|-------|
| Statements | 80%+ | Code executed |
| Branches | 70%+ | If/else paths |
| Functions | 90%+ | All functions called |

REMEMBER: 100% coverage != well-tested
- Test edge cases
- Test error paths
- Test boundary conditions

Best Practices

DoAvoid
Write test BEFORE implementationWriting implementation first
Keep tests focused on ONE behaviorTesting multiple things in one test
Use descriptive test namesGeneric names like "test1"
Run tests frequently (every few minutes)Long gaps between test runs
Refactor only when tests greenRefactoring with failing tests
Test behavior, not implementationTesting private methods directly
Keep cycles short (1-5 minutes)30+ minute cycles
Mock only external dependenciesOver-mocking your own code

Command Integration

Using TDD Command

# Start TDD workflow
/dev:tdd "user authentication"

# TDD with specific coverage
/dev:tdd "payment processing" --coverage 95

# TDD with specific test types
/dev:tdd "API endpoint" --test-types unit,integration,contract

Configuration

# .omgkit/workflow.yaml
testing:
  enabled: true
  enforcement:
    level: strict  # TDD recommends strict
  coverage_gates:
    unit:
      minimum: 90
      target: 95
  • methodology/test-enforcement - Enforce test completion
  • methodology/test-task-generation - Auto-generate test tasks
  • methodology/testing-anti-patterns - Avoid common test mistakes
  • testing/vitest - Vitest testing framework
  • testing/playwright - E2E testing with Playwright

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon