test-generator

0
0
Source

Automatically suggest tests for new functions and components. Use when new code is written, functions added, or user mentions testing. Creates test scaffolding with Jest, Vitest, Pytest patterns. Triggers on new functions, components, test requests, testing mentions.

Install

mkdir -p .claude/skills/test-generator && curl -L -o skill.zip "https://mcp.directory/api/skills/download/4986" && unzip -o skill.zip -d .claude/skills/test-generator && rm skill.zip

Installs to .claude/skills/test-generator

About this skill

Test Generator Skill

Auto-suggest tests when you write new code.

When I Activate

  • ✅ New function created
  • ✅ New component added
  • ✅ User mentions testing or tests
  • ✅ Test file missing for implementation
  • ✅ User asks "can you test this?"

What I Generate

Quick Test Scaffolding

  • Basic happy path tests
  • Null/undefined edge cases
  • Simple error scenarios
  • Framework-appropriate syntax (Jest/Vitest/Pytest)

What I Don't Do

  • Comprehensive test suites → Use @test-engineer sub-agent
  • Integration tests → Use @test-engineer sub-agent
  • E2E test design → Use @test-engineer sub-agent
  • Test strategy planning → Use @test-engineer sub-agent

Relationship with @test-engineer Sub-Agent

Me (Skill): Quick test scaffolding @test-engineer (Sub-Agent): Comprehensive testing strategy

Workflow

  1. You write a function
  2. I auto-generate basic test structure
  3. You want full suite → Invoke @test-engineer sub-agent
  4. Sub-agent creates comprehensive tests

Examples

JavaScript Function

// You write:
function calculateDiscount(price, percentage) {
  if (price <= 0) throw new Error('Invalid price');
  return price * (percentage / 100);
}

// I auto-generate:
describe('calculateDiscount', () => {
  it('calculates discount correctly', () => {
    expect(calculateDiscount(100, 10)).toBe(10);
  });

  it('throws error for invalid price', () => {
    expect(() => calculateDiscount(0, 10)).toThrow('Invalid price');
  });

  it('handles zero percentage', () => {
    expect(calculateDiscount(100, 0)).toBe(0);
  });

  // TODO: Add more edge cases
  // Consider: negative percentages, decimal values, very large numbers
});

React Component

// You write:
function UserCard({ user, onEdit }) {
  return (
    <div className="user-card">
      <h2>{user.name}</h2>
      <button onClick={() => onEdit(user.id)}>Edit</button>
    </div>
  );
}

// I auto-generate:
import { render, screen, fireEvent } from '@testing-library/react';

describe('UserCard', () => {
  const mockUser = { id: 1, name: 'John Doe' };
  const mockOnEdit = jest.fn();

  it('renders user name', () => {
    render(<UserCard user={mockUser} onEdit={mockOnEdit} />);
    expect(screen.getByText('John Doe')).toBeInTheDocument();
  });

  it('calls onEdit with user id when button clicked', () => {
    render(<UserCard user={mockUser} onEdit={mockOnEdit} />);
    fireEvent.click(screen.getByText('Edit'));
    expect(mockOnEdit).toHaveBeenCalledWith(1);
  });

  // TODO: Add tests for edge cases
  // - Missing user data
  // - Undefined onEdit
  // - Long names (UI testing)
});

Python Function

# You write:
def fetch_user_data(user_id: int) -> dict:
    if user_id <= 0:
        raise ValueError("Invalid user ID")
    return db.query("SELECT * FROM users WHERE id = ?", [user_id])

# I auto-generate:
import pytest

def test_fetch_user_data_success():
    """Test successful user data retrieval"""
    result = fetch_user_data(1)
    assert isinstance(result, dict)
    assert 'id' in result

def test_fetch_user_data_invalid_id():
    """Test with invalid user ID"""
    with pytest.raises(ValueError, match="Invalid user ID"):
        fetch_user_data(0)

def test_fetch_user_data_negative_id():
    """Test with negative ID"""
    with pytest.raises(ValueError):
        fetch_user_data(-1)

# TODO: Add integration tests with database
# TODO: Test database connection failures

Framework Detection

I automatically detect your testing framework:

  • JavaScript/TypeScript: Jest, Vitest, Mocha
  • Python: pytest, unittest
  • Java: JUnit
  • Go: testing package

Detection based on:

  • package.json dependencies
  • requirements.txt
  • Existing test files
  • Import statements

Test Patterns

Unit Tests

// Function testing
test('adds numbers correctly', () => {
  expect(add(2, 3)).toBe(5);
});

Component Tests

