@musashishao/agent-kit 1.6.2 → 1.8.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/.agent/rules/CODEX.md +8 -7
- package/.agent/rules/CODE_RULES.md +15 -0
- package/.agent/rules/REFERENCE.md +7 -2
- package/.agent/skills/brainstorming/SKILL.md +52 -0
- package/.agent/skills/frontend-design/SKILL.md +30 -0
- package/.agent/skills/git-worktrees/SKILL.md +181 -0
- package/.agent/skills/parallel-agents/SKILL.md +89 -0
- package/.agent/skills/react-patterns/SKILL.md +31 -0
- package/.agent/skills/react-patterns/bundle-patterns.md +129 -0
- package/.agent/skills/react-patterns/rerender-patterns.md +163 -0
- package/.agent/skills/react-patterns/server-patterns.md +146 -0
- package/.agent/skills/react-patterns/waterfall-patterns.md +102 -0
- package/.agent/skills/reader-testing/SKILL.md +183 -0
- package/.agent/skills/verification-gate/SKILL.md +129 -0
- package/.agent/skills/web-interface-guidelines/SKILL.md +94 -0
- package/.agent/skills/web-interface-guidelines/animation.md +153 -0
- package/.agent/skills/web-interface-guidelines/anti-patterns.md +204 -0
- package/.agent/skills/web-interface-guidelines/focus-states.md +104 -0
- package/.agent/skills/web-interface-guidelines/forms.md +154 -0
- package/.agent/skills/web-interface-guidelines/touch-interaction.md +150 -0
- package/.agent/workflows/autofix.md +4 -1
- package/.agent/workflows/brainstorm.md +1 -1
- package/.agent/workflows/context.md +3 -1
- package/.agent/workflows/create.md +1 -1
- package/.agent/workflows/dashboard.md +4 -1
- package/.agent/workflows/debug.md +1 -1
- package/.agent/workflows/deploy.md +1 -1
- package/.agent/workflows/enhance.md +1 -1
- package/.agent/workflows/next.md +4 -1
- package/.agent/workflows/orchestrate.md +1 -1
- package/.agent/workflows/plan.md +1 -1
- package/.agent/workflows/preview.md +1 -1
- package/.agent/workflows/quality.md +1 -1
- package/.agent/workflows/spec.md +1 -1
- package/.agent/workflows/status.md +1 -1
- package/.agent/workflows/test.md +1 -1
- package/.agent/workflows/ui-ux-pro-max.md +1 -1
- package/README.md +3 -3
- package/package.json +1 -1
package/.agent/rules/CODEX.md
CHANGED
|
@@ -99,18 +99,19 @@ For each domain, apply corresponding skill:
|
|
|
99
99
|
```
|
|
100
100
|
|
|
101
101
|
### Rule 4: Socratic Gate
|
|
102
|
-
For complex/unclear requests, ASK before implementing
|
|
103
|
-
```
|
|
104
|
-
Before I implement, let me clarify:
|
|
105
|
-
1. [Specific question about scope]
|
|
106
|
-
2. [Specific question about requirements]
|
|
107
|
-
3. [Specific question about constraints]
|
|
108
|
-
```
|
|
102
|
+
For complex/unclear requests, ASK before implementing. Follow the **One Question at a Time** protocol.
|
|
109
103
|
|
|
110
104
|
---
|
|
111
105
|
|
|
112
106
|
## 📂 SKILL QUICK REFERENCE
|
|
113
107
|
|
|
108
|
+
### Core & Workflow
|
|
109
|
+
```
|
|
110
|
+
/read .agent/skills/verification-gate/SKILL.md
|
|
111
|
+
/read .agent/skills/git-worktrees/SKILL.md
|
|
112
|
+
/read .agent/skills/parallel-agents/SKILL.md
|
|
113
|
+
```
|
|
114
|
+
|
|
114
115
|
### Frontend Development
|
|
115
116
|
```
|
|
116
117
|
/read .agent/skills/react-patterns/SKILL.md
|
|
@@ -58,6 +58,21 @@ trigger: always_on
|
|
|
58
58
|
|
|
59
59
|
---
|
|
60
60
|
|
|
61
|
+
## 🔴 VERIFICATION GATE (IRON LAW)
|
|
62
|
+
|
|
63
|
+
**MANDATORY: Before ANY claim of success or completion.**
|
|
64
|
+
|
|
65
|
+
| Rule | Action |
|
|
66
|
+
|------|--------|
|
|
67
|
+
| **Evidence First** | Run the specific command that proves the claim. |
|
|
68
|
+
| **No "Should"** | Stop using "should work" or "probably fixed". |
|
|
69
|
+
| **Fresh Data** | Verification must be run on the LATEST version of code. |
|
|
70
|
+
| **Two-Stage Review** | For orchestration, use Spec Review → Quality Review. |
|
|
71
|
+
|
|
72
|
+
**Protocol:** If you haven't run the verification command in the current turn, you CANNOT claim success. Apply `@[skills/verification-gate]`.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
61
76
|
## 🎭 Gemini Mode Mapping
|
|
62
77
|
|
|
63
78
|
| Mode | Agent | Behavior |
|
|
@@ -28,12 +28,17 @@ trigger: always_on
|
|
|
28
28
|
| Skill | Purpose |
|
|
29
29
|
|-------|---------|
|
|
30
30
|
| `clean-code` | Coding standards (GLOBAL) |
|
|
31
|
-
| `brainstorming` | Socratic questioning |
|
|
31
|
+
| `brainstorming` | Socratic questioning + one-question protocol |
|
|
32
|
+
| `verification-gate` | Evidence-based completion claims (NEW) |
|
|
33
|
+
| `git-worktrees` | Isolated branch development (NEW) |
|
|
32
34
|
| `spec-writing` | SPEC-{slug}.md format (SDD) |
|
|
33
35
|
| `plan-writing` | PLAN-{slug}.md format |
|
|
34
36
|
| `app-builder` | Full-stack orchestration |
|
|
35
|
-
| `
|
|
37
|
+
| `react-patterns` | React/Next.js patterns + 57 performance rules |
|
|
38
|
+
| `web-interface-guidelines` | UI audit (forms, touch, a11y, anti-patterns) |
|
|
39
|
+
| `frontend-design` | Web UI patterns + anti-AI-slop rules |
|
|
36
40
|
| `mobile-design` | Mobile UI patterns |
|
|
41
|
+
| `parallel-agents` | Multi-agent orchestration + two-stage review |
|
|
37
42
|
| `behavioral-modes` | Mode switching |
|
|
38
43
|
| `ai-security-guardrails` | OWASP Top 10 for LLMs, prompt injection defense |
|
|
39
44
|
| `privacy-preserving-dev` | PII detection and redaction patterns |
|
|
@@ -30,6 +30,58 @@ allowed-tools: Read, Glob, Grep
|
|
|
30
30
|
- 📦 Scope: Must-have vs nice-to-have?
|
|
31
31
|
3. **WAIT** - Get response before proceeding
|
|
32
32
|
|
|
33
|
+
### ☝️ ONE QUESTION AT A TIME (Superpowers Protocol)
|
|
34
|
+
|
|
35
|
+
> **Core Principle:** Don't overwhelm. One question per message.
|
|
36
|
+
|
|
37
|
+
| Rule | Rationale |
|
|
38
|
+
|------|-----------|
|
|
39
|
+
| **One question per message** | Easier to answer, clearer responses |
|
|
40
|
+
| **Multiple choice preferred** | Faster decisions than open-ended |
|
|
41
|
+
| **Explore before drilling** | Breadth first, depth on selected areas |
|
|
42
|
+
| **Break complex topics** | If topic needs exploration, use multiple questions |
|
|
43
|
+
|
|
44
|
+
**Example Flow:**
|
|
45
|
+
```
|
|
46
|
+
❌ WRONG: "What framework, styling, and auth method do you prefer?"
|
|
47
|
+
|
|
48
|
+
✅ CORRECT:
|
|
49
|
+
Message 1: "Which framework? (A) Next.js (B) React+Vite (C) Vue"
|
|
50
|
+
[Wait for answer]
|
|
51
|
+
Message 2: "For styling, what approach? (A) Tailwind (B) CSS Modules (C) styled-components"
|
|
52
|
+
[Wait for answer]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 📄 Incremental Design Validation
|
|
56
|
+
|
|
57
|
+
> **Present design in 200-300 word sections, validate each before proceeding**
|
|
58
|
+
|
|
59
|
+
**Process:**
|
|
60
|
+
1. Once you understand requirements, START presenting design
|
|
61
|
+
2. Break into digestible sections (200-300 words each)
|
|
62
|
+
3. After EACH section, ask: "Does this look right so far?"
|
|
63
|
+
4. Only proceed to next section after confirmation
|
|
64
|
+
5. Be ready to backtrack if something doesn't make sense
|
|
65
|
+
|
|
66
|
+
**Section Order:**
|
|
67
|
+
```
|
|
68
|
+
1. Architecture Overview (200-300 words) → Validate ✅
|
|
69
|
+
2. Data Model (200-300 words) → Validate ✅
|
|
70
|
+
3. Key Components (200-300 words) → Validate ✅
|
|
71
|
+
4. User Flows (200-300 words) → Validate ✅
|
|
72
|
+
5. Error Handling (200-300 words) → Validate ✅
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 🎯 YAGNI Ruthlessly
|
|
76
|
+
|
|
77
|
+
> Remove unnecessary features from ALL designs
|
|
78
|
+
|
|
79
|
+
| Question | If Answer is "Maybe" |
|
|
80
|
+
|----------|---------------------|
|
|
81
|
+
| "Do we need this feature now?" | Remove it |
|
|
82
|
+
| "Will users definitely use this?" | Defer it |
|
|
83
|
+
| "Is this essential for v1?" | Cut scope |
|
|
84
|
+
|
|
33
85
|
---
|
|
34
86
|
|
|
35
87
|
## 🧠 Dynamic Question Generation
|
|
@@ -340,6 +340,36 @@ For animation patterns: [animation-guide.md](animation-guide.md), for advanced:
|
|
|
340
340
|
- **Same layout structure / Vercel clone**
|
|
341
341
|
- **Not asking user preferences**
|
|
342
342
|
|
|
343
|
+
### 🚫 FORBIDDEN PATTERNS (Anti-AI-Slop)
|
|
344
|
+
|
|
345
|
+
> Adapted from Anthropic's frontend-design skill
|
|
346
|
+
|
|
347
|
+
| Element | 🚫 FORBIDDEN | ✅ USE INSTEAD |
|
|
348
|
+
|---------|--------------|----------------|
|
|
349
|
+
| **Fonts** | Inter, Roboto, Arial, system fonts | Distinctive display fonts (IBM Plex, Outfit, Space Mono, Bricolage Grotesque) |
|
|
350
|
+
| **Colors** | Purple gradients on white, fintech blue/cyan | Bold, context-specific palettes (Red + Black, Neon Green, Earth tones) |
|
|
351
|
+
| **Layouts** | Centered cards, hero split (left/right), predictable grids | Asymmetry, overlap, diagonal flow, massive typography |
|
|
352
|
+
| **Backgrounds** | Solid colors, generic mesh/aurora gradients | Gradient meshes (unique), noise textures, geometric patterns |
|
|
353
|
+
| **Effects** | Default shadows, cookie-cutter glassmorphism | Layered transparencies, dramatic shadows, grain overlays |
|
|
354
|
+
| **Copy** | "Orchestrate", "Empower", "Seamless" | Human language, context-specific |
|
|
355
|
+
|
|
356
|
+
### 🎨 Bold Aesthetic Direction (REQUIRED)
|
|
357
|
+
|
|
358
|
+
**Before coding, commit to ONE extreme:**
|
|
359
|
+
|
|
360
|
+
| Direction | Characteristics |
|
|
361
|
+
|-----------|-----------------|
|
|
362
|
+
| **Brutally Minimal** | Zero decoration, massive type, stark contrast |
|
|
363
|
+
| **Maximalist Chaos** | Dense, layered, overwhelming intentionally |
|
|
364
|
+
| **Retro-Futuristic** | 80s/90s tech meets modern |
|
|
365
|
+
| **Organic/Natural** | Flowing shapes, earth tones, imperfection |
|
|
366
|
+
| **Luxury/Refined** | Restrained elegance, whitespace, gold/black |
|
|
367
|
+
| **Playful/Toy-like** | Bright, rounded, childlike joy |
|
|
368
|
+
| **Editorial/Magazine** | Grid-based, type-heavy, sophisticated |
|
|
369
|
+
| **Brutalist/Raw** | Exposed structure, ugly-beautiful |
|
|
370
|
+
|
|
371
|
+
> **Remember:** Generic AI aesthetics = FAILURE. Every design must be memorable.
|
|
372
|
+
|
|
343
373
|
### ❌ Dark Patterns (Unethical)
|
|
344
374
|
|
|
345
375
|
- Hidden costs
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: git-worktrees
|
|
3
|
+
description: Isolated branch development using git worktrees. Use when starting new features, experiments, or parallel development. Creates clean workspace on new branch without affecting main checkout.
|
|
4
|
+
allowed-tools: Read, Bash, Grep, Glob
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Git Worktrees for Isolated Development
|
|
8
|
+
|
|
9
|
+
> **Core Principle:** Isolated workspaces prevent context pollution and enable clean experimentation.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 🎯 When to Use
|
|
14
|
+
|
|
15
|
+
| Situation | Use Worktrees? |
|
|
16
|
+
|-----------|----------------|
|
|
17
|
+
| New feature development | ✅ Yes |
|
|
18
|
+
| Experimental changes | ✅ Yes |
|
|
19
|
+
| Bug fix that might break things | ✅ Yes |
|
|
20
|
+
| Quick hotfix on main | ❌ No, direct |
|
|
21
|
+
| Review someone's PR | ✅ Yes |
|
|
22
|
+
| Parallel feature work | ✅ Yes |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 📁 Directory Selection Process
|
|
27
|
+
|
|
28
|
+
### 1. Check for Existing Worktree Directory
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Check if project has worktree directory
|
|
32
|
+
if [ -d ".worktrees" ]; then
|
|
33
|
+
WORKTREE_DIR=".worktrees"
|
|
34
|
+
elif [ -d "worktrees" ]; then
|
|
35
|
+
WORKTREE_DIR="worktrees"
|
|
36
|
+
else
|
|
37
|
+
# Create new
|
|
38
|
+
WORKTREE_DIR=".worktrees"
|
|
39
|
+
mkdir -p "$WORKTREE_DIR"
|
|
40
|
+
fi
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 2. Verify .gitignore Contains Worktree Directory
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# CRITICAL: Ensure worktree directory is ignored
|
|
47
|
+
if ! grep -q ".worktrees" .gitignore 2>/dev/null; then
|
|
48
|
+
echo ".worktrees/" >> .gitignore
|
|
49
|
+
fi
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 🔄 Creation Steps
|
|
55
|
+
|
|
56
|
+
### Step 1: Create Branch Name
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Format: feature/<descriptive-name>
|
|
60
|
+
BRANCH_NAME="feature/$(echo "$FEATURE_DESC" | tr ' ' '-' | tr '[:upper:]' '[:lower:]')"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Step 2: Create Worktree
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Create worktree with new branch
|
|
67
|
+
git worktree add ".worktrees/$BRANCH_NAME" -b "$BRANCH_NAME"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Step 3: Navigate and Setup
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
cd ".worktrees/$BRANCH_NAME"
|
|
74
|
+
|
|
75
|
+
# Run project setup (detect from project)
|
|
76
|
+
if [ -f "package.json" ]; then
|
|
77
|
+
npm install
|
|
78
|
+
elif [ -f "requirements.txt" ]; then
|
|
79
|
+
pip install -r requirements.txt
|
|
80
|
+
elif [ -f "Cargo.toml" ]; then
|
|
81
|
+
cargo build
|
|
82
|
+
fi
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Step 4: Verify Clean Baseline
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# CRITICAL: Tests must pass BEFORE starting work
|
|
89
|
+
npm test # or equivalent
|
|
90
|
+
|
|
91
|
+
# If tests fail, DO NOT proceed
|
|
92
|
+
# Fix the baseline first
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Step 5: Report Location
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
✅ Worktree created: .worktrees/feature/my-feature
|
|
99
|
+
📂 Branch: feature/my-feature
|
|
100
|
+
🧪 Baseline: 45/45 tests passing
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## 🔧 Common Commands
|
|
106
|
+
|
|
107
|
+
| Action | Command |
|
|
108
|
+
|--------|---------|
|
|
109
|
+
| List worktrees | `git worktree list` |
|
|
110
|
+
| Create worktree | `git worktree add <path> -b <branch>` |
|
|
111
|
+
| Remove worktree | `git worktree remove <path>` |
|
|
112
|
+
| Prune stale | `git worktree prune` |
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## ✅ Finishing a Worktree
|
|
117
|
+
|
|
118
|
+
### When Work is Complete
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# 1. Ensure all tests pass
|
|
122
|
+
npm test
|
|
123
|
+
|
|
124
|
+
# 2. Commit all changes
|
|
125
|
+
git add .
|
|
126
|
+
git commit -m "feat: description"
|
|
127
|
+
|
|
128
|
+
# 3. Return to main checkout
|
|
129
|
+
cd ../..
|
|
130
|
+
|
|
131
|
+
# 4. Present options to user
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Options to Present
|
|
135
|
+
|
|
136
|
+
| Option | Command | When to Use |
|
|
137
|
+
|--------|---------|-------------|
|
|
138
|
+
| **Merge** | `git merge feature/branch` | Ready to integrate |
|
|
139
|
+
| **Create PR** | Push and create PR | Team review needed |
|
|
140
|
+
| **Keep** | Do nothing | More work planned |
|
|
141
|
+
| **Discard** | `git worktree remove .worktrees/feature/branch` | Experiment failed |
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## ⚠️ Common Mistakes
|
|
146
|
+
|
|
147
|
+
| Mistake | Consequence | Prevention |
|
|
148
|
+
|---------|-------------|------------|
|
|
149
|
+
| Skip ignore verification | Worktree committed to repo | Always check .gitignore |
|
|
150
|
+
| Assume directory location | Wrong path, confusion | Check existing directories |
|
|
151
|
+
| Proceed with failing tests | Bad baseline | Verify clean baseline |
|
|
152
|
+
| Hardcode setup commands | Breaks on different projects | Detect from project files |
|
|
153
|
+
| Forget to prune | Stale worktrees accumulate | `git worktree prune` regularly |
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 🔁 Integration with Other Skills
|
|
158
|
+
|
|
159
|
+
| After Worktree Created | Use Skill |
|
|
160
|
+
|------------------------|-----------|
|
|
161
|
+
| Ready to plan work | `plan-writing` |
|
|
162
|
+
| Implementing features | `tdd-workflow` |
|
|
163
|
+
| Work complete | `verification-gate` |
|
|
164
|
+
| Ready to merge | `git-worktrees` finish flow |
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## 📋 Quick Reference
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# Full workflow
|
|
172
|
+
git worktree add .worktrees/feature-name -b feature/name
|
|
173
|
+
cd .worktrees/feature-name
|
|
174
|
+
npm install && npm test # verify baseline
|
|
175
|
+
# ... do work ...
|
|
176
|
+
npm test # verify completion
|
|
177
|
+
cd ../..
|
|
178
|
+
git merge feature/name # or create PR
|
|
179
|
+
git worktree remove .worktrees/feature-name
|
|
180
|
+
git worktree prune
|
|
181
|
+
```
|
|
@@ -156,6 +156,95 @@ After all agents complete, synthesize:
|
|
|
156
156
|
|
|
157
157
|
---
|
|
158
158
|
|
|
159
|
+
## 🔄 Two-Stage Review Pattern
|
|
160
|
+
|
|
161
|
+
> **Adapted from obra/superpowers** - Quality gates per task
|
|
162
|
+
|
|
163
|
+
### Overview
|
|
164
|
+
|
|
165
|
+
For high-quality implementation, each task goes through TWO review stages:
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
Implementer → Spec Reviewer → Code Quality Reviewer → Next Task
|
|
169
|
+
↑ ↑
|
|
170
|
+
└────── Fix Loop ────┘
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Stage 1: Spec Compliance Review
|
|
174
|
+
|
|
175
|
+
**Purpose:** Verify code matches specification exactly (no more, no less)
|
|
176
|
+
|
|
177
|
+
**Template for Spec Reviewer:**
|
|
178
|
+
```
|
|
179
|
+
You are reviewing implementation for SPEC COMPLIANCE ONLY.
|
|
180
|
+
|
|
181
|
+
Task Spec:
|
|
182
|
+
[paste exact task specification]
|
|
183
|
+
|
|
184
|
+
Implementation:
|
|
185
|
+
[paste code or git diff]
|
|
186
|
+
|
|
187
|
+
Review Checklist:
|
|
188
|
+
□ All requirements in spec are implemented
|
|
189
|
+
□ No extra features added (over-building)
|
|
190
|
+
□ No requirements missing (under-building)
|
|
191
|
+
□ Implementation matches spec intent
|
|
192
|
+
|
|
193
|
+
Output: ✅ Spec Compliant OR ❌ Issues (list specific gaps)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Stage 2: Code Quality Review
|
|
197
|
+
|
|
198
|
+
**Purpose:** Ensure implementation is well-built (only after spec compliance passes)
|
|
199
|
+
|
|
200
|
+
**Template for Code Quality Reviewer:**
|
|
201
|
+
```
|
|
202
|
+
You are reviewing implementation for CODE QUALITY ONLY.
|
|
203
|
+
(Spec compliance already verified ✅)
|
|
204
|
+
|
|
205
|
+
Code to Review:
|
|
206
|
+
[paste code or git diff]
|
|
207
|
+
|
|
208
|
+
Review Checklist:
|
|
209
|
+
□ Clean code principles followed
|
|
210
|
+
□ Error handling appropriate
|
|
211
|
+
□ Performance acceptable
|
|
212
|
+
□ Tests adequate
|
|
213
|
+
□ No obvious security issues
|
|
214
|
+
|
|
215
|
+
Output:
|
|
216
|
+
- Strengths: [list]
|
|
217
|
+
- Issues: [Critical/Important/Minor]
|
|
218
|
+
- Verdict: ✅ Approved OR ❌ Issues to fix
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Review Flow Rules
|
|
222
|
+
|
|
223
|
+
| Rule | Enforcement |
|
|
224
|
+
|------|-------------|
|
|
225
|
+
| Spec review FIRST | Never start code quality review before spec ✅ |
|
|
226
|
+
| Fix loop required | If issues found, implementer fixes, reviewer re-reviews |
|
|
227
|
+
| Both must pass | Cannot proceed to next task until both ✅ |
|
|
228
|
+
| Same implementer fixes | Don't switch to different agent mid-task |
|
|
229
|
+
|
|
230
|
+
### Integration with Orchestration
|
|
231
|
+
|
|
232
|
+
```
|
|
233
|
+
Use the backend-specialist agent to implement [task].
|
|
234
|
+
|
|
235
|
+
[After implementation complete]
|
|
236
|
+
|
|
237
|
+
Use the spec-reviewer to verify implementation matches [spec].
|
|
238
|
+
|
|
239
|
+
[If spec review passes]
|
|
240
|
+
|
|
241
|
+
Use the code-quality-reviewer to verify implementation quality.
|
|
242
|
+
|
|
243
|
+
[Both pass → next task]
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
159
248
|
## Best Practices
|
|
160
249
|
|
|
161
250
|
1. **Available agents** - 17 specialized agents can be orchestrated
|
|
@@ -7,6 +7,37 @@ allowed-tools: Read, Write, Edit, Glob, Grep
|
|
|
7
7
|
# React Patterns
|
|
8
8
|
|
|
9
9
|
> Principles for building production-ready React applications.
|
|
10
|
+
> Based on patterns from Vercel Engineering (57 rules, 8 categories).
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 🎯 Performance Priority System
|
|
15
|
+
|
|
16
|
+
| Priority | Category | Impact | Prefix | Reference |
|
|
17
|
+
|----------|----------|--------|--------|-----------|
|
|
18
|
+
| 1 | Eliminating Waterfalls | 🔴 CRITICAL | `async-` | [waterfall-patterns.md](waterfall-patterns.md) |
|
|
19
|
+
| 2 | Bundle Size Optimization | 🔴 CRITICAL | `bundle-` | [bundle-patterns.md](bundle-patterns.md) |
|
|
20
|
+
| 3 | Server-Side Performance | 🟠 HIGH | `server-` | [server-patterns.md](server-patterns.md) |
|
|
21
|
+
| 4 | Client-Side Data Fetching | 🟡 MEDIUM-HIGH | `client-` | Below |
|
|
22
|
+
| 5 | Re-render Optimization | 🟡 MEDIUM | `rerender-` | [rerender-patterns.md](rerender-patterns.md) |
|
|
23
|
+
| 6 | Rendering Performance | 🟡 MEDIUM | `rendering-` | Below |
|
|
24
|
+
| 7 | JavaScript Performance | 🟢 LOW-MEDIUM | `js-` | Below |
|
|
25
|
+
| 8 | Advanced Patterns | 🟢 LOW | `advanced-` | Below |
|
|
26
|
+
|
|
27
|
+
> 🔴 **Rule:** Fix CRITICAL issues first. Measure before optimizing MEDIUM/LOW.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 📚 Modular Files
|
|
32
|
+
|
|
33
|
+
Read ONLY the files relevant to your task:
|
|
34
|
+
|
|
35
|
+
| File | When to Read |
|
|
36
|
+
|------|--------------|
|
|
37
|
+
| [waterfall-patterns.md](waterfall-patterns.md) | Async/await, data fetching |
|
|
38
|
+
| [bundle-patterns.md](bundle-patterns.md) | Bundle size, imports |
|
|
39
|
+
| [server-patterns.md](server-patterns.md) | RSC, caching, SSR |
|
|
40
|
+
| [rerender-patterns.md](rerender-patterns.md) | State, memo, effects |
|
|
10
41
|
|
|
11
42
|
---
|
|
12
43
|
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Bundle Patterns (CRITICAL)
|
|
2
|
+
|
|
3
|
+
> Bundle size directly impacts Time to Interactive. Critical for Core Web Vitals.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## bundle-barrel-imports
|
|
8
|
+
|
|
9
|
+
**Import directly, avoid barrel files (index.ts/index.js).**
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
// ❌ BAD: Barrel import pulls entire package into bundle
|
|
13
|
+
import { Button } from '@/components';
|
|
14
|
+
import { format } from 'date-fns';
|
|
15
|
+
|
|
16
|
+
// ✅ GOOD: Direct import enables tree-shaking
|
|
17
|
+
import { Button } from '@/components/Button';
|
|
18
|
+
import { format } from 'date-fns/format';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
| Library | Barrel-Free Import |
|
|
22
|
+
|---------|-------------------|
|
|
23
|
+
| date-fns | `date-fns/format` |
|
|
24
|
+
| lodash | `lodash/debounce` |
|
|
25
|
+
| @mui | `@mui/material/Button` |
|
|
26
|
+
| lucide-react | `lucide-react/dist/esm/icons/menu` |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## bundle-dynamic-imports
|
|
31
|
+
|
|
32
|
+
**Use next/dynamic for heavy components.**
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
// ✅ Load only when needed
|
|
36
|
+
const HeavyEditor = dynamic(() => import('./HeavyEditor'), {
|
|
37
|
+
loading: () => <Skeleton />,
|
|
38
|
+
ssr: false // If client-only
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// ✅ Load on interaction
|
|
42
|
+
const [showChart, setShowChart] = useState(false);
|
|
43
|
+
const Chart = dynamic(() => import('./Chart'));
|
|
44
|
+
|
|
45
|
+
{showChart && <Chart />}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
| Component Type | Dynamic? |
|
|
49
|
+
|----------------|----------|
|
|
50
|
+
| Charts (recharts, chart.js) | ✅ Yes |
|
|
51
|
+
| Rich text editors | ✅ Yes |
|
|
52
|
+
| Code editors (Monaco) | ✅ Yes |
|
|
53
|
+
| Modals/Dialogs | ⚠️ Consider |
|
|
54
|
+
| Core UI | ❌ No |
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## bundle-defer-third-party
|
|
59
|
+
|
|
60
|
+
**Load analytics/logging after hydration.**
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
// ✅ Load analytics after page is interactive
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
import('analytics').then(({ init }) => init());
|
|
66
|
+
}, []);
|
|
67
|
+
|
|
68
|
+
// ✅ Or use next/script with afterInteractive
|
|
69
|
+
<Script
|
|
70
|
+
src="https://analytics.com/script.js"
|
|
71
|
+
strategy="afterInteractive"
|
|
72
|
+
/>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
| Script Type | Strategy |
|
|
76
|
+
|-------------|----------|
|
|
77
|
+
| Analytics | `afterInteractive` |
|
|
78
|
+
| Chat widgets | `lazyOnload` |
|
|
79
|
+
| A/B testing | `beforeInteractive` |
|
|
80
|
+
| Ads | `lazyOnload` |
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## bundle-conditional
|
|
85
|
+
|
|
86
|
+
**Load modules only when feature is activated.**
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
// ✅ Load on user action
|
|
90
|
+
const handleExport = async () => {
|
|
91
|
+
const { exportPDF } = await import('./export-utils');
|
|
92
|
+
exportPDF(data);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// ✅ Load based on feature flag
|
|
96
|
+
const AdminPanel = featureFlags.admin
|
|
97
|
+
? dynamic(() => import('./AdminPanel'))
|
|
98
|
+
: null;
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## bundle-preload
|
|
104
|
+
|
|
105
|
+
**Preload on hover/focus for perceived speed.**
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
// ✅ Preload on hover
|
|
109
|
+
<Link
|
|
110
|
+
href="/dashboard"
|
|
111
|
+
onMouseEnter={() => router.prefetch('/dashboard')}
|
|
112
|
+
>
|
|
113
|
+
Dashboard
|
|
114
|
+
</Link>
|
|
115
|
+
|
|
116
|
+
// ✅ Preload critical chunks
|
|
117
|
+
<link rel="preload" href="/_next/static/chunks/heavy.js" as="script" />
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Quick Checks
|
|
123
|
+
|
|
124
|
+
| Signal | Action |
|
|
125
|
+
|--------|--------|
|
|
126
|
+
| Bundle > 200KB | Analyze with `@next/bundle-analyzer` |
|
|
127
|
+
| `from 'library'` | Check for barrel-free alternative |
|
|
128
|
+
| Heavy deps in layout | Move to dynamic import |
|
|
129
|
+
| Third-party in `<head>` | Move to afterInteractive |
|