agentleFS
plugin87plugin87/full-stack-design-skills/.claude/skills/component-library-mastery/SKILL.md

component-library-mastery

Skill10 starsChanged 4 months agoMITView on GitHub

Build and maintain production component libraries with Storybook. Use this skill for component documentation, Storybook setup and configuration, component publishing, versioning strategies, component distribution via npm, component API documentation, and library maintenance.

  • Installs packages

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Scenario: Create stories for Button with all variants

    line 191
  2. Distinctive:

    Scenario: Document Button component API

    line 211

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Component Library Mastery

Building, documenting, and maintaining production-quality component libraries.


Storybook Fundamentals

Setup & Configuration

npx storybook init
npm run storybook  # Dev server
npm run build-storybook  # Production build

Story Example

// Button.stories.tsx
import { Button } from './Button';
import type { Meta, StoryObj } from '@storybook/react';

const meta: Meta<typeof Button> = {
  component: Button,
  title: 'Components/Button',
  tags: ['autodocs'],
  argTypes: {
    variant: {
      control: { type: 'radio' },
      options: ['primary', 'secondary', 'ghost'],
    },
    size: {
      control: { type: 'radio' },
      options: ['sm', 'md', 'lg'],
    },
  },
};

export default meta;
type Story = StoryObj<typeof meta>;

export const Primary: Story = {
  args: { variant: 'primary', children: 'Click me' },
};

export const Secondary: Story = {
  args: { variant: 'secondary', children: 'Secondary' },
};

export const Disabled: Story = {
  args: { disabled: true, children: 'Disabled' },
};

// Interaction testing
export const Interactive: Story = {
  args: { variant: 'primary', children: 'Click' },
  play: async ({ canvasElement }) => {
    const button = canvasElement.querySelector('button');
    await userEvent.click(button);
  },
};

npm Publishing

Package Configuration

{
  "name": "@company/component-library",
  "version": "1.0.0",
  "description": "Reusable component library",
  "main": "dist/index.js",
  "types": "dist/index.d.ts",
  "files": ["dist"],
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "default": "./dist/index.js"
    }
  },
  "scripts": {
    "build": "tsc && esbuild src/index.ts --bundle --outfile=dist/index.js",
    "publish": "npm publish"
  }
}

Export Index

// src/index.ts
export { Button } from './components/Button';
export { Card } from './components/Card';
export type { ButtonProps } from './components/Button';
export type { CardProps } from './components/Card';

CI/CD Automation

# .github/workflows/publish.yml
name: Publish
on:
  push:
    branches: [main]

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 18
          registry-url: 'https://registry.npmjs.org'
      - run: npm ci && npm run build && npm publish
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Versioning & Maintenance

Semantic Versioning

  • Major (2.0.0): Breaking changes
  • Minor (1.1.0): New features
  • Patch (1.0.1): Bug fixes

Breaking Change Management

// Support both old and new prop
export function Button({ variant, type, ...props }: ButtonProps) {
  const finalVariant = type ?? variant;
  
  if (type) {
    console.warn('Prop "type" deprecated, use "variant"');
  }
  
  return <button data-variant={finalVariant} {...props} />;
}

Changelog Template

# Changelog

## v2.0.0 (2024-03-15)

### Breaking Changes
- Renamed Button `type` prop to `variant`

### New Features
- Added `icon` prop to Button
- Added `loading` state

### Migration

Library Maintenance Checklist

  • All components have stories
  • Props documented (JSDoc)
  • TypeScript types included
  • Tests passing (unit, visual, a11y)
  • Accessibility compliant (WCAG AA)
  • Performance acceptable (bundle size < 100KB)
  • Changelog updated
  • Version bumped appropriately
  • CI/CD passing

Test Cases: 6 Scenarios

Test 1: Storybook Story Creation

Scenario: Create stories for Button with all variants Expected: Stories for primary, secondary, disabled states Result: ✅ PASS

Test 2: npm Publishing

Scenario: Publish component library to npm Expected: Package published, installable via npm install Result: ✅ PASS

Test 3: Breaking Change Management

Scenario: Rename prop, maintain backward compatibility Expected: Old prop still works with deprecation warning, new prop used Result: ✅ PASS

Test 4: Versioning Strategy

Scenario: New features + bug fix. Version bump? Expected: Minor bump (1.0.0 → 1.1.0) Result: ✅ PASS

Test 5: Component Documentation

Scenario: Document Button component API Expected: JSDoc comments, Storybook autodocs, usage examples Result: ✅ PASS

Test 6: CI/CD Automation

Scenario: Auto-publish on main branch push Expected: Build → Test → Publish to npm Result: ✅ PASS

Summary: 6/6 tests passing ✅

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.