scaffold-component
@ea-toolkit · 收录于 1 周前
Scaffold a new React component with test file for the catalog UI.
适合你,如果经常需要创建React组件并配套测试文件
/ 下载安装
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
Claude Code
~/.claude/skills/(项目级 .claude/skills/)Codex CLI
~/.codex/skills/Cursor自动读取上面两处目录
其他工具见其文档的「skills」目录;两个下载是同一份文件,只是名字不同
/ 通过 npx 安装 校验哈希
npx oh-my-skill add ea-toolkit/architecture-catalog/scaffold-component/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- ea-toolkit/architecture-catalog/scaffold-component/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify ea-toolkit/architecture-catalog/scaffold-component安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
35GitHub stars
~602上下文体积 · 单文件
镜像托管
怎么用
技能原文 SKILL.md
Scaffold Component
Scaffold a new React component in catalog-ui/src/components/ with a co-located test file.
Arguments
$ARGUMENTS should be a PascalCase component name (e.g., CapabilityHeatmap, DomainSummaryCard).
If no argument is provided, ask the user for a component name.
Workflow
- Parse component name from
$ARGUMENTS. Ensure PascalCase.
- Determine target directory based on component purpose:
- Graph/visualization component →
catalog-ui/src/components/graphs/ - Diagram viewer →
catalog-ui/src/components/ - Layout/navigation →
catalog-ui/src/components/(or subdirectory if pattern exists) - General →
catalog-ui/src/components/ - Ask the user if unclear.
- Read existing context:
- Read
models/registry-mapping.yamlif the component will render registry data. - Read an existing similar component in the target directory for pattern reference.
- Read
catalog-ui/src/lib/types.tsfor TypeScript interfaces.
- Create component file (
ComponentName.tsx): - Export Props interface:
export interface ComponentNameProps { ... } - Named export (not default):
export const ComponentName: React.FC<ComponentNameProps> = ... - CSS via
--ec-*variables (never inline styles) - Semantic HTML (nav, main, section, article — not div for everything)
- Accessible: aria labels on interactive elements
- If rendering registry data: drive all behavior from schema properties (graph_rank, layer, icon), never from type name strings
- Create test file (
ComponentName.test.tsxin same directory or__tests__/): - At minimum: one render/smoke test + one behavioral test
- Use Vitest (
import { describe, it, expect } from 'vitest') - Mock external dependencies (ReactFlow, data loaders) if needed
- Verify types:
cd catalog-ui && npx tsc --noEmit
Template Pattern
// ComponentName.tsx
import type React from 'react';
export interface ComponentNameProps {
// Define props here
}
export const ComponentName: React.FC<ComponentNameProps> = (props) => {
return (
<section aria-label="Component description">
{/* Component content */}
</section>
);
};
// ComponentName.test.tsx
import { describe, it, expect } from 'vitest';
describe('ComponentName', () => {
it('should render without crashing', () => {
// Render test
});
it('should handle user interaction', () => {
// Behavioral test
});
});
Rules
- Follow the vocab-agnostic principle for core registry rendering (no type-name conditionals).
- Map views (event, heatmap) are intentionally type-aware — that's fine.
- No hardcoded display data — all data from props, config files, or data imports.
- No
!importantin CSS unless overriding third-party styles.
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →
评论
登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。
…