// React component testing
test('button click triggers callback', () => {
  const onClick = jest.fn();
  render(<Button onClick={onClick} />);
  fireEvent.click(screen.getByRole('button'));
  expect(onClick).toHaveBeenCalled();
});

Edge Cases

// Boundary testing
test('handles empty input', () => {
  expect(processData([])).toEqual([]);
});

test('handles null input', () => {
  expect(processData(null)).toBeNull();
});

When to Use Sub-Agent

Invoke @test-engineer for:

  • Complete test suites (20+ tests)
  • Integration test strategy
  • E2E test planning
  • Test coverage goals
  • Complex mocking scenarios

Example:

Me: "Generated 3 basic tests for calculateDiscount()"
You: "@test-engineer create comprehensive test suite with all edge cases"
Sub-agent: [Creates 25+ tests covering all scenarios]

Sandboxing Compatibility

Works without sandboxing: ✅ Yes Works with sandboxing: ✅ Yes

  • Filesystem: Writes test files to project
  • Network: None required
  • Configuration: None required

Customization

Edit test templates:

cp -r ~/.claude/skills/development/test-generator \
      ~/.claude/skills/development/my-test-generator

# Edit SKILL.md to customize:
# - Test patterns
# - Framework preferences
# - Coverage expectations

Integration with Commands

/test-gen Command

/test-gen --file utils.js --framework jest --coverage 90

# Combines:
# 1. My quick scaffolding
# 2. @test-engineer comprehensive tests
# 3. Full test file generation

Tips

  1. Let me scaffold first - Review before invoking sub-agent
  2. Add TODOs - I include TODO comments for complex cases
  3. Framework consistency - I match your project's testing style
  4. Quick iteration - Regenerate if not satisfied

Related Tools

  • @test-engineer: Comprehensive test suite creation
  • code-reviewer skill: Flags code that needs testing
  • /test-gen command: Full test generation workflow

senior-architect

alirezarezvani

Comprehensive software architecture skill for designing scalable, maintainable systems using ReactJS, NextJS, NodeJS, Express, React Native, Swift, Kotlin, Flutter, Postgres, GraphQL, Go, Python. Includes architecture diagram generation, system design patterns, tech stack decision frameworks, and dependency analysis. Use when designing system architecture, making technical decisions, creating architecture diagrams, evaluating trade-offs, or defining integration patterns.

170129

content-creator

alirezarezvani

Create SEO-optimized marketing content with consistent brand voice. Includes brand voice analyzer, SEO optimizer, content frameworks, and social media templates. Use when writing blog posts, creating social media content, analyzing brand voice, optimizing SEO, planning content calendars, or when user mentions content creation, brand voice, SEO optimization, social media marketing, or content strategy.

11619

ceo-advisor

alirezarezvani

Executive leadership guidance for strategic decision-making, organizational development, and stakeholder management. Includes strategy analyzer, financial scenario modeling, board governance frameworks, and investor relations playbooks. Use when planning strategy, preparing board presentations, managing investors, developing organizational culture, making executive decisions, or when user mentions CEO, strategic planning, board meetings, investor updates, organizational leadership, or executive strategy.

8413

content-trend-researcher

alirezarezvani

Advanced content and topic research skill that analyzes trends across Google Analytics, Google Trends, Substack, Medium, Reddit, LinkedIn, X, blogs, podcasts, and YouTube to generate data-driven article outlines based on user intent analysis

10913

cold-email

alirezarezvani

When the user wants to write, improve, or build a sequence of B2B cold outreach emails to prospects who haven't asked to hear from them. Use when the user mentions 'cold email,' 'cold outreach,' 'prospecting emails,' 'SDR emails,' 'sales emails,' 'first touch email,' 'follow-up sequence,' or 'email prospecting.' Also use when they share an email draft that sounds too sales-y and needs to be humanized. Distinct from email-sequence (lifecycle/nurture to opted-in subscribers) — this is unsolicited outreach to new prospects. NOT for lifecycle emails, newsletters, or drip campaigns (use email-sequence).

3713

content-humanizer

alirezarezvani

Makes AI-generated content sound genuinely human — not just cleaned up, but alive. Use when content feels robotic, uses too many AI clichés, lacks personality, or reads like it was written by committee. Triggers: 'this sounds like AI', 'make it more human', 'add personality', 'it feels generic', 'sounds robotic', 'fix AI writing', 'inject our voice'. NOT for initial content creation (use content-production). NOT for SEO optimization (use content-production Mode 3).

359

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

643969

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

591705

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

318399

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

340397

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

452339

fastapi-templates

wshobson

Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.

304231

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.