Xpersona
T

TDD Workflow

CLAWHUB · Unverified

Test-driven development workflow enforcing 80%+ code coverage with unit, integration, and E2E tests. Write tests first, validate RED state, implement minimal... Skill: TDD Workflow Owner: djc00p Summary: Test-driven development workflow enforcing 80%+ code coverage with unit, integration, and E2E tests. Write tests first, validate RED state, implement minimal... Tags: latest:1.0.0 Version history: v1.0.0 | 2026-04-05T23:01:29.469Z | user Initial release. TDD workflow enforcing 80%+ coverage with git checkpoints. Adapted from everything-claude-code by @affaan-m (MIT) Archive

62
Rank
84
Safety
1.1k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.1K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17akx17qd32yxnr1065qq0kdd83h2c3:tdd-workflow
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-djc00p-tdd-workflow/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

9,830 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: tdd-workflow
description: "Test-driven development workflow enforcing 80%+ code coverage with unit, integration, and E2E tests. Write tests first, validate RED state, implement minimally, validate GREEN, then refactor. Use when writing features, fixing bugs, or refactoring. Trigger phrases: write tests, TDD, test-driven, feature implementation, bug fix. Adapted from everything-claude-code by @affaan-m (MIT)"
metadata: {"clawdbot":{"emoji":"✅","requires":{"bins":["npm","git"],"env":[]},"os":["darwin","linux","win32"]}}
---

# Test-Driven Development Workflow

Ensure all code development follows TDD principles with 80%+ code coverage.

## When to Activate

- Writing new features or functionality
- Fixing bugs or issues
- Refactoring existing code
- User says "write tests", "add specs", "how should I test this"

## Quick Start

1. Write user journey in acceptance-test format ("As a [role], I want...")
2. Generate test cases (happy path + edge cases + errors)
3. Run tests → verify RED state (must fail before implementation)
4. Implement minimal code to make tests pass → GREEN state
5. Refactor while keeping tests green
6. Verify 80%+ coverage achieved

## Key Concepts

- **Tests before code** — Write tests first, then implementation
- **RED-GREEN-REFACTOR** — Fail → Pass → Improve (no exceptions)
- **80% coverage minimum** — Unit, integration, and E2E combined
- **Unit-level isolation** — Mock dependencies, test behavior not implementation
- **Independent tests** — No test ordering dependencies; each can run solo

## Common Usage

Most frequent patterns:
- Unit tests for functions and components
- Integration tests for API endpoints and database operations
- E2E tests for critical user flows
- Edge case and error path testing
- Fast execution (unit tests < 50ms each)

## References

- `references/workflow-steps.md` — Detailed 7-step TDD cycle with git checkpoints
- `references/patterns-and-best-practices.md` — Test patterns, common mistakes, success metrics

_meta.json

{
  "ownerId": "kn75k4jwpn9qgy3pk38e93gkt982zqmg",
  "slug": "tdd-workflow",
  "version": "1.0.0",
  "publishedAt": 1775430089469
}

references/patterns-and-best-practices.md

# TDD Patterns and Best Practices

## Test Types

### Unit Tests

- Individual functions and utilities
- Component logic
- Pure functions
- Helpers and utilities

### Integration Tests

- API endpoints
- Database operations
- Service interactions
- External API calls

### E2E Tests

- Critical user flows
- Complete workflows
- Browser automation
- UI interactions

## Common Testing Patterns

### Unit Test (Jest/Vitest)

```typescript
describe('Button Component', () => {
  it('renders with correct text', () => {
    expect(component).toBeDefined()
  })

  it('calls onClick when clicked', () => {
    const handleClick = jest.fn()
    // Test interaction
    expect(handleClick).toHaveBeenCalled()
  })
})
```

### API Integration Test

```typescript
describe('GET /api/resource', () => {
  it('returns resource successfully', async () => {
    const response = await fetch('/api/resource')
    expect(response.status).toBe(200)
  })

  it('validates parameters', async () => {
    const response = await fetch('/api/resource?invalid=param')
    expect(response.status).toBe(400)
  })
})
```

### E2E Test (Playwright)

```typescript
test('user can complete flow', async ({ page }) => {
  await page.goto('/')
  await page.click('button')
  await expect(page.locator('text=Success')).toBeVisible()
})
```

## Best Practices

