Agent skill
ui-spec-generator
Generate and maintain structured UI specification files (pages.yaml) from design resources and test cases. Use when: (1) "生成 UI 设计描述文件" (2) "检查测试用例覆盖的 UI 组件" (3) "生成 UI 组件清单" (4) "为新测试用例添加缺失页面" (5) Need to analyze gaps between test cases and existing UI components. Reads from specs/design/ (.pen files, images, pages.md) and specs/testcases/*.md, outputs to specs/design/pages.yaml.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/ui-spec-generator
SKILL.md
UI Spec Generator
Generate structured page-component-function hierarchy from design resources and test cases.
Prerequisites
MCP Servers Required
- Pencil MCP: Read
.pendesign files viamcp__pencil__*tools - Figma MCP: Read Figma designs (configured in
.claude/mcp.json)
Input Resources
| Resource | Path | Purpose |
|---|---|---|
| Style spec | specs/design/style.pen, basic.pen |
Design tokens and style rules |
| Components | specs/design/components/*.pen |
Existing component designs |
| Screenshots | specs/design/assets/images/*.png |
Visual/layout reference |
| Page index | specs/design/pages.md |
Page-to-resource mapping with Figma links |
| Test cases | specs/testcases/*.md |
Functional requirements |
Workflow
Step 1: Gather Design Context
- Read
specs/design/style.pento understand design tokens (colors, fonts, spacing) - Read
specs/design/pages.mdto get page list and Figma URLs - Use Figma MCP to fetch component structure from Figma links
- Read existing
.penfiles inspecs/design/components/to catalog current components
Step 2: Analyze Test Cases
- Read all files in
specs/testcases/*.md - Extract implicit UI requirements from test case descriptions:
- What data needs to be displayed?
- What user actions are described?
- What state changes occur?
- Map requirements to pages and components
Step 3: Gap Analysis
Compare test case requirements against existing components:
- Covered: Test case UI needs are met by existing components
- Extendable: Existing component can be modified (see component-reuse-criteria.md)
- Missing: New component needed
Step 4: Design Missing Components
For gaps identified:
- Reference the corresponding screenshot in
specs/design/assets/images/ - Use Figma MCP to get detailed component structure if Figma link exists
- Follow existing design patterns from
style.pen - Prefer extending existing components over creating new ones
Step 5: Generate pages.yaml
Output to specs/design/pages.yaml following the format in output-format.md.
Structure:
pages:
- id: page-id
name: 页面名称
route: /path
sections:
- id: section-id
name: 区块名称
components:
- id: component-id
name: 组件名称
type: card|list-item|button|...
data_source: post|category|user|...
fields: [field1, field2]
actions: [action1, action2]
Using Figma MCP
Extract Figma file key and node ID from URLs in pages.md:
https://www.figma.com/design/{file_key}/...?node-id={node_id}
Use Figma MCP tools to:
- Get file structure and component hierarchy
- Identify grouped elements (frames, groups)
- Extract component names and relationships
Component Reuse Decision
Before creating new components, check references/component-reuse-criteria.md:
- Visual similarity with existing components
- Functional compatibility
- Non-breaking extension possibility
Data Type References
When specifying data_source, use types from specs/data/types.md:
category- 活动/赛事post- 帖子/提案user- 用户group- 团队resource- 资源文件rule- 规则interaction- 互动
Output Validation
After generating pages.yaml:
- Verify all pages from
pages.mdare included - Verify test case UI requirements are addressed
- Confirm component reuse is maximized
- Check YAML syntax validity
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?