Test-Driven Development methodology for Node.js/TypeScript projects.
/plugin marketplace add DoubleslashSE/claude-marketplace/plugin install node-tdd@doubleslash-pluginsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
patterns.mdTest-Driven Development methodology for Node.js/TypeScript projects.
Write tests BEFORE implementation:
Make tests pass with minimal code:
Improve code while keeping tests green:
describe('Calculator', () => {
it('should add two numbers correctly', () => {
// Arrange - Set up test conditions
const calculator = createCalculator();
// Act - Execute the behavior
const result = calculator.add(2, 3);
// Assert - Verify the outcome
expect(result).toBe(5);
});
});
Format: should {expectedBehavior} when {scenario}
Examples:
it('should return empty array when input is empty', ...);
it('should throw ValidationError when email is invalid', ...);
it('should emit event when state changes', ...);
describe('validateEmail', () => {
it('should return true for valid email', () => {
expect(validateEmail('user@example.com')).toBe(true);
});
});
describe('UserService', () => {
it('should persist user to database', async () => {
const db = createTestDatabase();
const service = createUserService({ db });
await service.createUser({ email: 'test@example.com' });
const user = await db.users.findFirst();
expect(user.email).toBe('test@example.com');
});
});
describe('API Contract', () => {
it('should return user with expected shape', async () => {
const response = await api.getUser('1');
expect(response).toMatchObject({
id: expect.any(String),
email: expect.any(String),
createdAt: expect.any(Date),
});
});
});
Returns canned data:
const stubApi = {
getUser: () => Promise.resolve({ id: '1', name: 'Test' }),
};
Verifies interactions:
const mockLogger = {
info: jest.fn(),
error: jest.fn(),
};
// Later: expect(mockLogger.info).toHaveBeenCalledWith('message');
Working implementation:
const createFakeDatabase = () => {
const store = new Map();
return {
save: (entity) => store.set(entity.id, entity),
findById: (id) => store.get(id),
};
};
Records calls:
const spy = jest.spyOn(service, 'notify');
await service.process();
expect(spy).toHaveBeenCalledTimes(1);
src/
services/
user-service.ts
user-service.test.ts # Co-located unit tests
api/
handlers.ts
handlers.test.ts
tests/
integration/ # Integration tests
user-flow.test.ts
fixtures/ # Shared test data
users.ts
helpers/ # Test utilities
test-context.ts
// Bad - testing internal state
expect(service._cache.size).toBe(1);
// Good - testing behavior
expect(service.getCachedValue('key')).toBe('value');
// Bad - brittle
expect(result).toEqual({
id: '123',
name: 'Test',
createdAt: new Date('2024-01-01'),
updatedAt: new Date('2024-01-01'),
});
// Good - flexible
expect(result).toMatchObject({
id: expect.any(String),
name: 'Test',
});
// Bad - tests depend on order
let user;
it('should create user', () => { user = createUser(); });
it('should update user', () => { updateUser(user); }); // Depends on previous
// Good - independent tests
it('should update user', () => {
const user = createUser();
updateUser(user);
});
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.