Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

Create New Component

БесплатноБез исполняемых скриптовНе проверен

Create a new React component following Lab's architecture patterns. Determines component scope (core vs. page-scoped), generates proper structure with…

ethpandaopsот ethpandaops★ 25 звёзд на GitHub17 установок в других каталогах

Об этом скилле

Create New Component

This skill creates React components following Lab's established architecture patterns.

Technology Stack

  • React: v19 (ref as a prop, JSX.Element)
  • TypeScript: v5 (strict typing)
  • Tailwind CSS: v4 (semantic color tokens)
  • Storybook: v9 (autodocs with decorators)
  • Icons: Heroicons v2 (@heroicons/react/20/solid, @heroicons/react/16/solid)
  • UI Library: Headless UI v2 (for interactive components)
  • Utilities: clsx for conditional classes
  • Forms: react-hook-form v7 (when applicable)

Before You Begin

STOP AND ASK QUESTIONS unless the user has provided complete specifications.

Ask the user to clarify:

  1. Component scope: Is this reusable across pages (core) or page-specific?
  2. Category: Which category fits best? (see Component Categories below)
  3. Functionality: What should this component do? What props are needed?
  4. Composition: Should it use existing components internally?
  5. Variants: Does it need size/variant/color options?

Only proceed after understanding the requirements.

Component Architecture

Core Components (src/components/)

When: Reusable across multiple pages/sections Requirements:

  • Generic and configurable via props
  • No page-specific business logic
  • No direct API calls (accept data via props)
  • Semantic Tailwind tokens (bg-surface, text-foreground)
  • MUST include Storybook stories
  • Compose from other core components when logical

Page-Scoped Components (src/pages/[section]/components/)

When: Used within specific page/section only Requirements:

  • Page-specific business logic allowed
  • Can use hooks (useNetwork, API hooks, etc.)
  • Compose/extend core components
  • May contain specialized state management
  • NO Storybook stories required

Component Categories

Core Component Categories (src/components/)

  • Use ls to list the components in the src/components/ directory.

Page Sections (src/pages/)

  • Use ls to list the pages in the src/pages/ directory.

Standard Component Structure

ComponentName/
  ComponentName.tsx              # Implementation
  ComponentName.types.ts         # TypeScript types (when needed)
  ComponentName.stories.tsx      # Storybook stories (core components only)
  index.ts                       # Barrel export

Implementation Steps

1. Research Existing Components

Before implementing, examine similar existing components:

  • Check category for existing patterns
  • Review how props are structured
  • Observe Tailwind class patterns
  • Note composability approach

2. Create Component Structure

For Core Components:

src/components/[Category]/[ComponentName]/

For Page-Scoped Components:

src/pages/[section]/components/[ComponentName]/

3. Implement Component File

Key Patterns:

import type { JSX } from 'react';
import clsx from 'clsx';
import type { ComponentNameProps } from './ComponentName.types';

// Inline Tailwind class definitions (not objects)
const baseClasses = 'inline-flex items-center font-semibold';

// Variant classes when needed
const variantClasses = {
  primary: 'bg-primary text-on-fill hover:bg-primary-hover',
  secondary: 'bg-surface text-foreground hover:bg-surface-hover',
};

// React 19 passes ref as a prop, so there is no forwardRef or displayName
export function ComponentName({
  variant = 'primary',
  className,
  children,
  ref,
  ...props
}: ComponentNameProps): JSX.Element {
  return (
    <div ref={ref} className={clsx(baseClasses, variantClasses[variant], className)} {...props}>
      {children}
    </div>
  );
}

Semantic Colors:

  • Use tokens: bg-surface, text-foreground, text-muted, border-border
  • Brand: bg-primary, text-primary, bg-secondary, bg-accent
  • States: text-success, text-warning, text-danger
  • Only token classes: no hard-coded colors (text-gray-500) or arbitrary values (min-w-[600px]); see Styling

Conditional Classes:

import { clsx } from 'clsx';

className={clsx(
  'base-classes',
  variant === 'primary' && 'primary-classes',
  disabled && 'opacity-50 cursor-not-allowed',
  className
)}

4. Create Types File (when needed)

import type { ComponentPropsWithoutRef, ReactNode, Ref } from 'react';

// Export a type only once another module imports it; pnpm knip fails on unused exports
type ComponentVariant = 'primary' | 'secondary';

export interface ComponentNameProps extends ComponentPropsWithoutRef<'div'> {
  /**
   * Ref to the rendered element
   */
  ref?: Ref<HTMLDivElement>;

  /**
   * The visual style variant
   * @default 'primary'
   */
  variant?: ComponentVariant;

  /**
   * Component content
   */
  children?: ReactNode;
}

5. Create Storybook Stories (Core Components Only)

Required Template:

import type { Meta, StoryObj } from '@storybook/react-vite';
import { ComponentName } from './Co
Полный SKILL.md на GitHub

Установить Create New Component в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл Create New Component?

Create a new React component following Lab's architecture patterns. Determines component scope (core vs. page-scoped), generates proper structure with TypeScript types, creates Storybook stories for core components, and ensures composability with existing components.

Как установить скилл Create New Component?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл Create New Component запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить Create New Component с