Skip to content
Back to skills

React Component Scaffold

ASecurity

Scaffold a React component with co-located tests, stories, and CSS module. Triggers on "create component", "scaffold component", "new component", "generate component".

  • 7 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 24, 2026
developmentjavascripttypescriptjavabashreact

Works with

  • cli

Security analysis

A100/100

Scanned November 24, 2026

npx -y skills add luqiang-code/claude-code-skills --skill react-component-scaffold --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of React Component Scaffold?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for React Component Scaffold
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/luqiang-code-react-component-scaffold/badge)](https://www.skillsdirectory.com/skills/luqiang-code-react-component-scaffold)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: react-component-scaffold
description: |
  Scaffold a React component with co-located tests, stories, and CSS module.
  Triggers on "create component", "scaffold component", "new component", "generate component".
metadata:
  type: tool
  version: "1.0.0"
  author: community
  tags: [react, component, scaffolding, typescript]
triggers:
  - "create component"
  - "scaffold component"
  - "new component"
  - "generate component"
allowed-tools:
  - Read
  - Write
  - Edit
  - Bash
---

# React Component Scaffold

Scaffold React components with tests, stories, and styles in one shot.

## When to Use
- Creating a new React component from scratch
- User says "create a component", "scaffold a component"
- Need consistent component file structure across a project

## When NOT to Use
- Modifying existing components
- Non-React component files
- The project has a code generator already (e.g., Plop, Hygen)

## Workflow
1. Ask user: component name, props (if known), and which optional files to generate
2. Detect or ask: JavaScript or TypeScript, CSS Modules or styled-components
3. Generate files:

```
ComponentName/
├── ComponentName.tsx          # Component with typed props
├── ComponentName.test.tsx     # Basic render + interaction tests
├── ComponentName.stories.tsx  # Storybook story (if project uses Storybook)
├── ComponentName.module.css   # CSS Module (if using CSS Modules)
└── index.ts                   # Barrel export
```

4. Write the component with:
   - Typed props interface
   - Default exports
   - Accessibility attributes (aria-label, role)
   - Loading/empty/error states if data-dependent

## Component Template
```tsx
import { type FC } from 'react';
import styles from './Button.module.css';

interface ButtonProps {
  /** Button label text */
  children: string;
  /** Visual variant */
  variant?: 'primary' | 'secondary' | 'danger';
  /** Disabled state */
  disabled?: boolean;
  /** Click handler */
  onClick?: () => void;
}

export const Button: FC<ButtonProps> = ({
  children,
  variant = 'primary',
  disabled = false,
  onClick,
}) => {
  return (
    <button
      className={`${styles.button} ${styles[variant]}`}
      disabled={disabled}
      onClick={onClick}
      type="button"
    >
      {children}
    </button>
  );
};
```

## Key Principles
- One component per folder — co-locate all related files
- Always include a barrel export (`index.ts`)
- Props interface should be exported (for consumers)
- Add JSDoc comments for each prop
- Use `type="button"` on buttons to prevent form submission

## Notes
- Follow the project's existing patterns — don't introduce new conventions
- If Storybook isn't used, skip the stories file
- Run `npm run lint` after generating to ensure compliance

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.