1. **Tests first** - Always TDD
2. **One assertion per test** - Focus on single behavior
3. **Descriptive names** - Explain what's tested
4. **Mock dependencies** - Isolate unit tests
5. **Test edge cases** - Null, undefined, empty, boundaries
6. **Test error paths** - Not just happy paths
7. **Keep tests fast** - Unit tests < 50ms each
8. **Clean up after tests** - No side effects
9. **Check coverage** - 80%+ target
10. **No skipped tests** - Review why tests are marked skip or pending

## Common Mistakes to Avoid

### ❌ Testing Implementation Details

```typescript
expect(component.state.count).toBe(5)
```

### ✅ Testing User-Visible Behavior

```typescript
expect(screen.getByText('Count: 5')).toBeInTheDocument()
```

### ❌ Brittle Selectors

```typescript
await page.click('.css-class-xyz')
```

### ✅ Semantic Selectors

```typescript
await page.click('[data-testid="submit-button"]')
```

### ❌ Tests That Depend on Each Other

```typescript
test('creates user', () => { /* ... */ })
test('updates same user', () => { /* depends on previous */ })
```

### ✅ Independent Tests

```typescript
beforeEach(() => {
  user = createTestUser()  // Fresh setup each test
})
```

## Mocking Examples

### Supabase Client Mock

```typescript
jest.mock('@/lib/supabase', () => ({
  supabase: {
    from: jest.fn(() => ({
      select: jest.fn(() => ({
        eq: jest.fn(() => Promise.resolve({
          data: [{ id: 1, name: 'Test' }],
          error: null
        }))
      }))
    }))
  }
}))
```

### Redis Mock

```typescript
jest.mock('@/lib/redis', () => ({
  searchByVector: jest.fn(() => Promise.resolve([
    { id: 'key-1', score: 0.95 }
  ])),
  set: je

references/workflow-steps.md

# TDD Workflow Steps

## Step 1: Write User Journeys

```text
As a [role], I want to [action], so that [benefit]

Example:
As a user, I want to search for markets semantically,
so that I can find relevant markets even without exact keywords.
```

## Step 2: Generate Test Cases

For each user journey, create comprehensive test cases covering happy path, edge cases, and errors.

## Step 3: Run Tests (RED gate)

```bash
npm test  # or appropriate test runner
```

**Tests MUST fail before implementation.** This is mandatory. Before modifying business logic:

- The test must compile/run successfully
- The test must execute and produce RED result
- The failure must be caused by the intended missing implementation (not unrelated syntax errors)

Create a git checkpoint commit after RED validation:

```bash
git commit -m "test: add reproducer for <feature or bug>"
```

## Step 4: Implement Code

Write minimal code to make tests pass. Don't over-engineer.

## Step 5: Run Tests (GREEN gate)

```bash
npm test  # Re-run the same test target
```

Tests should now pass. Only after GREEN validation may refactoring proceed.

Create a git checkpoint commit:

```bash
git commit -m "fix: <feature or bug>"
```

## Step 6: Refactor

Improve code quality while keeping tests green:
- Remove duplication
- Improve naming
- Optimize performance
- Enhance readability

Create a final checkpoint commit:

```bash
git commit -m "refactor: clean up after <feature or bug> implementation"
```

## Step 7: Verify Coverage

```bash
npm run test:coverage
# Verify 80%+ coverage achieved
```

skill-card.md

## Description:

Test-driven development workflow enforcing 80%+ code coverage with unit, integration, and E2E tests.

This skill is ready for commercial/non-commercial use.

## Publisher:

[djc00p](https://clawhub.ai/user/djc00p)

### License/Terms of Use:

MIT-0

## Use Case:

Developers and engineers use this skill to guide feature work, bug fixes, and refactoring through a test-first RED-GREEN-REFACTOR workflow with coverage checks.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: The workflow encourages running project tests and making local git checkpoint commits.

Mitigation: Review generated commits before sharing or pushing them.

## Reference(s):

- [TDD Workflow Skill Page](https://clawhub.ai/djc00p/skills/tdd-workflow)
- [TDD Workflow Steps](references/workflow-steps.md)
- [TDD Patterns and Best Practices](references/patterns-and-best-practices.md)

## Skill Output:

**Output Type(s):** [guidance, markdown, code, shell commands]

**Output Format:** [Markdown guidance with example test code and shell commands]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [May propose running project tests and creating local git checkpoint commits.]

## Skill Version(s):

1.0.0 (source: server release evidence)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.

Sponsored

Ads related to TDD Workflow and adjacent AI workflows.