agentleFS
wittyreferencewittyreference/twilio-claude-plugin/skills/tdd-workflow/SKILL.md

tdd-workflow

Skill2 starsChanged 8 months agoMITView on GitHub

Twilio development skill: tdd-workflow

78 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use kotlin-testing, ralphinho-rfc-pipeline and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • tpavanipradeepSkill

    kotlin-testing

    Kotlin testing patterns with Kotest, MockK, coroutine testing, property-based testing, and Kover coverage. Follows TDD methodology with idiomatic Kotlin practices.

    Also in 6 projects that use this

  • InfopibeSkill

    ralphinho-rfc-pipeline

    RFC-driven multi-agent DAG execution pattern with quality gates, merge queues, and work unit orchestration.

    Also in 10 projects that use this

  • mryeastcodeSkill

    nuxt4-patterns

    Nuxt 4 app patterns for hydration safety, performance, route rules, lazy loading, and SSR-safe data fetching with useFetch and useAsyncData.

    Also in 5 projects that use this

  • saxon-ySkill

    configure-ecc

    Interactive installer for Everything Claude Code — guides users through selecting and installing skills and rules to user-level or project-level directories, verifies paths, and optionally optimizes installed files.

    Also in 12 projects that use this

  • InfopibeSkill

    content-hash-cache-pattern

    Cache expensive file processing results using SHA-256 content hashes — path-independent, auto-invalidating, with service layer separation.

    Also in 12 projects that use this

  • WorldFlowAISkill

    project-guidelines-example

    Also in 19 projects that use this

  • +2 more from Infopibe

The file

Show its rules and text

We split this skill into the rules it gives an agent

31 rules. 0 are common, 30 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 72 edited versions we read keep these.

  • 30

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Test-Driven Development patterns for Twilio projects.

    line 8
  2. Distinctive:

    When building Twilio integrations, TDD is especially valuable because:

    line 12
  3. Distinctive:

    Write tests that FAIL. This is critical -- if tests pass before implementation, they're not testing new functionality.

    line 39
  4. Distinctive:

    Read specification or requirements

    line 42
  5. Distinctive:

    Write unit tests for each function

    line 43
  6. Distinctive:

    Write integration tests for workflows

    line 44
  7. Distinctive:

    Run tests and verify they fail

    line 45
  8. Distinctive:

    Write MINIMAL code to make tests pass.

    line 65
  9. Distinctive:

    Verify tests exist and fail

    line 68
  10. Distinctive:

    Read test expectations carefully

    line 69
  11. Distinctive:

    Write the simplest implementation that passes

    line 70
  12. Distinctive:

    Run tests until green

    line 71
  13. Distinctive:

    Before the Green Phase (dev), verify TDD was followed:

    line 93
  14. Very specific:

    Tests must fail: Test status must be failing -- if tests pass before implementation, they aren't testing new functionality

    line 96
  15. Distinctive:

    Coverage threshold: After Green Phase, verify minimum coverage (80%+ lines recommended)

    line 97
  16. Distinctive:

    If any check fails, go back to the Red Phase and fix the tests before proceeding.

    line 99
  17. Distinctive:

    If you find yourself with passing tests before writing implementation:

    line 103
  18. Distinctive:

    Write tests for NEW functionality that doesn't exist yet

    line 107
  19. Distinctive:

    Verify the new tests fail for the right reason (missing function/module, not syntax error)

    line 108
  20. Distinctive:

    Fix: Ensure tests reference functions/features that don't exist yet.

    line 119
  21. Distinctive:

    Fix: Test PUBLIC interfaces and edge cases, not private methods.

    line 127
  22. Distinctive:

    Test individual functions in isolation.

    line 155
  23. Distinctive:

    Test function interactions and webhook chains:

    line 198
  24. Distinctive:

    Test against live Twilio APIs using deep validation:

    line 223
  25. Distinctive:

    When using the plugin's development subagents:

    line 255
  26. Distinctive:

    Read spec from previous phase

    line 258
  27. Distinctive:

    Write test files with failing tests

    line 260
  28. Distinctive:

    Run tests to confirm failure

    line 261
  29. Distinctive:

    Verify failing tests exist

    line 265
  30. Distinctive:

    Run tests iteratively until green

    line 268
  31. Distinctive:

    Commit when all tests pass

    line 269

