agentic-loop 3.9.0 → 3.10.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/.claude/commands/tour.md +56 -4
- package/.claude/skills/explain/SKILL.md +114 -0
- package/.claude/skills/idea/SKILL.md +216 -0
- package/.claude/skills/my-dna/SKILL.md +122 -0
- package/.claude/skills/prd/SKILL.md +770 -0
- package/.claude/skills/review/SKILL.md +167 -0
- package/.claude/skills/sign/SKILL.md +32 -0
- package/.claude/skills/styleguide/SKILL.md +450 -0
- package/.claude/skills/tour/SKILL.md +353 -0
- package/.claude/skills/vibe-check/SKILL.md +116 -0
- package/.claude/skills/vibe-help/SKILL.md +47 -0
- package/.claude/skills/vibe-list/SKILL.md +203 -0
- package/package.json +1 -1
- package/ralph/setup.sh +10 -3
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Review code for issues, improvements, and best practices.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Code Review
|
|
6
|
+
|
|
7
|
+
Review code for issues, improvements, and best practices.
|
|
8
|
+
|
|
9
|
+
## Instructions
|
|
10
|
+
|
|
11
|
+
When asked to review code, perform a thorough analysis looking for:
|
|
12
|
+
|
|
13
|
+
### 1. Security Issues (Critical) - OWASP Top 10
|
|
14
|
+
|
|
15
|
+
- [ ] **Injection**: SQL, command, LDAP injection via string concatenation
|
|
16
|
+
- [ ] **XSS**: innerHTML, dangerouslySetInnerHTML, v-html with user data
|
|
17
|
+
- [ ] **Broken Auth**: Hardcoded credentials, weak passwords, missing rate limiting
|
|
18
|
+
- [ ] **Sensitive Data Exposure**: Secrets in code, sensitive data in logs/URLs
|
|
19
|
+
- [ ] **Broken Access Control**: Missing auth checks, IDOR, privilege escalation
|
|
20
|
+
- [ ] **Security Misconfiguration**: Debug mode, default credentials, verbose errors
|
|
21
|
+
- [ ] **Insecure Deserialization**: pickle, eval() with user input
|
|
22
|
+
- [ ] **Vulnerable Dependencies**: Outdated packages with known CVEs
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// VULNERABLE - SQL injection
|
|
26
|
+
const query = `SELECT * FROM users WHERE name = '${userInput}'`;
|
|
27
|
+
|
|
28
|
+
// SAFE - parameterized query
|
|
29
|
+
const query = "SELECT * FROM users WHERE name = ?";
|
|
30
|
+
db.execute(query, [userInput]);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
// VULNERABLE - XSS
|
|
35
|
+
element.innerHTML = userInput;
|
|
36
|
+
|
|
37
|
+
// SAFE
|
|
38
|
+
element.textContent = userInput;
|
|
39
|
+
// or with sanitization
|
|
40
|
+
element.innerHTML = DOMPurify.sanitize(userInput);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 2. Error Handling (High)
|
|
44
|
+
|
|
45
|
+
- [ ] Empty catch blocks
|
|
46
|
+
- [ ] Missing error boundaries
|
|
47
|
+
- [ ] Unhandled promise rejections
|
|
48
|
+
- [ ] Missing null/undefined checks
|
|
49
|
+
- [ ] Silent failures
|
|
50
|
+
|
|
51
|
+
### 3. Type Safety (High for TypeScript)
|
|
52
|
+
|
|
53
|
+
- [ ] Usage of `any` type
|
|
54
|
+
- [ ] Missing type annotations
|
|
55
|
+
- [ ] Type assertions that could fail
|
|
56
|
+
- [ ] Inconsistent types
|
|
57
|
+
|
|
58
|
+
### 4. Code Quality (Medium)
|
|
59
|
+
|
|
60
|
+
- [ ] Functions over 50 lines
|
|
61
|
+
- [ ] Deep nesting (4+ levels)
|
|
62
|
+
- [ ] Code duplication
|
|
63
|
+
- [ ] Magic numbers
|
|
64
|
+
- [ ] Unclear variable names
|
|
65
|
+
- [ ] Missing or outdated comments
|
|
66
|
+
|
|
67
|
+
### 5. Performance (Medium)
|
|
68
|
+
|
|
69
|
+
- [ ] N+1 query patterns
|
|
70
|
+
- [ ] Missing memoization for expensive operations
|
|
71
|
+
- [ ] Unnecessary re-renders (React)
|
|
72
|
+
- [ ] Large bundle imports
|
|
73
|
+
- [ ] Missing pagination
|
|
74
|
+
|
|
75
|
+
### 6. Maintainability (Low)
|
|
76
|
+
|
|
77
|
+
- [ ] Dead code
|
|
78
|
+
- [ ] Commented-out code
|
|
79
|
+
- [ ] TODOs that should be addressed
|
|
80
|
+
- [ ] Inconsistent patterns
|
|
81
|
+
- [ ] Missing tests
|
|
82
|
+
|
|
83
|
+
## Output Format
|
|
84
|
+
|
|
85
|
+
Structure your review like this:
|
|
86
|
+
|
|
87
|
+
```markdown
|
|
88
|
+
## Code Review: [filename or description]
|
|
89
|
+
|
|
90
|
+
### Summary
|
|
91
|
+
[1-2 sentence overview of the code quality]
|
|
92
|
+
|
|
93
|
+
### Critical Issues
|
|
94
|
+
These must be fixed before merging:
|
|
95
|
+
|
|
96
|
+
1. **[Issue Title]** (Line X)
|
|
97
|
+
- Problem: [What's wrong]
|
|
98
|
+
- Risk: [What could happen]
|
|
99
|
+
- Fix: [How to fix it]
|
|
100
|
+
```
|
|
101
|
+
[Code suggestion if applicable]
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Improvements
|
|
105
|
+
These should be addressed:
|
|
106
|
+
|
|
107
|
+
1. **[Issue Title]** (Line X)
|
|
108
|
+
- Current: [What it does now]
|
|
109
|
+
- Better: [What it should do]
|
|
110
|
+
- Why: [Benefit of changing]
|
|
111
|
+
|
|
112
|
+
### Minor Suggestions
|
|
113
|
+
Nice to have, low priority:
|
|
114
|
+
|
|
115
|
+
1. **[Suggestion]** (Line X)
|
|
116
|
+
- [Brief explanation]
|
|
117
|
+
|
|
118
|
+
### What's Good
|
|
119
|
+
[Acknowledge good patterns and practices in the code]
|
|
120
|
+
|
|
121
|
+
### Verdict
|
|
122
|
+
[ ] Ready to merge
|
|
123
|
+
[ ] Needs minor changes
|
|
124
|
+
[ ] Needs significant changes
|
|
125
|
+
[ ] Needs rewrite
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Severity Guide
|
|
129
|
+
|
|
130
|
+
| Severity | Block Merge? | Examples |
|
|
131
|
+
|----------|--------------|----------|
|
|
132
|
+
| Critical | Yes | Security vulnerabilities, data loss risks |
|
|
133
|
+
| High | Yes | Missing error handling, type safety issues |
|
|
134
|
+
| Medium | Review | Performance issues, code quality |
|
|
135
|
+
| Low | No | Style preferences, minor improvements |
|
|
136
|
+
|
|
137
|
+
## Review Modes
|
|
138
|
+
|
|
139
|
+
### Quick Review
|
|
140
|
+
Focus only on critical and high-severity issues:
|
|
141
|
+
> "Quick review of this code"
|
|
142
|
+
|
|
143
|
+
### Full Review
|
|
144
|
+
Check everything:
|
|
145
|
+
> "Full review of src/api/users.ts"
|
|
146
|
+
|
|
147
|
+
### Security Review (OWASP Top 10)
|
|
148
|
+
Deep dive on security - injection, XSS, auth, access control, secrets:
|
|
149
|
+
> "Security review of the authentication flow"
|
|
150
|
+
> "Check for SQL injection vulnerabilities"
|
|
151
|
+
> "Full security audit of the API endpoints"
|
|
152
|
+
|
|
153
|
+
### Performance Review
|
|
154
|
+
Focus on performance:
|
|
155
|
+
> "Performance review of the dashboard page"
|
|
156
|
+
|
|
157
|
+
### Dependency Audit
|
|
158
|
+
Check for vulnerable dependencies:
|
|
159
|
+
> "Check our dependencies for known vulnerabilities"
|
|
160
|
+
|
|
161
|
+
## Be Constructive
|
|
162
|
+
|
|
163
|
+
- Explain **why** something is an issue, not just that it is
|
|
164
|
+
- Provide **specific** suggestions for fixes
|
|
165
|
+
- Acknowledge what's **done well**
|
|
166
|
+
- Be **respectful** - we all make mistakes
|
|
167
|
+
- Focus on the **code**, not the coder
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Add a learned pattern (sign) that Ralph will remember for future stories.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Add Sign
|
|
6
|
+
|
|
7
|
+
The user wants to add a sign - a pattern or rule that Ralph should remember for all future work.
|
|
8
|
+
|
|
9
|
+
**Get the pattern from the user.** Ask:
|
|
10
|
+
1. What's the pattern or rule? (e.g., "Always use select_related for foreign keys")
|
|
11
|
+
2. What category? (frontend, backend, general, testing)
|
|
12
|
+
|
|
13
|
+
**Then run:**
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx ralph sign "THE PATTERN HERE" CATEGORY
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Examples:**
|
|
20
|
+
```bash
|
|
21
|
+
npx ralph sign "Never hardcode AI model names - use env vars" backend
|
|
22
|
+
npx ralph sign "Always add data-testid for Playwright tests" frontend
|
|
23
|
+
npx ralph sign "Use useCallback for event handlers passed to children" frontend
|
|
24
|
+
npx ralph sign "Always paginate list endpoints" backend
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**After adding, confirm:** "Added sign. Ralph will include this in every future story prompt."
|
|
28
|
+
|
|
29
|
+
**To see all signs:**
|
|
30
|
+
```bash
|
|
31
|
+
npx ralph signs
|
|
32
|
+
```
|
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Generate a complete HTML/React styleguide page for your project based on your design preferences.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Styleguide Generator
|
|
6
|
+
|
|
7
|
+
Generate a complete HTML/React styleguide page for your project based on your design preferences.
|
|
8
|
+
|
|
9
|
+
## Instructions
|
|
10
|
+
|
|
11
|
+
This skill creates a `/styleguide` route that displays all your UI components, making it easy for AI to understand and replicate your design system.
|
|
12
|
+
|
|
13
|
+
### Phase 1: Discovery
|
|
14
|
+
|
|
15
|
+
First, understand the project:
|
|
16
|
+
|
|
17
|
+
**Check the tech stack:**
|
|
18
|
+
- Look for `package.json` to identify the framework (React, Vue, Next.js, etc.)
|
|
19
|
+
- Check for existing styling solution (Tailwind, CSS Modules, styled-components, etc.)
|
|
20
|
+
- Find the components directory structure
|
|
21
|
+
- Look for any existing design tokens or theme files
|
|
22
|
+
|
|
23
|
+
**Check for existing components:**
|
|
24
|
+
- Search for `components/` or `src/components/`
|
|
25
|
+
- Look for existing Button, Input, Card components
|
|
26
|
+
- Note any UI library usage (shadcn, MUI, Chakra, etc.)
|
|
27
|
+
|
|
28
|
+
### Phase 2: Interview the User
|
|
29
|
+
|
|
30
|
+
Ask these questions to understand their design vision. Present them as a friendly conversation:
|
|
31
|
+
|
|
32
|
+
**1. "What's the vibe you're going for?"**
|
|
33
|
+
|
|
34
|
+
Offer examples:
|
|
35
|
+
- **Clean & Minimal** - Lots of whitespace, subtle shadows, muted colors
|
|
36
|
+
- **Bold & Vibrant** - Saturated colors, strong contrasts, energetic
|
|
37
|
+
- **Dark & Moody** - Dark backgrounds, neon accents, atmospheric
|
|
38
|
+
- **Soft & Friendly** - Rounded corners, pastels, warm feeling
|
|
39
|
+
- **Professional & Corporate** - Conservative, trustworthy, structured
|
|
40
|
+
- **Playful & Fun** - Bright colors, animations, personality
|
|
41
|
+
- **Neon Glass** - Glassmorphism, glows, futuristic
|
|
42
|
+
- **Other** - Let them describe it
|
|
43
|
+
|
|
44
|
+
**2. "What are your brand colors?"**
|
|
45
|
+
|
|
46
|
+
Ask for:
|
|
47
|
+
- **Primary color** - Main brand color (buttons, links, accents)
|
|
48
|
+
- **Secondary color** - Supporting color
|
|
49
|
+
- **Accent color** - For highlights and CTAs (optional)
|
|
50
|
+
|
|
51
|
+
If they don't have colors, suggest palettes based on their vibe:
|
|
52
|
+
- Clean: Blue (#3B82F6) + Gray
|
|
53
|
+
- Bold: Orange (#F97316) + Purple (#8B5CF6)
|
|
54
|
+
- Dark: Cyan (#06B6D4) + Purple (#A855F7)
|
|
55
|
+
- Soft: Pink (#EC4899) + Lavender (#A78BFA)
|
|
56
|
+
- Professional: Navy (#1E40AF) + Gold (#F59E0B)
|
|
57
|
+
|
|
58
|
+
**3. "Light mode, dark mode, or both?"**
|
|
59
|
+
|
|
60
|
+
- Light mode only
|
|
61
|
+
- Dark mode only
|
|
62
|
+
- Both (with toggle)
|
|
63
|
+
|
|
64
|
+
**4. "What's your border radius preference?"**
|
|
65
|
+
|
|
66
|
+
- **Sharp** - 0px (modern, editorial)
|
|
67
|
+
- **Subtle** - 4px (clean, professional)
|
|
68
|
+
- **Rounded** - 8px (friendly, approachable)
|
|
69
|
+
- **Pill** - 9999px for buttons (playful)
|
|
70
|
+
- **Mixed** - Rounded cards, pill buttons
|
|
71
|
+
|
|
72
|
+
**5. "Any specific components you need?"**
|
|
73
|
+
|
|
74
|
+
Common ones to include:
|
|
75
|
+
- Buttons (primary, secondary, ghost, destructive)
|
|
76
|
+
- Form inputs (text, select, checkbox, radio, toggle)
|
|
77
|
+
- Cards
|
|
78
|
+
- Modals/Dialogs
|
|
79
|
+
- Alerts/Toasts
|
|
80
|
+
- Navigation
|
|
81
|
+
- Tables
|
|
82
|
+
- Badges/Tags
|
|
83
|
+
|
|
84
|
+
### Phase 3: Generate the Styleguide
|
|
85
|
+
|
|
86
|
+
Create a styleguide page at `/styleguide` (or their preferred route).
|
|
87
|
+
|
|
88
|
+
**File structure for React/Next.js:**
|
|
89
|
+
```
|
|
90
|
+
src/
|
|
91
|
+
├── pages/styleguide.tsx (or app/styleguide/page.tsx for Next.js App Router)
|
|
92
|
+
└── styles/
|
|
93
|
+
└── design-tokens.css (optional CSS variables)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Include these sections:**
|
|
97
|
+
|
|
98
|
+
#### 1. Design Tokens
|
|
99
|
+
```tsx
|
|
100
|
+
<section id="tokens">
|
|
101
|
+
<h2>Design Tokens</h2>
|
|
102
|
+
|
|
103
|
+
{/* Colors */}
|
|
104
|
+
<div className="grid grid-cols-5 gap-4">
|
|
105
|
+
<div className="h-20 rounded-lg bg-primary" title="Primary" />
|
|
106
|
+
<div className="h-20 rounded-lg bg-secondary" title="Secondary" />
|
|
107
|
+
<div className="h-20 rounded-lg bg-accent" title="Accent" />
|
|
108
|
+
<div className="h-20 rounded-lg bg-background" title="Background" />
|
|
109
|
+
<div className="h-20 rounded-lg bg-foreground" title="Foreground" />
|
|
110
|
+
</div>
|
|
111
|
+
|
|
112
|
+
{/* Typography Scale */}
|
|
113
|
+
<div className="space-y-2 mt-8">
|
|
114
|
+
<p className="text-xs">xs - 12px</p>
|
|
115
|
+
<p className="text-sm">sm - 14px</p>
|
|
116
|
+
<p className="text-base">base - 16px</p>
|
|
117
|
+
<p className="text-lg">lg - 18px</p>
|
|
118
|
+
<p className="text-xl">xl - 20px</p>
|
|
119
|
+
<p className="text-2xl">2xl - 24px</p>
|
|
120
|
+
<p className="text-3xl">3xl - 30px</p>
|
|
121
|
+
<p className="text-4xl">4xl - 36px</p>
|
|
122
|
+
</div>
|
|
123
|
+
|
|
124
|
+
{/* Spacing */}
|
|
125
|
+
<div className="flex items-end gap-2 mt-8">
|
|
126
|
+
<div className="w-1 h-1 bg-primary" title="1 - 4px" />
|
|
127
|
+
<div className="w-2 h-2 bg-primary" title="2 - 8px" />
|
|
128
|
+
<div className="w-3 h-3 bg-primary" title="3 - 12px" />
|
|
129
|
+
<div className="w-4 h-4 bg-primary" title="4 - 16px" />
|
|
130
|
+
<div className="w-6 h-6 bg-primary" title="6 - 24px" />
|
|
131
|
+
<div className="w-8 h-8 bg-primary" title="8 - 32px" />
|
|
132
|
+
</div>
|
|
133
|
+
</section>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### 2. Buttons
|
|
137
|
+
```tsx
|
|
138
|
+
<section id="buttons">
|
|
139
|
+
<h2>Buttons</h2>
|
|
140
|
+
|
|
141
|
+
{/* Variants */}
|
|
142
|
+
<div className="flex flex-wrap gap-4">
|
|
143
|
+
<Button variant="primary">Primary</Button>
|
|
144
|
+
<Button variant="secondary">Secondary</Button>
|
|
145
|
+
<Button variant="ghost">Ghost</Button>
|
|
146
|
+
<Button variant="destructive">Destructive</Button>
|
|
147
|
+
<Button variant="link">Link</Button>
|
|
148
|
+
</div>
|
|
149
|
+
|
|
150
|
+
{/* Sizes */}
|
|
151
|
+
<div className="flex items-center gap-4 mt-4">
|
|
152
|
+
<Button size="sm">Small</Button>
|
|
153
|
+
<Button size="md">Medium</Button>
|
|
154
|
+
<Button size="lg">Large</Button>
|
|
155
|
+
</div>
|
|
156
|
+
|
|
157
|
+
{/* States */}
|
|
158
|
+
<div className="flex flex-wrap gap-4 mt-4">
|
|
159
|
+
<Button>Default</Button>
|
|
160
|
+
<Button disabled>Disabled</Button>
|
|
161
|
+
<Button loading>Loading</Button>
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
{/* With Icons */}
|
|
165
|
+
<div className="flex gap-4 mt-4">
|
|
166
|
+
<Button><PlusIcon /> Add Item</Button>
|
|
167
|
+
<Button>Next <ArrowRightIcon /></Button>
|
|
168
|
+
<Button size="icon"><SearchIcon /></Button>
|
|
169
|
+
</div>
|
|
170
|
+
</section>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### 3. Form Inputs
|
|
174
|
+
```tsx
|
|
175
|
+
<section id="forms">
|
|
176
|
+
<h2>Form Inputs</h2>
|
|
177
|
+
|
|
178
|
+
{/* Text Inputs */}
|
|
179
|
+
<div className="space-y-4 max-w-md">
|
|
180
|
+
<Input label="Default" placeholder="Enter text..." />
|
|
181
|
+
<Input label="With value" value="Hello world" />
|
|
182
|
+
<Input label="Disabled" disabled value="Can't edit" />
|
|
183
|
+
<Input label="With error" error="This field is required" />
|
|
184
|
+
<Input label="With helper" helper="We'll never share your email" />
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
{/* Select */}
|
|
188
|
+
<Select label="Choose option">
|
|
189
|
+
<option>Option 1</option>
|
|
190
|
+
<option>Option 2</option>
|
|
191
|
+
<option>Option 3</option>
|
|
192
|
+
</Select>
|
|
193
|
+
|
|
194
|
+
{/* Checkbox & Radio */}
|
|
195
|
+
<div className="space-y-2 mt-4">
|
|
196
|
+
<Checkbox label="Accept terms" />
|
|
197
|
+
<Checkbox label="Checked" checked />
|
|
198
|
+
<Checkbox label="Disabled" disabled />
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
{/* Toggle */}
|
|
202
|
+
<div className="flex gap-4 mt-4">
|
|
203
|
+
<Toggle label="Off" />
|
|
204
|
+
<Toggle label="On" checked />
|
|
205
|
+
</div>
|
|
206
|
+
</section>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
#### 4. Cards
|
|
210
|
+
```tsx
|
|
211
|
+
<section id="cards">
|
|
212
|
+
<h2>Cards</h2>
|
|
213
|
+
|
|
214
|
+
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
|
|
215
|
+
{/* Basic Card */}
|
|
216
|
+
<Card>
|
|
217
|
+
<CardHeader>
|
|
218
|
+
<CardTitle>Card Title</CardTitle>
|
|
219
|
+
<CardDescription>Card description goes here</CardDescription>
|
|
220
|
+
</CardHeader>
|
|
221
|
+
<CardContent>
|
|
222
|
+
<p>Card content with some text.</p>
|
|
223
|
+
</CardContent>
|
|
224
|
+
</Card>
|
|
225
|
+
|
|
226
|
+
{/* Card with Image */}
|
|
227
|
+
<Card>
|
|
228
|
+
<img src="/placeholder.jpg" className="w-full h-40 object-cover" />
|
|
229
|
+
<CardContent>
|
|
230
|
+
<h3>Image Card</h3>
|
|
231
|
+
<p>Card with image header</p>
|
|
232
|
+
</CardContent>
|
|
233
|
+
</Card>
|
|
234
|
+
|
|
235
|
+
{/* Interactive Card */}
|
|
236
|
+
<Card hover clickable>
|
|
237
|
+
<CardContent>
|
|
238
|
+
<h3>Interactive</h3>
|
|
239
|
+
<p>Hover and click states</p>
|
|
240
|
+
</CardContent>
|
|
241
|
+
</Card>
|
|
242
|
+
</div>
|
|
243
|
+
</section>
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
#### 5. Feedback Components
|
|
247
|
+
```tsx
|
|
248
|
+
<section id="feedback">
|
|
249
|
+
<h2>Feedback</h2>
|
|
250
|
+
|
|
251
|
+
{/* Alerts */}
|
|
252
|
+
<div className="space-y-4">
|
|
253
|
+
<Alert variant="info">This is an info message</Alert>
|
|
254
|
+
<Alert variant="success">Success! Your changes were saved.</Alert>
|
|
255
|
+
<Alert variant="warning">Warning: This action cannot be undone.</Alert>
|
|
256
|
+
<Alert variant="error">Error: Something went wrong.</Alert>
|
|
257
|
+
</div>
|
|
258
|
+
|
|
259
|
+
{/* Badges */}
|
|
260
|
+
<div className="flex gap-2 mt-6">
|
|
261
|
+
<Badge>Default</Badge>
|
|
262
|
+
<Badge variant="success">Success</Badge>
|
|
263
|
+
<Badge variant="warning">Warning</Badge>
|
|
264
|
+
<Badge variant="error">Error</Badge>
|
|
265
|
+
</div>
|
|
266
|
+
|
|
267
|
+
{/* Loading States */}
|
|
268
|
+
<div className="flex gap-4 mt-6">
|
|
269
|
+
<Spinner size="sm" />
|
|
270
|
+
<Spinner size="md" />
|
|
271
|
+
<Spinner size="lg" />
|
|
272
|
+
<Skeleton className="h-4 w-32" />
|
|
273
|
+
<Skeleton className="h-10 w-full" />
|
|
274
|
+
</div>
|
|
275
|
+
</section>
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Phase 4: Generate Component Files
|
|
279
|
+
|
|
280
|
+
If components don't exist yet, create them based on the user's preferences.
|
|
281
|
+
|
|
282
|
+
**Example Button component (Tailwind + React):**
|
|
283
|
+
```tsx
|
|
284
|
+
// src/components/ui/Button.tsx
|
|
285
|
+
import { forwardRef } from 'react';
|
|
286
|
+
import { cn } from '@/lib/utils';
|
|
287
|
+
|
|
288
|
+
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
289
|
+
variant?: 'primary' | 'secondary' | 'ghost' | 'destructive' | 'link';
|
|
290
|
+
size?: 'sm' | 'md' | 'lg' | 'icon';
|
|
291
|
+
loading?: boolean;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
295
|
+
({ className, variant = 'primary', size = 'md', loading, children, disabled, ...props }, ref) => {
|
|
296
|
+
return (
|
|
297
|
+
<button
|
|
298
|
+
ref={ref}
|
|
299
|
+
disabled={disabled || loading}
|
|
300
|
+
className={cn(
|
|
301
|
+
// Base styles
|
|
302
|
+
'inline-flex items-center justify-center font-medium transition-colors',
|
|
303
|
+
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2',
|
|
304
|
+
'disabled:pointer-events-none disabled:opacity-50',
|
|
305
|
+
|
|
306
|
+
// Variants (customize based on user's vibe)
|
|
307
|
+
{
|
|
308
|
+
'bg-primary text-primary-foreground hover:bg-primary/90': variant === 'primary',
|
|
309
|
+
'bg-secondary text-secondary-foreground hover:bg-secondary/80': variant === 'secondary',
|
|
310
|
+
'hover:bg-accent hover:text-accent-foreground': variant === 'ghost',
|
|
311
|
+
'bg-destructive text-destructive-foreground hover:bg-destructive/90': variant === 'destructive',
|
|
312
|
+
'text-primary underline-offset-4 hover:underline': variant === 'link',
|
|
313
|
+
},
|
|
314
|
+
|
|
315
|
+
// Sizes
|
|
316
|
+
{
|
|
317
|
+
'h-8 px-3 text-sm rounded-md': size === 'sm',
|
|
318
|
+
'h-10 px-4 text-sm rounded-md': size === 'md',
|
|
319
|
+
'h-12 px-6 text-base rounded-lg': size === 'lg',
|
|
320
|
+
'h-10 w-10 rounded-md': size === 'icon',
|
|
321
|
+
},
|
|
322
|
+
|
|
323
|
+
className
|
|
324
|
+
)}
|
|
325
|
+
{...props}
|
|
326
|
+
>
|
|
327
|
+
{loading ? <Spinner className="mr-2" size="sm" /> : null}
|
|
328
|
+
{children}
|
|
329
|
+
</button>
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
);
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### Phase 5: Add CSS Variables
|
|
336
|
+
|
|
337
|
+
Create design tokens as CSS variables for easy theming:
|
|
338
|
+
|
|
339
|
+
```css
|
|
340
|
+
/* src/styles/design-tokens.css */
|
|
341
|
+
:root {
|
|
342
|
+
/* Colors - Light Mode */
|
|
343
|
+
--color-primary: 59 130 246; /* blue-500 */
|
|
344
|
+
--color-secondary: 100 116 139; /* slate-500 */
|
|
345
|
+
--color-accent: 168 85 247; /* purple-500 */
|
|
346
|
+
--color-background: 255 255 255; /* white */
|
|
347
|
+
--color-foreground: 15 23 42; /* slate-900 */
|
|
348
|
+
--color-muted: 241 245 249; /* slate-100 */
|
|
349
|
+
--color-border: 226 232 240; /* slate-200 */
|
|
350
|
+
|
|
351
|
+
/* Feedback Colors */
|
|
352
|
+
--color-success: 34 197 94; /* green-500 */
|
|
353
|
+
--color-warning: 234 179 8; /* yellow-500 */
|
|
354
|
+
--color-error: 239 68 68; /* red-500 */
|
|
355
|
+
--color-info: 59 130 246; /* blue-500 */
|
|
356
|
+
|
|
357
|
+
/* Spacing */
|
|
358
|
+
--spacing-unit: 4px;
|
|
359
|
+
|
|
360
|
+
/* Border Radius */
|
|
361
|
+
--radius-sm: 4px;
|
|
362
|
+
--radius-md: 8px;
|
|
363
|
+
--radius-lg: 12px;
|
|
364
|
+
--radius-full: 9999px;
|
|
365
|
+
|
|
366
|
+
/* Shadows */
|
|
367
|
+
--shadow-sm: 0 1px 2px rgb(0 0 0 / 0.05);
|
|
368
|
+
--shadow-md: 0 4px 6px rgb(0 0 0 / 0.1);
|
|
369
|
+
--shadow-lg: 0 10px 15px rgb(0 0 0 / 0.1);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/* Dark Mode */
|
|
373
|
+
.dark {
|
|
374
|
+
--color-background: 15 23 42; /* slate-900 */
|
|
375
|
+
--color-foreground: 248 250 252; /* slate-50 */
|
|
376
|
+
--color-muted: 30 41 59; /* slate-800 */
|
|
377
|
+
--color-border: 51 65 85; /* slate-700 */
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Phase 6: Update CLAUDE.md
|
|
382
|
+
|
|
383
|
+
Add the styleguide reference to the project's CLAUDE.md:
|
|
384
|
+
|
|
385
|
+
```markdown
|
|
386
|
+
## Design System
|
|
387
|
+
|
|
388
|
+
Reference `/styleguide` for all UI components and design tokens.
|
|
389
|
+
|
|
390
|
+
### Quick Reference
|
|
391
|
+
- Primary: [color]
|
|
392
|
+
- Border Radius: [preference]
|
|
393
|
+
- Mode: [light/dark/both]
|
|
394
|
+
|
|
395
|
+
### Components
|
|
396
|
+
Use components from `@/components/ui`:
|
|
397
|
+
- Button, Input, Select, Checkbox, Toggle
|
|
398
|
+
- Card, Alert, Badge, Modal
|
|
399
|
+
- All variants shown in /styleguide
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### Vibe-Specific Templates
|
|
403
|
+
|
|
404
|
+
**Neon Glass:**
|
|
405
|
+
```tsx
|
|
406
|
+
// Dark background with glassmorphism
|
|
407
|
+
<div className="bg-black min-h-screen">
|
|
408
|
+
<Card className="
|
|
409
|
+
bg-white/5 backdrop-blur-xl
|
|
410
|
+
border border-white/10
|
|
411
|
+
shadow-[0_0_30px_rgba(0,255,255,0.1)]
|
|
412
|
+
">
|
|
413
|
+
<h2 className="text-transparent bg-clip-text bg-gradient-to-r from-cyan-400 to-purple-500">
|
|
414
|
+
Neon Glass
|
|
415
|
+
</h2>
|
|
416
|
+
</Card>
|
|
417
|
+
</div>
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
**Clean & Minimal:**
|
|
421
|
+
```tsx
|
|
422
|
+
// Lots of whitespace, subtle shadows
|
|
423
|
+
<div className="bg-gray-50 min-h-screen p-12">
|
|
424
|
+
<Card className="bg-white shadow-sm border border-gray-100 rounded-lg">
|
|
425
|
+
<h2 className="text-gray-900 font-light tracking-tight">
|
|
426
|
+
Clean & Minimal
|
|
427
|
+
</h2>
|
|
428
|
+
</Card>
|
|
429
|
+
</div>
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
**Bold & Vibrant:**
|
|
433
|
+
```tsx
|
|
434
|
+
// Strong colors, high contrast
|
|
435
|
+
<div className="bg-gradient-to-br from-orange-500 to-pink-600 min-h-screen">
|
|
436
|
+
<Card className="bg-white rounded-2xl shadow-2xl">
|
|
437
|
+
<h2 className="text-3xl font-black text-gray-900">
|
|
438
|
+
Bold & Vibrant
|
|
439
|
+
</h2>
|
|
440
|
+
</Card>
|
|
441
|
+
</div>
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
## Notes
|
|
445
|
+
|
|
446
|
+
- Always create components that match the user's chosen vibe
|
|
447
|
+
- Include all states (hover, active, focus, disabled, loading)
|
|
448
|
+
- Make the styleguide itself match the design system
|
|
449
|
+
- Add code snippets so developers can copy usage examples
|
|
450
|
+
- Test in both light and dark mode if applicable
|