Skip to main content
command CX Codex

convert-to-test-driven-prompt — Claude Code command for TDD prompts

convert-to-test-driven-prompt turns a plain request into a TDD-style prompt with test cases, expected outcomes, and success criteria. Useful when behavior needs to be pinned down before code exists.

MIT ★ 2,744 updated 2026-10-08

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/commands/convert-to-test-driven-prompt.md
Open on GitHub

What convert-to-test-driven-prompt does

The command takes a user request and reshapes it into a test-driven structure: an objective, test scenarios written as GIVEN/WHEN/THEN, success criteria, and red-green-refactor steps. Input can be direct text or a file — $ARGUMENTS reads a relative or absolute path.

The workflow has five steps: extract requirements, define test cases, specify expected outcomes, arrange the prompt for a red-green-refactor cycle, and add edge cases. Output is a markdown document with happy path, error handling, and boundary tests.

An example from the instructions shows "Add user login functionality" becoming a spec with four tests: successful login, wrong password, non-existent user, and rate limiting after five failed attempts. The command recommends covering negative scenarios and boundaries, like a sixth login try within 15 minutes.

What it helps with

  • turn "add a login" into checkable scenarios
  • pin down success criteria before implementation
  • catch edge cases and error handling early
  • get a structure for red-green-refactor cycles
  • pass a file as input instead of plain text

Example prompts for the agent

  • Convert this to TDD: add a user authentication feature
  • Make this test-driven: create a shopping cart component
  • /convert-to-test-driven-prompt @path/to/prompt-file.md

How to install convert-to-test-driven-prompt

Manually: put the files in place

.claude/commands/convert-to-test-driven-prompt.md

Call it with /convert-to-test-driven-prompt. For all projects use ~/.claude/commands/

Questions about convert-to-test-driven-prompt

How do I install convert-to-test-driven-prompt in Claude Code?

Create a file at .claude/commands/convert-to-test-driven-prompt.md with the command content. It then becomes available as a slash command in Claude Code.

What does convert-to-test-driven-prompt do?

It turns a user request into a TDD prompt: extracts requirements, defines GIVEN/WHEN/THEN test scenarios, adds success criteria, and lays out test-first development steps.

Can I pass a file instead of typing a request?

Yes. Use $ARGUMENTS with a relative or absolute path. Without an argument, the command converts the user's direct input.

Source text

convert-to-test-driven-prompt.md · MIT
# Convert to Test-Driven Prompt

Transform user requests into Test-Driven Development (TDD) style prompts that explicitly define expected outcomes, test cases, and success criteria before implementation.

## Usage Examples

### Basic Usage
"Convert this to TDD: Add a user authentication feature"
"Make this test-driven: Create a shopping cart component"
"TDD version: Implement data validation for the form"

### With File Input
`/convert-to-test-driven-prompt @path/to/prompt-file.md`
`/convert-to-test-driven-prompt @../other-project/feature-request.txt`

### Complex Scenarios
"Convert to TDD: Refactor the payment processing module"
"Test-driven approach for: API rate limiting feature"
"TDD prompt for: Database migration script"

## Instructions for Claude

When converting to TDD prompts:

### Input Handling
- If `$ARGUMENTS` is provided, read the file at that path to get the prompt to convert
- If no `$ARGUMENTS`, use the user's direct input as the prompt to convert
- Support relative and absolute file paths

1. **Extract Requirements**: Identify core functionality from the original request
2. **Define Test Cases**: Create specific, measurable test scenarios
3. **Specify Expected Outcomes**: Clear success and failure criteria
4. **Structure for Implementation**: Organize prompt for red-green-refactor cycle
5. **Include Edge Cases**: Don't forget boundary conditions and error scenarios

### TDD Prompt Structure

#### 1. Objective Statement
Clear, concise description of what needs to be built

#### 2. Test Specifications
```
GIVEN: [Initial state/context]
WHEN: [Action performed]
THEN: [Expected outcome]
```

#### 3. Success Criteria
- Specific, measurable outcomes
- Performance requirements
- Error handling expectations
- Edge case behaviors