“Common” is measured: kept by at least 6 in 10 of the 72 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

TDD Workflow Patterns

Test-Driven Development patterns for Twilio projects. Load this skill when working on feature development to ensure quality through disciplined test-first practices.

Why TDD Matters

When building Twilio integrations, TDD is especially valuable because:

  1. Quality gate: Tests define expected behavior upfront -- critical for webhook-driven flows where debugging is hard
  2. Reviewability: Easier to review tests than implementation
  3. Confidence: Green tests = working code
  4. Self-verification: Validates work without manual Twilio API testing

The TDD Cycle

+-------------------------------------------------------------+
|                                                             |
|   RED -------------> GREEN -------------> REFACTOR          |
|    |                  |                    |                 |
|    |                  |                    |                 |
|  Write              Write               Improve             |
|  failing            minimal             code                |
|  tests              code to             while               |
|                     pass                keeping             |
|                     tests               tests               |
|                                         green               |
|                                                             |
+-------------------------------------------------------------+

Red Phase (Write Failing Tests)

Write tests that FAIL. This is critical -- if tests pass before implementation, they're not testing new functionality.

What to do:

  1. Read specification or requirements
  2. Write unit tests for each function
  3. Write integration tests for workflows
  4. Run tests and verify they fail
  5. Confirm failures are for the right reason (missing function, not syntax error)
// Example: Tests that correctly fail (function doesn't exist yet)
describe('transferCall', () => {
  it('should return valid TwiML with Dial verb', () => {
    const result = transferCall({ to: '+1234567890' });
    expect(result).toContain('<Dial>');
  });

  it('should require phone number', () => {
    expect(() => transferCall({})).toThrow('Missing required: to');
  });
});
// Error: Cannot find module '../functions/voice/transfer'

Green Phase (Make Tests Pass)

Write MINIMAL code to make tests pass. No more, no less.

What to do:

  1. Verify tests exist and fail
  2. Read test expectations carefully
  3. Write the simplest implementation that passes
  4. Run tests until green
  5. Commit working code

Refactor Phase (Improve While Green)

Improve code quality while keeping tests green.

What's allowed:

  • Rename for clarity
  • Extract methods
  • Remove duplication
  • Improve performance

What's NOT allowed:

  • Add new features
  • Change behavior
  • Break tests

TDD Enforcement

Pre-Phase Checks

Before the Green Phase (dev), verify TDD was followed:

  1. Tests must exist: At least one test file from the Red Phase
  2. Tests must fail: Test status must be failing -- if tests pass before implementation, they aren't testing new functionality
  3. Coverage threshold: After Green Phase, verify minimum coverage (80%+ lines recommended)

If any check fails, go back to the Red Phase and fix the tests before proceeding.

Recovering from TDD Violations

If you find yourself with passing tests before writing implementation:

  1. Stop -- don't proceed to implementation
  2. Go back to the Red Phase
  3. Write tests for NEW functionality that doesn't exist yet
  4. Verify the new tests fail for the right reason (missing function/module, not syntax error)
  5. Resume the Green Phase

Common TDD Pitfalls

Pitfall 1: Tests Pass Before Implementation

Problem: Tests pass immediately, meaning they don't test new code.

Cause: Testing existing functionality or writing assertions that always pass.

Fix: Ensure tests reference functions/features that don't exist yet.

Pitfall 2: Over-Testing

Problem: Writing too many tests that overlap in coverage.

Cause: Testing implementation details instead of behavior.

