create-claudecraft 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +194 -0
- package/bin/cli.js +2 -0
- package/dist/constants.d.ts +71 -0
- package/dist/constants.js +128 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +229 -0
- package/dist/ink-prompts.d.ts +12 -0
- package/dist/ink-prompts.js +363 -0
- package/dist/prompts.d.ts +16 -0
- package/dist/prompts.js +434 -0
- package/dist/scaffold.d.ts +19 -0
- package/dist/scaffold.js +303 -0
- package/dist/ui.d.ts +27 -0
- package/dist/ui.js +254 -0
- package/package.json +74 -0
- package/templates/app/App.tsx +21 -0
- package/templates/base/CLAUDE.md +332 -0
- package/templates/base/eslint.config.js +28 -0
- package/templates/base/index.html +17 -0
- package/templates/base/package.json +43 -0
- package/templates/base/postcss.config.js +6 -0
- package/templates/base/tailwind.config.js +81 -0
- package/templates/base/tsconfig.json +25 -0
- package/templates/base/vite.config.ts +16 -0
- package/templates/commands/brainstorm.md +6 -0
- package/templates/commands/build.md +41 -0
- package/templates/commands/execute-plan.md +6 -0
- package/templates/commands/lint.md +41 -0
- package/templates/commands/ralph.md +113 -0
- package/templates/commands/typecheck.md +44 -0
- package/templates/commands/write-plan.md +6 -0
- package/templates/components/ErrorBoundary.tsx +49 -0
- package/templates/components/ui/Button.tsx +60 -0
- package/templates/components/ui/CodeBlock.tsx +46 -0
- package/templates/components/ui/CopyCommand.tsx +38 -0
- package/templates/components/ui/FilePreview.tsx +46 -0
- package/templates/components/ui/SkipLink.tsx +7 -0
- package/templates/components/ui/ThemeSelector.tsx +41 -0
- package/templates/components/ui/UICarousel.tsx +309 -0
- package/templates/context/ThemeContext.tsx +61 -0
- package/templates/homepage/HomePage.tsx +534 -0
- package/templates/homepage/NotFoundPage.tsx +17 -0
- package/templates/hooks/README.md +82 -0
- package/templates/hooks/check-branch.js +27 -0
- package/templates/hooks/typecheck-after-edit.js +51 -0
- package/templates/index.css +67 -0
- package/templates/lib/utils.ts +9 -0
- package/templates/main.tsx +16 -0
- package/templates/settings/MCP_SETUP.md +76 -0
- package/templates/settings/settings.json +16 -0
- package/templates/settings/settings.local.json +37 -0
- package/templates/skills/design/a11y-audit/SKILL.md +173 -0
- package/templates/skills/design/design-polish/SKILL.md +75 -0
- package/templates/skills/design/figma-to-code/SKILL.md +157 -0
- package/templates/skills/design/json-ld/SKILL.md +125 -0
- package/templates/skills/design/microcopy/SKILL.md +197 -0
- package/templates/skills/design/og-image/SKILL.md +157 -0
- package/templates/skills/design/ralph-wiggum-loops/SKILL.md +299 -0
- package/templates/skills/design/react-best-practices/SKILL.md +106 -0
- package/templates/skills/design/react-best-practices/references/react-performance-guidelines.md +143 -0
- package/templates/skills/design/seo-review/SKILL.md +96 -0
- package/templates/skills/design/sitemap-generator/SKILL.md +66 -0
- package/templates/skills/design/testing-patterns/SKILL.md +276 -0
- package/templates/skills/design/ui-skills/SKILL.md +85 -0
- package/templates/skills/design/visual-iteration/SKILL.md +88 -0
- package/templates/skills/workflow/brainstorming/SKILL.md +54 -0
- package/templates/skills/workflow/dispatching-parallel-agents/SKILL.md +180 -0
- package/templates/skills/workflow/executing-plans/SKILL.md +76 -0
- package/templates/skills/workflow/finishing-a-development-branch/SKILL.md +200 -0
- package/templates/skills/workflow/receiving-code-review/SKILL.md +213 -0
- package/templates/skills/workflow/requesting-code-review/SKILL.md +105 -0
- package/templates/skills/workflow/requesting-code-review/code-reviewer.md +146 -0
- package/templates/skills/workflow/subagent-driven-development/SKILL.md +240 -0
- package/templates/skills/workflow/subagent-driven-development/code-quality-reviewer-prompt.md +20 -0
- package/templates/skills/workflow/subagent-driven-development/implementer-prompt.md +78 -0
- package/templates/skills/workflow/subagent-driven-development/spec-reviewer-prompt.md +61 -0
- package/templates/skills/workflow/systematic-debugging/CREATION-LOG.md +119 -0
- package/templates/skills/workflow/systematic-debugging/SKILL.md +296 -0
- package/templates/skills/workflow/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/templates/skills/workflow/systematic-debugging/condition-based-waiting.md +115 -0
- package/templates/skills/workflow/systematic-debugging/defense-in-depth.md +122 -0
- package/templates/skills/workflow/systematic-debugging/find-polluter.sh +63 -0
- package/templates/skills/workflow/systematic-debugging/root-cause-tracing.md +169 -0
- package/templates/skills/workflow/systematic-debugging/test-academic.md +14 -0
- package/templates/skills/workflow/systematic-debugging/test-pressure-1.md +58 -0
- package/templates/skills/workflow/systematic-debugging/test-pressure-2.md +68 -0
- package/templates/skills/workflow/systematic-debugging/test-pressure-3.md +69 -0
- package/templates/skills/workflow/test-driven-development/SKILL.md +371 -0
- package/templates/skills/workflow/test-driven-development/testing-anti-patterns.md +299 -0
- package/templates/skills/workflow/using-git-worktrees/SKILL.md +217 -0
- package/templates/skills/workflow/using-superpowers/SKILL.md +87 -0
- package/templates/skills/workflow/verification-before-completion/SKILL.md +139 -0
- package/templates/skills/workflow/writing-plans/SKILL.md +116 -0
- package/templates/skills/workflow/writing-skills/SKILL.md +655 -0
- package/templates/skills/workflow/writing-skills/anthropic-best-practices.md +1150 -0
- package/templates/skills/workflow/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
- package/templates/skills/workflow/writing-skills/graphviz-conventions.dot +172 -0
- package/templates/skills/workflow/writing-skills/persuasion-principles.md +187 -0
- package/templates/skills/workflow/writing-skills/render-graphs.js +168 -0
- package/templates/skills/workflow/writing-skills/testing-skills-with-subagents.md +384 -0
- package/templates/types/index.ts +17 -0
- package/templates/vite-env.d.ts +1 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* PreToolUse Hook: Check Branch Before Edit
|
|
5
|
+
*
|
|
6
|
+
* Warns if editing files on main/master branch.
|
|
7
|
+
* Helps prevent accidental commits to protected branches.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const { execSync } = require('child_process');
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
const branch = execSync('git rev-parse --abbrev-ref HEAD', {
|
|
14
|
+
encoding: 'utf8',
|
|
15
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
16
|
+
}).trim();
|
|
17
|
+
|
|
18
|
+
if (branch === 'main' || branch === 'master') {
|
|
19
|
+
console.log(JSON.stringify({
|
|
20
|
+
feedback: `⚠️ Warning: You are on the ${branch} branch. Consider creating a feature branch first.`,
|
|
21
|
+
suppressOutput: false
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
} catch (error) {
|
|
25
|
+
// Not a git repo or git not available - silently continue
|
|
26
|
+
process.exit(0);
|
|
27
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* PostToolUse Hook: Type Check After Edit
|
|
5
|
+
*
|
|
6
|
+
* Runs TypeScript type checking after a file is edited.
|
|
7
|
+
* Outputs JSON feedback for Claude to process.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const { execSync } = require('child_process');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
|
|
13
|
+
// Get the edited file path from arguments
|
|
14
|
+
const filePath = process.argv[2];
|
|
15
|
+
|
|
16
|
+
// Only check TypeScript/JavaScript files
|
|
17
|
+
if (!filePath || !filePath.match(/\.(tsx?|jsx?)$/)) {
|
|
18
|
+
// Exit silently for non-TS/JS files
|
|
19
|
+
process.exit(0);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
// Run TypeScript check (non-blocking, just report)
|
|
24
|
+
execSync('npx tsc --noEmit', {
|
|
25
|
+
encoding: 'utf8',
|
|
26
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
27
|
+
timeout: 30000
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// No errors - output success feedback
|
|
31
|
+
console.log(JSON.stringify({
|
|
32
|
+
feedback: `✅ Type check passed for ${path.basename(filePath)}`,
|
|
33
|
+
suppressOutput: true
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
} catch (error) {
|
|
37
|
+
// Parse TypeScript errors
|
|
38
|
+
const output = error.stdout || error.stderr || '';
|
|
39
|
+
const errorLines = output.split('\n').filter(line => line.includes('error TS'));
|
|
40
|
+
|
|
41
|
+
if (errorLines.length > 0) {
|
|
42
|
+
// Has type errors - provide feedback
|
|
43
|
+
console.log(JSON.stringify({
|
|
44
|
+
feedback: `⚠️ Type errors detected:\n${errorLines.slice(0, 5).join('\n')}${errorLines.length > 5 ? `\n... and ${errorLines.length - 5} more` : ''}`,
|
|
45
|
+
suppressOutput: false
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
// Exit code 0 to not block, just inform
|
|
49
|
+
process.exit(0);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
@tailwind base;
|
|
2
|
+
@tailwind components;
|
|
3
|
+
@tailwind utilities;
|
|
4
|
+
|
|
5
|
+
/* Smaller border radius for all DaisyUI components */
|
|
6
|
+
:root {
|
|
7
|
+
--rounded-box: 0.25rem;
|
|
8
|
+
--rounded-btn: 0.25rem;
|
|
9
|
+
--rounded-badge: 0.25rem;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/* ═══════════════════════════════════════
|
|
13
|
+
Accessibility Defaults
|
|
14
|
+
═══════════════════════════════════════ */
|
|
15
|
+
|
|
16
|
+
/* Screen reader only */
|
|
17
|
+
.sr-only {
|
|
18
|
+
position: absolute;
|
|
19
|
+
width: 1px;
|
|
20
|
+
height: 1px;
|
|
21
|
+
padding: 0;
|
|
22
|
+
margin: -1px;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
clip: rect(0, 0, 0, 0);
|
|
25
|
+
white-space: nowrap;
|
|
26
|
+
border: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Skip link - visible on focus */
|
|
30
|
+
.skip-link {
|
|
31
|
+
position: absolute;
|
|
32
|
+
top: -100%;
|
|
33
|
+
left: 50%;
|
|
34
|
+
transform: translateX(-50%);
|
|
35
|
+
z-index: 9999;
|
|
36
|
+
padding: 0.75rem 1.5rem;
|
|
37
|
+
background: var(--fallback-b1, oklch(var(--b1)));
|
|
38
|
+
border: 1px solid var(--fallback-b3, oklch(var(--b3)));
|
|
39
|
+
border-radius: 0.25rem;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.skip-link:focus {
|
|
43
|
+
top: 1rem;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Focus visible - keyboard only focus indicator */
|
|
47
|
+
:focus-visible {
|
|
48
|
+
outline: 2px solid oklch(var(--p));
|
|
49
|
+
outline-offset: 2px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Remove default focus for mouse users */
|
|
53
|
+
:focus:not(:focus-visible) {
|
|
54
|
+
outline: none;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* Respect reduced motion preferences */
|
|
58
|
+
@media (prefers-reduced-motion: reduce) {
|
|
59
|
+
*,
|
|
60
|
+
*::before,
|
|
61
|
+
*::after {
|
|
62
|
+
animation-duration: 0.01ms !important;
|
|
63
|
+
animation-iteration-count: 1 !important;
|
|
64
|
+
transition-duration: 0.01ms !important;
|
|
65
|
+
scroll-behavior: auto !important;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { StrictMode } from 'react'
|
|
2
|
+
import { createRoot } from 'react-dom/client'
|
|
3
|
+
import { BrowserRouter } from 'react-router-dom'
|
|
4
|
+
import { ThemeProvider } from './context/ThemeContext'
|
|
5
|
+
import App from './App'
|
|
6
|
+
import './index.css'
|
|
7
|
+
|
|
8
|
+
createRoot(document.getElementById('root')!).render(
|
|
9
|
+
<StrictMode>
|
|
10
|
+
<BrowserRouter>
|
|
11
|
+
<ThemeProvider>
|
|
12
|
+
<App />
|
|
13
|
+
</ThemeProvider>
|
|
14
|
+
</BrowserRouter>
|
|
15
|
+
</StrictMode>,
|
|
16
|
+
)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# MCP Server Setup
|
|
2
|
+
|
|
3
|
+
Model Context Protocol (MCP) servers extend Claude Code with external tools and data sources.
|
|
4
|
+
|
|
5
|
+
## Recommended MCP Servers
|
|
6
|
+
|
|
7
|
+
### Figma (Official)
|
|
8
|
+
|
|
9
|
+
Convert designs to code with direct Figma access.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
claude mcp add --transport http figma https://mcp.figma.com/mcp
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then authenticate:
|
|
16
|
+
1. Type `/mcp` in Claude Code
|
|
17
|
+
2. Select `figma`
|
|
18
|
+
3. Click "Authenticate" and allow access
|
|
19
|
+
|
|
20
|
+
**Usage:** Share a Figma frame URL and ask Claude to implement it.
|
|
21
|
+
|
|
22
|
+
### Browser Automation (Optional)
|
|
23
|
+
|
|
24
|
+
Control Chrome for testing and automation.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Requires Chrome extension: Claude in Chrome
|
|
28
|
+
claude mcp add chrome-automation
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Database (Optional)
|
|
32
|
+
|
|
33
|
+
Query databases directly from Claude.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# PostgreSQL
|
|
37
|
+
claude mcp add --transport stdio postgres npx @anthropic-ai/mcp-server-postgres $DATABASE_URL
|
|
38
|
+
|
|
39
|
+
# SQLite
|
|
40
|
+
claude mcp add --transport stdio sqlite npx @anthropic-ai/mcp-server-sqlite $DB_PATH
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Managing MCP Servers
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# List configured servers
|
|
47
|
+
claude mcp list
|
|
48
|
+
|
|
49
|
+
# Remove a server
|
|
50
|
+
claude mcp remove figma
|
|
51
|
+
|
|
52
|
+
# Check server status
|
|
53
|
+
/mcp
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Rate Limits
|
|
57
|
+
|
|
58
|
+
| Plan | Figma API Calls |
|
|
59
|
+
|------|-----------------|
|
|
60
|
+
| Starter/View/Collab | 6/month |
|
|
61
|
+
| Dev/Full (Professional+) | Per-minute limits |
|
|
62
|
+
|
|
63
|
+
## Troubleshooting
|
|
64
|
+
|
|
65
|
+
**"MCP server not responding"**
|
|
66
|
+
- Check `/mcp` status
|
|
67
|
+
- Re-authenticate if needed
|
|
68
|
+
- Ensure you have network access
|
|
69
|
+
|
|
70
|
+
**"Rate limit exceeded"**
|
|
71
|
+
- Wait or upgrade Figma plan
|
|
72
|
+
- Cache designs locally when possible
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
*The robots need credentials too. It's only fair.*
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(bun install)",
|
|
5
|
+
"Bash(bun install:*)",
|
|
6
|
+
"Bash(bun add:*)",
|
|
7
|
+
"Bash(bun remove:*)",
|
|
8
|
+
"Bash(bun run:*)",
|
|
9
|
+
"Bash(bun dev:*)",
|
|
10
|
+
"Bash(bun test:*)",
|
|
11
|
+
"Bash(bunx:*)",
|
|
12
|
+
"Bash(npx tsc:*)",
|
|
13
|
+
"Bash(git status)",
|
|
14
|
+
"Bash(git diff:*)",
|
|
15
|
+
"Bash(git log:*)",
|
|
16
|
+
"Bash(git branch:*)",
|
|
17
|
+
"Bash(git add:*)",
|
|
18
|
+
"Bash(git commit:*)",
|
|
19
|
+
"Bash(git checkout:*)",
|
|
20
|
+
"Bash(git merge:*)",
|
|
21
|
+
"Bash(git stash:*)",
|
|
22
|
+
"Bash(ls:*)",
|
|
23
|
+
"Bash(find:*)",
|
|
24
|
+
"Bash(tree:*)",
|
|
25
|
+
"Bash(wc:*)",
|
|
26
|
+
"Bash(grep:*)",
|
|
27
|
+
"Bash(curl:*)",
|
|
28
|
+
"WebSearch",
|
|
29
|
+
"Bash(gh auth status:*)",
|
|
30
|
+
"Bash(gh repo create:*)",
|
|
31
|
+
"Bash(npx vercel:*)",
|
|
32
|
+
"WebFetch(domain:github.com)",
|
|
33
|
+
"Bash(git clone:*)"
|
|
34
|
+
],
|
|
35
|
+
"deny": []
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Accessibility Audit
|
|
2
|
+
|
|
3
|
+
WCAG 2.1 AA compliance checklist for React components.
|
|
4
|
+
|
|
5
|
+
## Critical (Must Fix)
|
|
6
|
+
|
|
7
|
+
### Perceivable
|
|
8
|
+
|
|
9
|
+
| Check | WCAG | How to Fix |
|
|
10
|
+
|-------|------|------------|
|
|
11
|
+
| Images without alt | 1.1.1 | Add `alt="description"` or `alt=""` for decorative |
|
|
12
|
+
| Videos without captions | 1.2.2 | Add captions track |
|
|
13
|
+
| Color-only info | 1.4.1 | Add icon/text alongside color |
|
|
14
|
+
| Contrast < 4.5:1 | 1.4.3 | Use darker/lighter colors |
|
|
15
|
+
| Text resize breaks layout | 1.4.4 | Use relative units (rem) |
|
|
16
|
+
|
|
17
|
+
### Operable
|
|
18
|
+
|
|
19
|
+
| Check | WCAG | How to Fix |
|
|
20
|
+
|-------|------|------------|
|
|
21
|
+
| Not keyboard accessible | 2.1.1 | Add tabIndex, onKeyDown |
|
|
22
|
+
| No skip link | 2.4.1 | Add skip to main content link |
|
|
23
|
+
| Missing focus indicator | 2.4.7 | Use focus-visible, not outline-none |
|
|
24
|
+
| Touch target < 44px | 2.5.5 | Increase padding/size |
|
|
25
|
+
|
|
26
|
+
### Understandable
|
|
27
|
+
|
|
28
|
+
| Check | WCAG | How to Fix |
|
|
29
|
+
|-------|------|------------|
|
|
30
|
+
| No lang attribute | 3.1.1 | Add `<html lang="en">` |
|
|
31
|
+
| Form errors unclear | 3.3.1 | Show specific error messages |
|
|
32
|
+
| No labels on inputs | 3.3.2 | Add `<label>` or aria-label |
|
|
33
|
+
|
|
34
|
+
### Robust
|
|
35
|
+
|
|
36
|
+
| Check | WCAG | How to Fix |
|
|
37
|
+
|-------|------|------------|
|
|
38
|
+
| Invalid HTML | 4.1.1 | Fix nesting, duplicates |
|
|
39
|
+
| Missing ARIA labels | 4.1.2 | Add aria-label to icon buttons |
|
|
40
|
+
| Bad ARIA usage | 4.1.2 | Remove redundant/incorrect ARIA |
|
|
41
|
+
|
|
42
|
+
## Component Patterns
|
|
43
|
+
|
|
44
|
+
### Buttons
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
// ✗ Bad
|
|
48
|
+
<div onClick={handleClick}>Click me</div>
|
|
49
|
+
|
|
50
|
+
// ✓ Good
|
|
51
|
+
<button onClick={handleClick}>Click me</button>
|
|
52
|
+
|
|
53
|
+
// ✓ Icon button
|
|
54
|
+
<button onClick={handleClick} aria-label="Close dialog">
|
|
55
|
+
<XIcon aria-hidden="true" />
|
|
56
|
+
</button>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Links
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
// ✗ Bad
|
|
63
|
+
<a onClick={navigate}>Go somewhere</a>
|
|
64
|
+
|
|
65
|
+
// ✓ Good
|
|
66
|
+
<a href="/somewhere">Go somewhere</a>
|
|
67
|
+
|
|
68
|
+
// ✓ External link
|
|
69
|
+
<a href="https://..." target="_blank" rel="noopener noreferrer">
|
|
70
|
+
External site
|
|
71
|
+
<span className="sr-only">(opens in new tab)</span>
|
|
72
|
+
</a>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Forms
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
// ✓ Good
|
|
79
|
+
<div>
|
|
80
|
+
<label htmlFor="email">Email</label>
|
|
81
|
+
<input
|
|
82
|
+
id="email"
|
|
83
|
+
type="email"
|
|
84
|
+
aria-describedby="email-error"
|
|
85
|
+
aria-invalid={hasError}
|
|
86
|
+
/>
|
|
87
|
+
{hasError && (
|
|
88
|
+
<p id="email-error" role="alert">
|
|
89
|
+
Please enter a valid email
|
|
90
|
+
</p>
|
|
91
|
+
)}
|
|
92
|
+
</div>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Images
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
// Informative image
|
|
99
|
+
<img src="chart.png" alt="Sales increased 25% in Q4" />
|
|
100
|
+
|
|
101
|
+
// Decorative image
|
|
102
|
+
<img src="decoration.png" alt="" aria-hidden="true" />
|
|
103
|
+
|
|
104
|
+
// Complex image
|
|
105
|
+
<figure>
|
|
106
|
+
<img src="diagram.png" alt="System architecture" />
|
|
107
|
+
<figcaption>Detailed description...</figcaption>
|
|
108
|
+
</figure>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Required CSS
|
|
112
|
+
|
|
113
|
+
```css
|
|
114
|
+
/* Screen reader only */
|
|
115
|
+
.sr-only {
|
|
116
|
+
position: absolute;
|
|
117
|
+
width: 1px;
|
|
118
|
+
height: 1px;
|
|
119
|
+
padding: 0;
|
|
120
|
+
margin: -1px;
|
|
121
|
+
overflow: hidden;
|
|
122
|
+
clip: rect(0, 0, 0, 0);
|
|
123
|
+
white-space: nowrap;
|
|
124
|
+
border: 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* Respect motion preferences */
|
|
128
|
+
@media (prefers-reduced-motion: reduce) {
|
|
129
|
+
*, *::before, *::after {
|
|
130
|
+
animation-duration: 0.01ms !important;
|
|
131
|
+
animation-iteration-count: 1 !important;
|
|
132
|
+
transition-duration: 0.01ms !important;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* Focus visible (keyboard only) */
|
|
137
|
+
:focus-visible {
|
|
138
|
+
outline: 2px solid currentColor;
|
|
139
|
+
outline-offset: 2px;
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Testing Tools
|
|
144
|
+
|
|
145
|
+
- **axe DevTools** — Browser extension
|
|
146
|
+
- **WAVE** — wave.webaim.org
|
|
147
|
+
- **Lighthouse** — Chrome DevTools
|
|
148
|
+
- **VoiceOver** — macOS screen reader (Cmd + F5)
|
|
149
|
+
|
|
150
|
+
## Output Format
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
A11Y AUDIT: [component/page]
|
|
154
|
+
════════════════════════════
|
|
155
|
+
|
|
156
|
+
CRITICAL (2)
|
|
157
|
+
────────────
|
|
158
|
+
[4.1.2] Line 45: Button missing accessible name
|
|
159
|
+
<button><XIcon /></button>
|
|
160
|
+
Fix: Add aria-label="Close"
|
|
161
|
+
|
|
162
|
+
[2.4.7] Line 12: Focus outline removed without replacement
|
|
163
|
+
className="outline-none"
|
|
164
|
+
Fix: Use focus-visible styles instead
|
|
165
|
+
|
|
166
|
+
WARNINGS (1)
|
|
167
|
+
────────────
|
|
168
|
+
[2.5.5] Line 78: Touch target may be too small
|
|
169
|
+
className="p-1" (32px)
|
|
170
|
+
Fix: Increase to p-2.5 minimum (44px)
|
|
171
|
+
|
|
172
|
+
Score: 85/100 (AA compliant with warnings)
|
|
173
|
+
```
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Design Polish Skill
|
|
2
|
+
|
|
3
|
+
Use this skill when doing visual polish passes on UI components.
|
|
4
|
+
|
|
5
|
+
## Trigger
|
|
6
|
+
|
|
7
|
+
Use when user asks to "polish", "review design", "check UI consistency", or "do a design pass".
|
|
8
|
+
|
|
9
|
+
## Checklist
|
|
10
|
+
|
|
11
|
+
When reviewing components, systematically check:
|
|
12
|
+
|
|
13
|
+
### Spacing
|
|
14
|
+
- [ ] Consistent padding (use spacing scale: 4, 8, 16, 24, 32px)
|
|
15
|
+
- [ ] Proper margins between elements
|
|
16
|
+
- [ ] Alignment on grid
|
|
17
|
+
|
|
18
|
+
### Typography
|
|
19
|
+
- [ ] Clear hierarchy (heading > subhead > body > caption)
|
|
20
|
+
- [ ] Consistent font weights
|
|
21
|
+
- [ ] Proper line heights for readability
|
|
22
|
+
- [ ] No orphaned words in headlines
|
|
23
|
+
|
|
24
|
+
### Color
|
|
25
|
+
- [ ] Uses semantic colors (primary, secondary, base-content)
|
|
26
|
+
- [ ] Sufficient contrast ratios (4.5:1 for text)
|
|
27
|
+
- [ ] Consistent use of opacity for secondary elements
|
|
28
|
+
|
|
29
|
+
### Interaction States
|
|
30
|
+
- [ ] Hover states present
|
|
31
|
+
- [ ] Focus states for accessibility (visible focus ring)
|
|
32
|
+
- [ ] Active/pressed states
|
|
33
|
+
- [ ] Disabled states where appropriate
|
|
34
|
+
- [ ] Transitions smooth (150-300ms)
|
|
35
|
+
|
|
36
|
+
### Responsive
|
|
37
|
+
- [ ] Works at 375px (mobile)
|
|
38
|
+
- [ ] Works at 768px (tablet)
|
|
39
|
+
- [ ] Works at 1280px+ (desktop)
|
|
40
|
+
- [ ] Touch targets 44px+ on mobile
|
|
41
|
+
|
|
42
|
+
## Process
|
|
43
|
+
|
|
44
|
+
1. Read the component file(s)
|
|
45
|
+
2. Run through checklist silently
|
|
46
|
+
3. Report findings grouped by category
|
|
47
|
+
4. Offer to fix issues one at a time
|
|
48
|
+
5. Show before/after for each fix
|
|
49
|
+
|
|
50
|
+
## Output Format
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
## Polish Review: [Component Name]
|
|
54
|
+
|
|
55
|
+
### ✅ Passing
|
|
56
|
+
- Spacing is consistent
|
|
57
|
+
- Typography hierarchy is clear
|
|
58
|
+
|
|
59
|
+
### ⚠️ Issues Found
|
|
60
|
+
|
|
61
|
+
**Spacing**
|
|
62
|
+
- Card padding inconsistent (16px top, 12px bottom)
|
|
63
|
+
- Missing gap between icon and label
|
|
64
|
+
|
|
65
|
+
**Interaction**
|
|
66
|
+
- No hover state on clickable card
|
|
67
|
+
- Focus state missing
|
|
68
|
+
|
|
69
|
+
### Recommended Fixes
|
|
70
|
+
1. [Most impactful fix first]
|
|
71
|
+
2. [Second priority]
|
|
72
|
+
...
|
|
73
|
+
|
|
74
|
+
Shall I fix these one at a time?
|
|
75
|
+
```
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: figma-to-code
|
|
3
|
+
description: Convert Figma designs to React components with pixel-perfect accuracy
|
|
4
|
+
triggers:
|
|
5
|
+
- figma
|
|
6
|
+
- design to code
|
|
7
|
+
- implement design
|
|
8
|
+
- from figma
|
|
9
|
+
- mockup
|
|
10
|
+
- ui from design
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Figma to Code
|
|
14
|
+
|
|
15
|
+
Convert Figma designs into production-ready React components.
|
|
16
|
+
|
|
17
|
+
## Prerequisites
|
|
18
|
+
|
|
19
|
+
### MCP Server Setup
|
|
20
|
+
|
|
21
|
+
Run this command once to connect Figma to Claude Code:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
claude mcp add --transport http figma https://mcp.figma.com/mcp
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Then authenticate: type `/mcp` in Claude, select `figma`, and click "Authenticate".
|
|
28
|
+
|
|
29
|
+
## Workflow
|
|
30
|
+
|
|
31
|
+
### 1. Get the Figma Link
|
|
32
|
+
|
|
33
|
+
User provides a Figma frame URL like:
|
|
34
|
+
```
|
|
35
|
+
https://www.figma.com/design/ABC123/ProjectName?node-id=1-234
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 2. Analyze the Design
|
|
39
|
+
|
|
40
|
+
Use Figma MCP to inspect:
|
|
41
|
+
- **Layout structure** - Frames, auto-layout, constraints
|
|
42
|
+
- **Design tokens** - Colors, typography, spacing
|
|
43
|
+
- **Components** - Reusable elements, variants
|
|
44
|
+
- **Assets** - Icons, images (export if needed)
|
|
45
|
+
|
|
46
|
+
### 3. Map to React + Tailwind
|
|
47
|
+
|
|
48
|
+
| Figma Concept | React/Tailwind Equivalent |
|
|
49
|
+
|---------------|--------------------------|
|
|
50
|
+
| Frame | `<div>` with flex/grid |
|
|
51
|
+
| Auto Layout | `flex` + `gap-*` |
|
|
52
|
+
| Fill Container | `w-full` or `flex-1` |
|
|
53
|
+
| Hug Contents | `w-fit` |
|
|
54
|
+
| Constraints | `absolute` positioning |
|
|
55
|
+
| Corner Radius | `rounded-*` |
|
|
56
|
+
| Drop Shadow | `shadow-*` |
|
|
57
|
+
| Text Styles | `text-*` + `font-*` |
|
|
58
|
+
|
|
59
|
+
### 4. Generate Component
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
// Example output structure
|
|
63
|
+
interface ComponentProps {
|
|
64
|
+
// Props derived from Figma variants
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function ComponentName({ ...props }: ComponentProps) {
|
|
68
|
+
return (
|
|
69
|
+
<div className="/* Tailwind classes from Figma styles */">
|
|
70
|
+
{/* Child elements */}
|
|
71
|
+
</div>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Design Token Extraction
|
|
77
|
+
|
|
78
|
+
When you encounter repeated values in Figma:
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
// tailwind.config.js extension
|
|
82
|
+
module.exports = {
|
|
83
|
+
theme: {
|
|
84
|
+
extend: {
|
|
85
|
+
colors: {
|
|
86
|
+
// Extract from Figma color styles
|
|
87
|
+
'brand-primary': '#6366f1',
|
|
88
|
+
'brand-secondary': '#a855f7',
|
|
89
|
+
},
|
|
90
|
+
spacing: {
|
|
91
|
+
// Extract from Figma spacing
|
|
92
|
+
'18': '4.5rem',
|
|
93
|
+
},
|
|
94
|
+
borderRadius: {
|
|
95
|
+
// Extract from Figma corner radius
|
|
96
|
+
'card': '1.5rem',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Common Patterns
|
|
104
|
+
|
|
105
|
+
### Cards
|
|
106
|
+
```tsx
|
|
107
|
+
<div className="bg-base-100 rounded-xl p-6 shadow-lg">
|
|
108
|
+
{/* Card content */}
|
|
109
|
+
</div>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Buttons (from Figma variants)
|
|
113
|
+
```tsx
|
|
114
|
+
<button className={cn(
|
|
115
|
+
"btn",
|
|
116
|
+
variant === 'primary' && "btn-primary",
|
|
117
|
+
variant === 'secondary' && "btn-secondary btn-outline",
|
|
118
|
+
size === 'lg' && "btn-lg",
|
|
119
|
+
)}>
|
|
120
|
+
{children}
|
|
121
|
+
</button>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Responsive Layouts
|
|
125
|
+
```tsx
|
|
126
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
|
127
|
+
{/* Responsive grid from Figma breakpoints */}
|
|
128
|
+
</div>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Checklist
|
|
132
|
+
|
|
133
|
+
Before completing Figma-to-code conversion:
|
|
134
|
+
|
|
135
|
+
- [ ] Layout matches Figma at 1:1 zoom
|
|
136
|
+
- [ ] Colors use DaisyUI semantic classes (`bg-base-*`, `text-primary`)
|
|
137
|
+
- [ ] Typography uses Tailwind scale (`text-lg`, `font-semibold`)
|
|
138
|
+
- [ ] Spacing is consistent with Figma (use `gap-*`, `p-*`, `m-*`)
|
|
139
|
+
- [ ] Interactive states match Figma (hover, focus, active)
|
|
140
|
+
- [ ] Component is responsive (test at 320px, 768px, 1024px)
|
|
141
|
+
- [ ] Icons are imported from Lucide React
|
|
142
|
+
- [ ] No hardcoded colors (use theme variables)
|
|
143
|
+
|
|
144
|
+
## Limitations
|
|
145
|
+
|
|
146
|
+
- Complex animations need manual implementation
|
|
147
|
+
- Multi-frame flows (carousels, onboarding) require combining frames
|
|
148
|
+
- Design system updates may require regeneration
|
|
149
|
+
- Figma effects like blur may need CSS equivalents
|
|
150
|
+
|
|
151
|
+
## Dark Humor Corner
|
|
152
|
+
|
|
153
|
+
> "The design looked simple. The implementation had other plans."
|
|
154
|
+
|
|
155
|
+
> "Pixel-perfect is a lie we tell ourselves to feel productive."
|
|
156
|
+
|
|
157
|
+
> "That 4px difference? No one will notice. Except you. Forever."
|