一键导入
add-component
Workflow for adding a new UI component to ui-components (with Storybook + optional tests) and optionally to the react-generators template system.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Workflow for adding a new UI component to ui-components (with Storybook + optional tests) and optionally to the react-generators template system.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Step-by-step workflow for creating a new Baseplate plugin package, including root configuration files, source structure, and platform modules.
Workflow for modifying generated code in Baseplate, including template extraction, generator updates, and project synchronization.
Systematic approach for upgrading packages in the Baseplate monorepo, ensuring consistency between monorepo dependencies and generated project code.
| name | add-component |
| description | Workflow for adding a new UI component to ui-components (with Storybook + optional tests) and optionally to the react-generators template system. |
Use this skill when adding a new UI component to Baseplate. The workflow covers:
packages/ui-components with stories and optional testsBefore writing any code, determine where the component comes from. If the user hasn't specified, ask:
Decision tree:
https://ui.shadcn.com/docs/components/base/<name>). If yes, use that — @base-ui/react is already a dependency. If only a Radix variant exists (/docs/components/radix/<name>), use that instead. Note the shadcn URL in a JSDoc comment.packages/ui-components/src/components/ui/<component-name>/
├── <component-name>.tsx # Component implementation
└── <component-name>.stories.tsx # Storybook stories
# Add if complex logic exists:
└── <component-name>.unit.test.tsx # Unit tests
import { cn } from '#src/utils/index.js';: React.ReactElement return typedata-slot attributes exactly as they come from shadcn source. Only add data-slot when building a custom component from scratch..js extensions (ES module requirement)/**
* A responsive table component.
*
* https://ui.shadcn.com/docs/components/base/table
*/
import { Button } from '../button/button.js';
#src/ alias, e.g.:
import { useConfirmDialog } from '#src/hooks/use-confirm-dialog.js';
packages/ui-components/package.json, add it with pnpm --filter @baseplate-dev/ui-components add <package>.import type { Meta, StoryObj } from '@storybook/react-vite';
import { ComponentName } from './component-name.js';
const meta = {
title: 'components/ComponentName',
component: ComponentName,
tags: ['autodocs'],
argTypes: {
// Add interactive controls for key props
},
} satisfies Meta<typeof ComponentName>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {
args: {
// Provide sensible defaults
},
};
// Add more story variants for different states/variants
Add a <component-name>.unit.test.tsx only when the component has:
Use renderWithProviders from #src/tests/render.test-helper.js, not raw render:
import { describe, expect, it } from 'vitest';
import { renderWithProviders } from '#src/tests/render.test-helper.js';
import { ComponentName } from './component-name.js';
describe('ComponentName', () => {
it('should ...', () => {
renderWithProviders(<ComponentName ... />);
// assertions
});
});
Add to packages/ui-components/src/components/ui/index.ts (keep alphabetically sorted):
export * from './<component-name>/<component-name>.js';
After creating the ui-components files, stop and present:
Do NOT proceed to Phase 4 until the user explicitly confirms.
The example lives at examples/blog-with-auth/apps/admin/.
Create examples/blog-with-auth/apps/admin/src/components/ui/<component-name>.tsx with these adaptations from the ui-components version:
components/ui/<component-name>.tsx (no sub-folder)import { cn } from '@src/utils/cn'; (the example project's path alias)@src/components/ui/<component-name> alias instead of relative folder paths@src/hooks/<hook-name> alias@ts-nocheck in the example file — the generator tooling adds it automatically during extractionThen validate the example builds:
pnpm run:example blog-with-auth -- pnpm typecheck
pnpm run:example blog-with-auth -- pnpm lint
mcp__baseplate_dev_server__configure_ts_template({
filePath: 'src/components/ui/<component-name>.tsx',
generator: '@baseplate-dev/react-generators#core/react-components',
templateName: '<component-name>',
project: 'blog-with-auth',
});
mcp__baseplate_dev_server__extract_templates({
project: 'blog-with-auth',
app: 'admin',
});
pnpm --filter @baseplate-dev/react-generators typecheck
pnpm --filter @baseplate-dev/react-generators lint --fix
mcp__baseplate_dev_server__sync_all_projects({
overwrite: true,
});
Check .changeset/ for an existing changeset covering the same component. If found, add to it. Otherwise create .changeset/<component-name>.md:
---
'@baseplate-dev/react-generators': patch
'@baseplate-dev/ui-components': patch
---
Add <ComponentName> component
| Purpose | Path |
|---|---|
| ui-components barrel export | packages/ui-components/src/components/ui/index.ts |
| ui-components test helper | packages/ui-components/src/tests/render.test-helper.tsx |
| Example component (table) | packages/ui-components/src/components/ui/table/table.tsx |
| Generator templates dir | packages/react-generators/src/generators/core/react-components/templates/components/ui/ |
| Generator extractor config | packages/react-generators/src/generators/core/react-components/extractor.json |
| Example template (table) | packages/react-generators/src/generators/core/react-components/templates/components/ui/table.tsx |
| Modify generated code skill | .claude/skills/modify-generated-code/SKILL.md |
generated/ directories — they are auto-generated.templates/, extractor.json, and the main *.generator.ts.