mock-spec-extractor
Extracts design specifications from mock images including colors, typography, spacing, and component details
Best use case
mock-spec-extractor is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Extracts design specifications from mock images including colors, typography, spacing, and component details
Teams using mock-spec-extractor should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/mock-spec-extractor/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How mock-spec-extractor Compares
| Feature / Agent | mock-spec-extractor | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Extracts design specifications from mock images including colors, typography, spacing, and component details
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# mock-spec-extractor
You are **mock-spec-extractor** - a specialized skill for extracting comprehensive design specifications from mock images.
## Overview
This skill analyzes design mock images to extract structured specifications including colors, typography, spacing patterns, and component details that serve as the source of truth for pixel-perfect implementation.
## Prerequisites
- Node.js 18+ installed
- Image processing libraries (sharp, jimp)
- Color extraction libraries (node-vibrant, color-thief)
- OCR capabilities for text analysis (optional)
## Capabilities
### 1. Color Palette Extraction
```javascript
const Vibrant = require('node-vibrant');
async function extractColors(mockPath) {
const palette = await Vibrant.from(mockPath).getPalette();
return {
primary: palette.Vibrant?.hex,
secondary: palette.Muted?.hex,
accent: palette.DarkVibrant?.hex,
background: palette.LightMuted?.hex,
text: palette.DarkMuted?.hex,
allColors: Object.entries(palette)
.filter(([_, swatch]) => swatch)
.map(([name, swatch]) => ({
name,
hex: swatch.hex,
rgb: swatch.rgb,
population: swatch.population
}))
};
}
```
### 2. Layout Structure Analysis
```javascript
async function analyzeLayout(mockPath) {
const image = await sharp(mockPath).metadata();
// Detect major sections through edge detection
const edges = await detectEdges(mockPath);
// Identify grid patterns
const gridAnalysis = await detectGridPattern(edges);
return {
dimensions: { width: image.width, height: image.height },
sections: identifySections(edges),
grid: gridAnalysis,
hierarchy: buildHierarchy(sections)
};
}
```
### 3. Typography Detection
```javascript
async function detectTypography(mockPath, regions) {
const textStyles = [];
for (const region of regions) {
// Extract text regions
const textAreas = await findTextAreas(mockPath, region);
for (const area of textAreas) {
textStyles.push({
region: region.name,
estimatedSize: estimateFontSize(area),
estimatedWeight: estimateWeight(area),
color: extractDominantColor(area),
position: area.bounds
});
}
}
return deduplicateStyles(textStyles);
}
```
### 4. Spacing Pattern Recognition
```javascript
async function analyzeSpacing(mockPath, elements) {
const spacingValues = [];
// Analyze gaps between elements
for (let i = 0; i < elements.length - 1; i++) {
const gap = calculateGap(elements[i], elements[i + 1]);
spacingValues.push(gap);
}
// Identify spacing scale
const scale = identifySpacingScale(spacingValues);
return {
scale,
patterns: groupByPattern(spacingValues),
recommendations: suggestCSSVariables(scale)
};
}
```
### 5. Component Detection
```javascript
async function detectComponents(mockPath) {
const components = [];
// Detect buttons
const buttons = await detectButtons(mockPath);
components.push(...buttons.map(b => ({ type: 'button', ...b })));
// Detect cards
const cards = await detectCards(mockPath);
components.push(...cards.map(c => ({ type: 'card', ...c })));
// Detect inputs
const inputs = await detectInputs(mockPath);
components.push(...inputs.map(i => ({ type: 'input', ...i })));
return components;
}
```
## Input Schema
```json
{
"type": "object",
"required": ["mockSource"],
"properties": {
"mockSource": {
"type": "object",
"properties": {
"type": { "type": "string", "enum": ["image", "figma", "url"] },
"path": { "type": "string" }
}
},
"analysisDepth": {
"type": "string",
"enum": ["basic", "detailed", "comprehensive"],
"default": "detailed"
},
"focusAreas": {
"type": "array",
"items": { "type": "string" }
}
}
}
```
## Output Schema
```json
{
"type": "object",
"properties": {
"success": { "type": "boolean" },
"designSpec": {
"type": "object",
"properties": {
"layout": { "type": "object" },
"typography": { "type": "object" },
"colorPalette": { "type": "object" },
"spacing": { "type": "object" },
"components": { "type": "array" },
"decorativeElements": { "type": "array" }
}
},
"cssVariables": { "type": "object" },
"implementationNotes": { "type": "array" }
}
}
```
## Process Integration
This skill integrates with:
- `pixel-perfect-implementation.js` - Provides mock analysis for convergence
- `design-system.js` - Extracts design tokens
- `component-library.js` - Identifies component patterns
## Usage Example
```bash
/skill mock-spec-extractor \
--mock designs/dashboard-mock.png \
--depth comprehensive \
--focus "header,sidebar,cards"
```
## Best Practices
1. **High-resolution mocks** - Use 2x resolution for better analysis
2. **Clean backgrounds** - Solid backgrounds improve detection
3. **Consistent naming** - Name regions consistently for tracking
4. **Validate extractions** - Review and refine extracted specs
5. **Iterate with feedback** - Use scoring feedback to improve extractionRelated Skills
retrospect
Summarize or retrospect on a completed Babysitter run.
animation-spec
Generate animation specifications, easing curves, and motion design documentation
api-mock-server
Generate and run mock API servers from OpenAPI specifications
typespec-sdk-generator
Microsoft TypeSpec-based API and SDK generation
typescript-sdk-specialist
TypeScript SDK development with Node.js and browser support. Design SDK architecture, implement type-safe API clients, support ESM and CommonJS modules, and configure bundling for browsers.
sdk-mock-generator
Generate mock servers and clients for SDK testing
rust-sdk-specialist
Rust SDK development with zero-cost abstractions
python-sdk-specialist
Python SDK development with async support and type hints
openapi-spec-generator
Automated OpenAPI specification generation from code annotations, comments, and interface definitions
java-sdk-specialist
Java SDK development for enterprise environments
go-sdk-specialist
Go SDK development with idiomatic patterns
csharp-sdk-specialist
C#/.NET SDK development with async patterns