Fix: Test PUBLIC interfaces and edge cases, not private methods.

Pitfall 3: Under-Testing

Problem: Tests only cover happy path.

Cause: Skipping error cases to make tests pass faster.

Fix: Requirements should define error scenarios. Test them all.

Pitfall 4: Modifying Tests to Pass

Problem: Changing test expectations to match buggy implementation.

Cause: Pressure to make tests green without fixing root cause.

Fix: Tests define CORRECT behavior. Fix implementation, not tests.

Test Categories

CategoryLocationRuns WhenCoverage Target
Unit__tests__/unit/ or *.test.jsnpm test80%+
Integration__tests__/integration/npm testKey flows
E2E__tests__/e2e/ or postman/npm run test:e2eCritical paths

Unit Tests for Twilio Functions

Test individual functions in isolation. Mock the Twilio context and callback:

const { handler } = require('../functions/voice/greeting');

describe('greeting handler', () => {
  let context, event, callback;

  beforeEach(() => {
    context = {
      getTwilioClient: jest.fn(),
      TWILIO_PHONE_NUMBER: '+15551234567'
    };
    event = { From: '+15559876543' };
    callback = jest.fn();
  });

  it('should return TwiML with Say verb', (done) => {
    callback.mockImplementation((err, response) => {
      expect(err).toBeNull();
      expect(response.toString()).toContain('<Say');
      done();
    });

    handler(context, event, callback);
  });

  it('should handle missing From number', (done) => {
    event = {};
    callback.mockImplementation((err, response) => {
      expect(err).toBeNull();
      // Should still work with a default message
      expect(response.toString()).toContain('<Say');
      done();
    });

    handler(context, event, callback);
  });
});

Integration Tests

Test function interactions and webhook chains:

describe('IVR flow', () => {
  it('should route billing calls to billing queue', async () => {
    // Step 1: Incoming call hits IVR
    const ivrResponse = await testHandler('/voice/ivr', {
      CallSid: 'CAtest123',
      From: '+15559876543'
    });
    expect(ivrResponse).toContain('<Gather>');

    // Step 2: Caller presses 1 for billing
    const routeResponse = await testHandler('/voice/ivr-handler', {
      CallSid: 'CAtest123',
      Digits: '1'
    });
    expect(routeResponse).toContain('<Enqueue');
    expect(routeResponse).toContain('billing');
  });
});

E2E Tests with Real Twilio

Test against live Twilio APIs using deep validation:

describe('Voice transfer E2E', () => {
  it('should complete transfer successfully', async () => {
    // Make a real call via Twilio API
    const call = await client.calls.create({
      to: testPhoneNumber,
      from: twilioPhoneNumber,
      url: `${baseUrl}/voice/incoming`
    });

    // Wait for call to complete
    await waitForCallStatus(call.sid, 'completed', 60000);

    // Deep validate
    const finalCall = await client.calls(call.sid).fetch();
    expect(finalCall.status).toBe('completed');

    // Check for debugger errors
    const alerts = await client.monitor.alerts.list({
      startDate: new Date(Date.now() - 300000),
      logLevel: 'error'
    });
    const relatedAlerts = alerts.filter(a => a.resourceSid === call.sid);
    expect(relatedAlerts).toHaveLength(0);
  });
});

TDD with Development Subagents

When using the plugin's development subagents:

test-gen Subagent (Red Phase)

  1. Read spec from previous phase
  2. Identify test scenarios
  3. Write test files with failing tests
  4. Run tests to confirm failure
  5. Report test count and failure status

dev Subagent (Green Phase)

  1. Verify failing tests exist
  2. Read test expectations
  3. Write minimal implementation
  4. Run tests iteratively until green
  5. Commit when all tests pass

review Subagent (Verification)

The review subagent checks TDD discipline:

  • Were tests written before implementation?
  • Were tests initially failing?
  • Is the implementation minimal?
  • Are there no extra features beyond what tests require?

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.