Test-Driven Development workflow - write tests first, then implementation
/plugin marketplace add Benny9193/devflow/plugin install benny9193-devflow@Benny9193/devflowThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Follow the Red-Green-Refactor cycle strictly. Never write production code without a failing test first.
┌─────────────────────────────────────────┐
│ │
│ ┌───────┐ │
│ │ RED │ Write a failing test │
│ └───┬───┘ │
│ │ │
│ ▼ │
│ ┌───────┐ │
│ │ GREEN │ Write minimal code to pass│
│ └───┬───┘ │
│ │ │
│ ▼ │
│ ┌──────────┐ │
│ │ REFACTOR │ Improve without │
│ └────┬─────┘ breaking tests │
│ │ │
│ └──────────────────────────────┘
No production code without a failing test
Write the minimum test to fail
Write the minimum code to pass
Refactor only when green
// Start with what you want the API to look like
describe('Calculator', () => {
it('should add two numbers', () => {
const calc = new Calculator();
expect(calc.add(2, 3)).toBe(5);
});
});
Run test → Watch it fail → Confirm it fails for the RIGHT reason
// Write the SIMPLEST code that passes
class Calculator {
add(a: number, b: number): number {
return 5; // Yes, hardcoding is fine here!
}
}
Run test → Watch it pass → Celebrate (briefly)
it('should add different numbers', () => {
const calc = new Calculator();
expect(calc.add(1, 1)).toBe(2); // Forces real implementation
});
class Calculator {
add(a: number, b: number): number {
return a + b; // Now we generalize
}
}
With green tests, improve the code:
Use this pattern: should [expected behavior] when [condition]
it('should return empty array when input is null')
it('should throw ValidationError when email is invalid')
it('should retry 3 times when connection fails')
Before writing ANY code, verify:
Before marking GREEN:
Before REFACTORING:
This is not TDD. Tests written after tend to test implementation, not behavior.
Write ONE test, make it pass, then write the next. Stay in the cycle.
If your implementation is more than a few lines, you skipped steps. Add intermediate tests.
// BAD - tests implementation
expect(user._hashedPassword).toMatch(/^[a-f0-9]{64}$/);
// GOOD - tests behavior
expect(user.verifyPassword('correct')).toBe(true);
Never refactor with failing tests. Get green first.
Goal: Implement a slugify function
// Test 1: Simplest case
it('should lowercase the input', () => {
expect(slugify('Hello')).toBe('hello');
});
// Implementation: return input.toLowerCase();
// Test 2: Handle spaces
it('should replace spaces with hyphens', () => {
expect(slugify('Hello World')).toBe('hello-world');
});
// Implementation: return input.toLowerCase().replace(/ /g, '-');
// Test 3: Handle special characters
it('should remove special characters', () => {
expect(slugify('Hello, World!')).toBe('hello-world');
});
// Implementation: add .replace(/[^a-z0-9-]/g, '');
// Test 4: Edge case
it('should handle empty string', () => {
expect(slugify('')).toBe('');
});
// Already passes! No change needed.
"TDD is not about testing. It's about design."
The tests drive you toward better, more modular code. Trust the process.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.