Sponsor Suno AI Music arrow_forward
Slash Command

Component Generator

Generate React components from descriptions with TypeScript and tests

Type
Slash Command
GitHub stars
2.8k
License
MIT
Repo last updated
Sep 27, 2026

What Component Generator is

Component Generator is a slash command published in the jeremylongshore/tons-of-skills-marketplace repository on GitHub, which has about 2.8k stars. The repository describes itself as: “Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com.”

A slash command is a reusable prompt saved as a markdown file and run by typing its name after a slash. In Claude Code, custom commands have been merged into skills: a file in .claude/commands/ and a skill folder in .claude/skills/ both create the same kind of command, and existing command files keep working.

Component Generator gives you a repeatable way to run the same instructions without retyping them, optionally with arguments.

How to install Component Generator

Claude Code

  1. Download component-generator.md from the repository.
  2. Save it to ~/.claude/commands/ (all projects) or .claude/commands/ (one project). As a skill, you can instead save it as ~/.claude/skills/<name>/SKILL.md.
  3. Run it by typing / followed by its name.

Claude Cowork

  1. Turn the command into a skill: create a folder with the file saved as SKILL.md and zip it.
  2. In Customize → Skills, click +, then upload the ZIP.
  3. Run it from any task with / and the skill name.

New to extending Cowork? Our plugins guide and Customize guide explain how skills, plugins, and connectors fit together.

Inside the source file

An excerpt from plugins/packages/fullstack-starter-pack/commands/component-generator.md, shared under the repository's MIT license. Read the full file on GitHub.

Generates production-ready React components from natural language descriptions, including TypeScript types, styling, and tests.

What This Command Does

Component Generation:

  • Creates React component with TypeScript
  • Generates prop types and interfaces
  • Adds basic styling (CSS modules or Tailwind)
  • Creates test file (React Testing Library)
  • Includes JSDoc comments
  • Follows React best practices

Output: Complete component with types, styles, and tests

Time: 2-5 minutes

Usage

# Generate component from description
/component-generator "Create a Card component with image, title, description, and action button"

# Shortcut
/cg "Button component with loading state and icon support"

# Specify framework/style
/cg "Modal dialog with animations" --style tailwind --test vitest

# Generate with directory
/cg "UserProfile component" --output src/components/UserProfile

Example Output

Input:

/cg "Create a Button component with variants (primary, secondary, ghost), sizes (sm, md, lg), loading state, and icon support"

Generated Files:

Button.tsx:

import { ButtonHTMLAttributes, ReactNode } from 'react'
import styles from './Button.module.css'

export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
  /** Button visual variant */
  variant?: 'primary' | 'secondary' | 'ghost'
  /** Button size */
  size?: 'sm' | 'md' | 'lg'
  /** Show loading spinner */
  loading?: boolean
  /** Icon to display before text */
  icon?: ReactNode
  /** Button content */
  children: ReactNode
}

/**
 * Button component with multiple variants and sizes
…

Button.module.css:

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: 0.375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Variants */
…

Button.test.tsx:

import { render, screen, fireEvent } from '@testing-library/react'
import { Button } from './Button'

describe('Button', () => {
  it('renders button with text', () => {
    render(<Button>Click me</Button>)
    expect(screen.getByRole('button')).toHaveTextContent('Click me')
  })

  it('handles click events', () => {
    const handleClick = jest.fn()
    render(<Button onClick={handleClick}>Click</Button>)

    fireEvent.click(screen.getByRole('button'))
    expect(handleClick).toHaveBeenCalledTimes(1)
  })

  it('shows loading state', () => {
…

Component Templates

Common Components Generated

1. Card Component:

<Card
  image="/product.jpg"
  title="Product Name"
  description="Product description"
  action={<Button>Buy Now</Button>}
/>

2. Modal Component:

<Modal
  isOpen={isOpen}
  onClose={handleClose}
  title="Confirm Action"
>
  <p>Are you sure?</p>
</Modal>

3. Form Field Component:

<FormField
  label="Email"
  type="email"
  error={errors.email}
  required
/>

4. Dropdown Component:

<Dropdown
  items={options}
  value={selected}
  onChange={handleChange}
  placeholder="Select option"
/>

Features

Accessibility Built-In

  • Semantic HTML elements
  • ARIA attributes where needed
  • Keyboard navigation support
  • Focus management
  • Screen reader announcements

TypeScript Support

  • Full type definitions
  • Prop validation
  • IntelliSense support
  • Generic types where appropriate

Testing Included

  • Unit tests with React Testing Library
  • Accessibility tests
  • User interaction tests
  • Edge case coverage

Styling Options

  • CSS Modules (default)
  • Tailwind CSS
  • Styled Components
  • Emotion
  • Plain CSS

Best Practices Applied

Component Structure:

  • Single responsibility
  • Composable design
  • Prop drilling avoided
  • Performance optimized (React.memo where beneficial)

Code Quality:

  • ESLint compliant
  • Prettier formatted
  • TypeScript strict mode
  • JSDoc comments

Testing:

  • 80%+ code coverage
  • User-centric tests (not implementation details)
  • Accessibility assertions
  • Happy path + edge cases

Related Commands

  • /css-utility-generator - Generate utility CSS classes
  • React Specialist (agent) - React architecture guidance
  • UI/UX Expert (agent) - Design review

Generate components in seconds. Ship features faster. ️

Before you install

  • Read the whole file first. Skills, commands, and subagents are instructions Claude will follow, so make sure they match what you want.
  • Check which tools, scripts, or MCP servers it uses. Local servers and scripts run with your permissions.
  • Try it in a test project or a copy of your files before pointing it at real work.
  • Pin the version you tested, and review changes before updating.
  • Watch for instructions that fetch web content or run shell commands; those are where prompt injection risks start. See our prompt injection guide.

FAQ

What is Component Generator?

Component Generator is a slash command for Claude Code and Claude Cowork from the jeremylongshore/tons-of-skills-marketplace repository on GitHub. Generate React components from descriptions with TypeScript and tests

How do I install Component Generator in Claude Code?

Download component-generator.md from the repository. Save it to ~/.claude/commands/ (all projects) or .claude/commands/ (one project). As a skill, you can instead save it as ~/.claude/skills/<name>/SKILL.md. Run it by typing / followed by its name.

Can I use Component Generator in Claude Cowork?

Turn the command into a skill: create a folder with the file saved as SKILL.md and zip it. In Customize → Skills, click +, then upload the ZIP. Run it from any task with / and the skill name.

Is Component Generator safe to install?

It is a third-party community resource, not reviewed by Anthropic or this site. Read the source file first, check which tools and connectors it uses, and install only from sources you trust.

Similar resources

Browse all skills, subagents, and plugins →

Listing data comes from the public GitHub repository and was last checked in September 2026. Excerpts are © their authors and shared under MIT. This directory is independent and not affiliated with Anthropic or the resource's authors.