--- name: react-component-creator description: Create React components with TypeScript and hooks. Use when the user asks to create, generate, or scaffold a React component. ---
# React Component Creator## Instructions1. Create component file at `src/components/[ComponentName]/index.tsx`2. Use function component with TypeScript interface for props
3. Export as named export (not default export)
## Component Template```tsx
interface [Name]Props {
// props here
}
export function [Name]({ ...props }: [Name]Props) {
return <section>...</section>
}
Conventions
File naming: PascalCase for components, camelCase for hooks
One component per file
Co-locate styles: [ComponentName].module.css
Co-locate tests: [ComponentName].test.tsx
## 写好 Skill 的 10 个核心原则
知道了怎么写一个 SKILL.md 之后,怎么把它**「写好」**才是关键。研究了大量优秀的 Skills 案例并在项目中反复试错后,总结出这 10 个核心原则。它们各自解决的问题完全不同,缺哪个都会踩坑:
10 个核心原则
### 原则一:只写 Agent 不知道的事
Agent 已经是一个训练有素的"高级开发"了——它知道 React 怎么写、TypeScript 怎么用、怎么发起 HTTP 请求。你不需要教它这些。
你真正需要写的,是那些**「只存在于你团队脑子里」**的知识:我们的状态管理用 zustand 不用 redux、接口请求统一走 `src/api/request.ts` 里封装的方法、日期用 dayjs 不用 moment...这些"潜规则"Agent 没法从公开知识里推断出来。
举个例子,下面两种写法对比:
```markdown
# ❌ 浪费:Agent 自己就知道怎么用 fetch
When making HTTP requests, you can use the fetch API. The fetch function takes a URL and an options object containing method, headers, and body...
# ✅ 有价值:这是你们团队的私有约定
All API calls MUST use the project's request wrapper:
```ts
import { request } from'@/api/request'// GETconst users = await request.get<User[]>('/api/users')
// POSTawait request.post('/api/users', { name: 'Winty' })
## Design Thinking
Before coding, understand the context and commit to a BOLD aesthetic direction:
-**Purpose**: What problem does this interface solve? Who uses it?
-**Tone**: Pick an extreme: brutally minimal, maximalist chaos, retro-futuristic, luxury/refined, playful/toy-like...
-**Constraints**: Technical requirements (framework, performance, accessibility)
-**Differentiation**: What makes this UNFORGETTABLE?
这个案例好在哪里?
「description 写得精准」:既描述了能力(create frontend interfaces),又明确了触发时机(when the user asks to build web components, pages...)
## Decision Tree: Choosing Your Approach
User task → Is it static HTML?
├─ Yes → Read HTML file directly to identify selectors
│ └─ Write Playwright script using selectors
│ └─ No (dynamic webapp) → Is the server already running?
├─ No → Run: python scripts/with_server.py --help
└─ Yes → Reconnaissance-then-action:
1. Navigate and wait for networkidle
2. Take screenshot or inspect DOM
3. Identify selectors from rendered state
4. Execute actions with discovered selectors
这个写法的亮点在于:
「决策树清晰」:Agent 能快速判断走哪条路径
「脚本当黑盒用」:不需要把脚本内容加载到上下文,用 --help 了解用法后直接调用
「有明确的反模式提示」:用 ❌ 和 ✅ 标记常见陷阱
案例三:GitHub Copilot docs-agent —— 角色定位模式
来自 GitHub 官方博客对 2500+ 个 agents.md 的最佳实践总结:
---name: docs_agent description:Experttechnicalwriterforthisproject---Youareanexperttechnicalwriterforthisproject.## Your role-YouarefluentinMarkdownandcanreadTypeScriptcode-Youwriteforadeveloperaudience-Your task:readcodefrom`src/`andgeneratedocumentationin`docs/`## Commands you can useBuild docs:`npmrundocs:build`Lint markdown:`npxmarkdownlintdocs/`## Boundaries-✅Always do:Writenewfilesto`docs/`,followstyleexamples-⚠️Ask first:Beforemodifyingexistingdocumentsinamajorway-🚫Never do:Modifycodein`src/`,editconfigfiles,commitsecrets
--- name: react-component description: Scaffold React components with TypeScript following team conventions. Use when the user asks to create, generate, or scaffold a React component, or mentions creating a new UI element. ---
# React Component Generator## File Structure
For a component named `UserCard`:
```text
src/components/UserCard/
├── index.tsx # Component implementation
├── UserCard.module.css # Scoped styles
├── UserCard.test.tsx # Unit tests
└── types.ts # Type definitions (if complex)
AI Agent 已经很聪明了,不需要解释"什么是 React""什么是 TypeScript"。只写它不知道的信息:你们团队的规范、项目的特殊约定、偏好的技术方案。
3. 给太多选择
# ❌ Agent 会困惑到底该用哪个
You can use styled-components, or CSS Modules, or Tailwind, or Emotion...
# ✅ 给一个默认方案,必要时提供备选
Use CSS Modules for component styling. For utility-based layouts, use Tailwind CSS classes instead.