#### 4. Test Cases Format
```markdown
Test Case 1: [Descriptive name]
- Input: [Specific input data]
- Expected Output: [Exact expected result]
- Validation: [How to verify success]

Test Case 2: [Edge case name]
- Input: [Boundary/error condition]
- Expected Output: [Error handling result]
- Validation: [Error verification method]
```

### Conversion Examples

#### Original Request:
"Add user login functionality"

#### TDD Conversion:
```markdown
## Objective
Implement secure user login with email/password authentication

## Test Specifications

### Test 1: Successful Login
GIVEN: Valid user credentials exist in database
WHEN: User submits correct email and password
THEN: User receives auth token and is redirected to dashboard

### Test 2: Invalid Password
GIVEN: Valid email but incorrect password
WHEN: User submits login form
THEN: Return error "Invalid credentials" without revealing which field is wrong

### Test 3: Non-existent User
GIVEN: Email not in database
WHEN: User attempts login
THEN: Return same "Invalid credentials" error (prevent user enumeration)

### Test 4: Rate Limiting
GIVEN: User has failed 5 login attempts
WHEN: User attempts 6th login within 15 minutes
THEN: Block attempt and show "Too many attempts" error

## Success Criteria
- All tests pass
- Password is hashed using bcrypt
- Auth tokens expire after 24 hours
- Login attempts are logged
- Response time < 200ms
```

### Output Format

Generate TDD prompt as:

```markdown
## TDD Prompt: [Feature Name]

### Objective
[Clear description of the feature to implement]

### Test Suite

#### Happy Path Tests
[List of successful scenario tests]

#### Error Handling Tests
[List of failure scenario tests]

#### Edge Case Tests
[List of boundary condition tests]

### Implementation Requirements
- [ ] All tests must pass
- [ ] Code coverage > 80%
- [ ] Performance criteria met
- [ ] Security requirements satisfied

### Test-First Development Steps
1. Write failing test for [first requirement]
2. Implement minimal code to pass
3. Refactor while keeping tests green
4. Repeat for next requirement

### Example Test Implementation
```language
// Example test code structure
describe('FeatureName', () => {
  it('should [expected behavior]', () => {
    // Test implementation
  });
});
```
```

Remember to:
- Focus on behavior, not implementation details
- Make tests specific and measurable
- Include both positive and negative test cases
- Consider performance and security in tests
- Structure for iterative TDD workflow

© centminmod · MIT · centminmod/my-claude-code-setup

Similar slash commands

All slash commands for Testing and QA →

From the same set35

The whole set →
security-audit The security-audit command scans a codebase for vulnerabilities and unsafe patterns across a project or a specific module. CX Codex +1 ★ 2,744repo stars check-best-practices The check-best-practices command reviews code against language-specific standards, conventions, and best practices. It spots issues from critical bugs to style violations and suggests concrete improvements. CX Codex +1 ★ 2,744repo stars claude-docs-consultant claude-docs-consultant pulls official Claude Code documentation directly from code.claude.com on demand. Fetches only the markdown files needed for the active task. CX Codex +1 ★ 2,744repo stars explain-architecture-pattern The explain-architecture-pattern command identifies architecture and design patterns in a codebase, then explains the structure behind them. Use it when the project’s organization needs a clear rationale. CX Codex +1 ★ 2,744repo stars batch-operations-prompt batch-operations-prompt transforms bulk code modification requests into structured plans with parallel stages and sequential tasks. It optimizes Claude Code execution through TodoWrite checklists. CX Codex +1 ★ 2,744repo stars memory-bank-synchronizer memory-bank-synchronizer is a Claude Code subagent that checks memory-bank files against the codebase and refreshes documentation when CLAUDE-*.md diverges from the implementation. CX Codex ★ 2,744repo stars ux-design-expert ux-design-expert audits user flows, builds Tailwind design systems and themes Highcharts charts. Useful when the interface is done but people still get lost. CX Codex ★ 2,744repo stars code-searcher code-searcher navigates codebases, tracks vulnerabilities, and returns exact file and line references. CX Codex ★ 2,744repo stars

Project sponsors

Companies that keep this analytics open