@sylphx/flow 0.2.13 → 1.0.1
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/CHANGELOG.md +318 -0
- package/LOOP_MODE.md +446 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +59398 -698
- package/dist/lancedb.linux-x64-gnu-b7f0jgsz.node +0 -0
- package/dist/lancedb.linux-x64-musl-tgcv22rx.node +0 -0
- package/dist/shared/chunk-25dwp0dp.js +89 -0
- package/dist/shared/chunk-3pjb6063.js +208 -0
- package/dist/shared/chunk-4d6ydpw7.js +2854 -0
- package/dist/shared/chunk-4wjcadjk.js +225 -0
- package/dist/shared/chunk-5j4w74t6.js +30 -0
- package/dist/shared/chunk-5j8m3dh3.js +58 -0
- package/dist/shared/chunk-5thh3qem.js +91 -0
- package/dist/shared/chunk-6g9xy73m.js +252 -0
- package/dist/shared/chunk-7eq34c42.js +23 -0
- package/dist/shared/chunk-c2gwgx3r.js +115 -0
- package/dist/shared/chunk-cjd3mk4c.js +1320 -0
- package/dist/shared/chunk-g5cv6703.js +368 -0
- package/dist/shared/chunk-hpkhykhq.js +574 -0
- package/dist/shared/chunk-m2322pdk.js +122 -0
- package/dist/shared/chunk-nd5fdvaq.js +26 -0
- package/dist/shared/chunk-pgd3m6zf.js +108 -0
- package/dist/shared/chunk-qk8n91hw.js +494 -0
- package/dist/shared/chunk-rkkn8szp.js +16855 -0
- package/dist/shared/chunk-t16rfxh0.js +61 -0
- package/dist/shared/chunk-t4fbfa5v.js +19 -0
- package/dist/shared/chunk-t77h86w6.js +276 -0
- package/dist/shared/chunk-v0ez4aef.js +71 -0
- package/dist/shared/chunk-v29j2r3s.js +32051 -0
- package/dist/shared/chunk-vfbc6ew5.js +765 -0
- package/dist/shared/chunk-vmeqwm1c.js +204 -0
- package/dist/shared/chunk-x66eh37x.js +137 -0
- package/package.json +45 -93
- package/README.md +0 -625
- package/assets/agents/coder.md +0 -32
- package/assets/agents/orchestrator.md +0 -36
- package/assets/agents/reviewer.md +0 -30
- package/assets/agents/writer.md +0 -30
- package/assets/knowledge/data/sql.md +0 -216
- package/assets/knowledge/guides/saas-template.md +0 -85
- package/assets/knowledge/guides/system-prompt.md +0 -344
- package/assets/knowledge/guides/tech-stack.md +0 -92
- package/assets/knowledge/guides/ui-ux.md +0 -44
- package/assets/knowledge/stacks/nextjs-app.md +0 -165
- package/assets/knowledge/stacks/node-api.md +0 -220
- package/assets/knowledge/stacks/react-app.md +0 -232
- package/assets/knowledge/universal/deployment.md +0 -109
- package/assets/knowledge/universal/performance.md +0 -121
- package/assets/knowledge/universal/security.md +0 -79
- package/assets/knowledge/universal/testing.md +0 -111
- package/assets/output-styles/silent.md +0 -23
- package/assets/rules/core.md +0 -197
- package/assets/slash-commands/commit.md +0 -23
- package/assets/slash-commands/context.md +0 -112
- package/assets/slash-commands/explain.md +0 -35
- package/assets/slash-commands/mep.md +0 -63
- package/assets/slash-commands/review.md +0 -39
- package/assets/slash-commands/test.md +0 -30
- package/dist/assets/agents/coder.md +0 -32
- package/dist/assets/agents/orchestrator.md +0 -36
- package/dist/assets/agents/reviewer.md +0 -30
- package/dist/assets/agents/writer.md +0 -30
- package/dist/assets/knowledge/data/sql.md +0 -216
- package/dist/assets/knowledge/guides/saas-template.md +0 -85
- package/dist/assets/knowledge/guides/system-prompt.md +0 -344
- package/dist/assets/knowledge/guides/tech-stack.md +0 -92
- package/dist/assets/knowledge/guides/ui-ux.md +0 -44
- package/dist/assets/knowledge/stacks/nextjs-app.md +0 -165
- package/dist/assets/knowledge/stacks/node-api.md +0 -220
- package/dist/assets/knowledge/stacks/react-app.md +0 -232
- package/dist/assets/knowledge/universal/deployment.md +0 -109
- package/dist/assets/knowledge/universal/performance.md +0 -121
- package/dist/assets/knowledge/universal/security.md +0 -79
- package/dist/assets/knowledge/universal/testing.md +0 -111
- package/dist/assets/output-styles/silent.md +0 -23
- package/dist/assets/rules/core.md +0 -197
- package/dist/assets/slash-commands/commit.md +0 -23
- package/dist/assets/slash-commands/context.md +0 -112
- package/dist/assets/slash-commands/explain.md +0 -35
- package/dist/assets/slash-commands/mep.md +0 -63
- package/dist/assets/slash-commands/review.md +0 -39
- package/dist/assets/slash-commands/test.md +0 -30
- package/dist/chunk-01gv4qey.js +0 -4
- package/dist/chunk-01gv4qey.js.map +0 -11
- package/dist/chunk-1e8xf3f6.js +0 -27
- package/dist/chunk-1e8xf3f6.js.map +0 -23
- package/dist/chunk-3m9whg4q.js +0 -4
- package/dist/chunk-3m9whg4q.js.map +0 -9
- package/dist/chunk-3qxj0zy3.js +0 -23
- package/dist/chunk-3qxj0zy3.js.map +0 -11
- package/dist/chunk-3w6pd43t.js +0 -25
- package/dist/chunk-3w6pd43t.js.map +0 -61
- package/dist/chunk-4e5g3df9.js +0 -105
- package/dist/chunk-4e5g3df9.js.map +0 -27
- package/dist/chunk-4nm4ere4.js +0 -4
- package/dist/chunk-4nm4ere4.js.map +0 -11
- package/dist/chunk-4vrj3f8r.js +0 -26
- package/dist/chunk-4vrj3f8r.js.map +0 -75
- package/dist/chunk-5njgv5k5.js +0 -161
- package/dist/chunk-5njgv5k5.js.map +0 -83
- package/dist/chunk-67n29s4q.js +0 -7
- package/dist/chunk-67n29s4q.js.map +0 -10
- package/dist/chunk-7yyg008s.js +0 -27
- package/dist/chunk-7yyg008s.js.map +0 -14
- package/dist/chunk-86ce45n6.js +0 -3
- package/dist/chunk-86ce45n6.js.map +0 -10
- package/dist/chunk-99pz5wm0.js +0 -75
- package/dist/chunk-99pz5wm0.js.map +0 -12
- package/dist/chunk-cv1nhr27.js +0 -2
- package/dist/chunk-cv1nhr27.js.map +0 -9
- package/dist/chunk-g4baca7p.js +0 -10
- package/dist/chunk-g4baca7p.js.map +0 -23
- package/dist/chunk-gc66xe7z.js +0 -4
- package/dist/chunk-gc66xe7z.js.map +0 -11
- package/dist/chunk-hj6qtsqp.js +0 -15
- package/dist/chunk-hj6qtsqp.js.map +0 -10
- package/dist/chunk-jbd95k1f.js +0 -14
- package/dist/chunk-jbd95k1f.js.map +0 -20
- package/dist/chunk-jk1ebfqn.js +0 -23
- package/dist/chunk-jk1ebfqn.js.map +0 -132
- package/dist/chunk-kn908zkk.js +0 -4
- package/dist/chunk-kn908zkk.js.map +0 -10
- package/dist/chunk-mw13a082.js +0 -4
- package/dist/chunk-mw13a082.js.map +0 -10
- package/dist/chunk-n8vzewr3.js +0 -4
- package/dist/chunk-n8vzewr3.js.map +0 -12
- package/dist/chunk-nke51f3c.js +0 -4
- package/dist/chunk-nke51f3c.js.map +0 -10
- package/dist/chunk-ns5atzyz.js +0 -3
- package/dist/chunk-ns5atzyz.js.map +0 -10
- package/dist/chunk-q4nh3vst.js +0 -54
- package/dist/chunk-q4nh3vst.js.map +0 -53
- package/dist/chunk-q5gqgs0p.js +0 -4
- package/dist/chunk-q5gqgs0p.js.map +0 -10
- package/dist/chunk-qpej66sh.js +0 -6
- package/dist/chunk-qpej66sh.js.map +0 -11
- package/dist/chunk-s9bsh0gp.js +0 -4
- package/dist/chunk-s9bsh0gp.js.map +0 -10
- package/dist/chunk-waemzsf4.js +0 -4
- package/dist/chunk-waemzsf4.js.map +0 -10
- package/dist/chunk-wnhhwtsy.js +0 -19
- package/dist/chunk-wnhhwtsy.js.map +0 -11
- package/dist/chunk-xs370t8p.js +0 -119
- package/dist/chunk-xs370t8p.js.map +0 -26
- package/dist/chunk-xtrn4wn0.js +0 -3
- package/dist/chunk-xtrn4wn0.js.map +0 -10
- package/dist/index.js.map +0 -920
- package/drizzle/0000_wooden_lady_bullseye.sql +0 -52
- package/drizzle/0001_material_pyro.sql +0 -85
- package/drizzle/0002_lyrical_random.sql +0 -2
- package/drizzle/0003_romantic_lockjaw.sql +0 -4
- package/drizzle/0004_blushing_meteorite.sql +0 -6
- package/drizzle/meta/0000_snapshot.json +0 -310
- package/drizzle/meta/0001_snapshot.json +0 -906
- package/drizzle/meta/0002_snapshot.json +0 -920
- package/drizzle/meta/0003_snapshot.json +0 -920
- package/drizzle/meta/0004_snapshot.json +0 -921
- package/drizzle/meta/_journal.json +0 -41
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: React Application
|
|
3
|
-
description: React patterns, hooks, state management, performance, common bugs and fixes
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# React Development
|
|
7
|
-
|
|
8
|
-
## State Management Decision Tree
|
|
9
|
-
```
|
|
10
|
-
Used by 3+ unrelated components?
|
|
11
|
-
├─ NO → useState in common ancestor
|
|
12
|
-
└─ YES → Server data?
|
|
13
|
-
├─ YES → React Query/SWR (not state!)
|
|
14
|
-
└─ NO → Complex actions?
|
|
15
|
-
├─ YES → useReducer / Zustand
|
|
16
|
-
└─ NO → Context API
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Common Bugs & Fixes
|
|
20
|
-
|
|
21
|
-
### Infinite useEffect Loop
|
|
22
|
-
|
|
23
|
-
**Object/array deps:**
|
|
24
|
-
```javascript
|
|
25
|
-
// BAD
|
|
26
|
-
useEffect(() => { fetch(users) }, [users])
|
|
27
|
-
|
|
28
|
-
// FIX
|
|
29
|
-
useEffect(() => { fetch(users) }, [userIds.join(',')]) // Primitive
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
**Unconditional state update:**
|
|
33
|
-
```javascript
|
|
34
|
-
// BAD
|
|
35
|
-
useEffect(() => { setCount(count + 1) }, [count])
|
|
36
|
-
|
|
37
|
-
// FIX
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
if (condition && count < max) setCount(count + 1)
|
|
40
|
-
}, [count, condition, max])
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### Stale Closure
|
|
44
|
-
|
|
45
|
-
```javascript
|
|
46
|
-
// BAD - uses initial count
|
|
47
|
-
const [count, setCount] = useState(0)
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
setInterval(() => setCount(count + 1), 1000)
|
|
50
|
-
}, [])
|
|
51
|
-
|
|
52
|
-
// FIX: Functional update
|
|
53
|
-
setInterval(() => setCount(c => c + 1), 1000)
|
|
54
|
-
|
|
55
|
-
// FIX: useRef (complex cases)
|
|
56
|
-
const countRef = useRef(count)
|
|
57
|
-
useEffect(() => { countRef.current = count })
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
setInterval(() => setCount(countRef.current + 1), 1000)
|
|
60
|
-
}, [])
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### Missing Cleanup
|
|
64
|
-
|
|
65
|
-
```javascript
|
|
66
|
-
// BAD
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
subscribeToData(setData)
|
|
69
|
-
}, [])
|
|
70
|
-
|
|
71
|
-
// GOOD
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
const unsubscribe = subscribeToData(setData)
|
|
74
|
-
return () => unsubscribe()
|
|
75
|
-
}, [])
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## Performance
|
|
79
|
-
|
|
80
|
-
**Optimize when:**
|
|
81
|
-
- Profiler shows slowness
|
|
82
|
-
- User-visible lag
|
|
83
|
-
- 100+ renders/second
|
|
84
|
-
|
|
85
|
-
**Profile first, optimize second.**
|
|
86
|
-
|
|
87
|
-
### Unnecessary Re-renders
|
|
88
|
-
|
|
89
|
-
```javascript
|
|
90
|
-
// BAD
|
|
91
|
-
function Parent() {
|
|
92
|
-
const config = { theme: 'dark' }
|
|
93
|
-
return <Child config={config} />
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// GOOD
|
|
97
|
-
const config = useMemo(() => ({ theme: 'dark' }), [])
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
**Order:**
|
|
101
|
-
1. Fix parent
|
|
102
|
-
2. useMemo/useCallback
|
|
103
|
-
3. Profile
|
|
104
|
-
4. React.memo (last resort)
|
|
105
|
-
|
|
106
|
-
### Virtualization
|
|
107
|
-
|
|
108
|
-
**When**: 500+ items, laggy scroll
|
|
109
|
-
|
|
110
|
-
```javascript
|
|
111
|
-
import { FixedSizeList } from 'react-window'
|
|
112
|
-
<FixedSizeList height={600} itemCount={items.length} itemSize={35}>
|
|
113
|
-
{({ index, style }) => <div style={style}>{items[index]}</div>}
|
|
114
|
-
</FixedSizeList>
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### Debounce Search
|
|
118
|
-
|
|
119
|
-
```javascript
|
|
120
|
-
const debouncedQuery = useDebounce(query, 300)
|
|
121
|
-
useEffect(() => {
|
|
122
|
-
if (debouncedQuery) searchAPI(debouncedQuery)
|
|
123
|
-
}, [debouncedQuery])
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
## Data Fetching
|
|
127
|
-
|
|
128
|
-
**Never** useState for server data. You lose: caching, loading, errors, refetching, race conditions.
|
|
129
|
-
|
|
130
|
-
**Use React Query:**
|
|
131
|
-
```javascript
|
|
132
|
-
const { data, isLoading, error } = useQuery({
|
|
133
|
-
queryKey: ['users'],
|
|
134
|
-
queryFn: () => fetch('/api/users').then(r => r.json())
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
const mutation = useMutation({
|
|
138
|
-
mutationFn: (user) => fetch('/api/users', { method: 'POST', body: JSON.stringify(user) }),
|
|
139
|
-
onSuccess: () => queryClient.invalidateQueries(['users'])
|
|
140
|
-
})
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
## Forms
|
|
144
|
-
|
|
145
|
-
**React Hook Form** (recommended):
|
|
146
|
-
```javascript
|
|
147
|
-
const { register, handleSubmit, formState: { errors } } = useForm()
|
|
148
|
-
|
|
149
|
-
<form onSubmit={handleSubmit(onSubmit)}>
|
|
150
|
-
<input {...register('email', {
|
|
151
|
-
required: 'Required',
|
|
152
|
-
pattern: { value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i }
|
|
153
|
-
})} />
|
|
154
|
-
{errors.email && <span>{errors.email.message}</span>}
|
|
155
|
-
</form>
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
**Controlled vs Uncontrolled:**
|
|
159
|
-
- Controlled: Validation on change, dependent fields
|
|
160
|
-
- Uncontrolled: Simple submit, file inputs
|
|
161
|
-
|
|
162
|
-
## Accessibility
|
|
163
|
-
|
|
164
|
-
**Critical:**
|
|
165
|
-
1. Semantic HTML (`<button>` not `<div onClick>`)
|
|
166
|
-
2. Alt text (meaningful or `alt=""`)
|
|
167
|
-
3. Form labels (every input)
|
|
168
|
-
4. Keyboard nav (Tab, Enter/Space)
|
|
169
|
-
5. Focus visible
|
|
170
|
-
|
|
171
|
-
**Test**: VoiceOver (Cmd+F5), Tab through app
|
|
172
|
-
|
|
173
|
-
```javascript
|
|
174
|
-
// BAD
|
|
175
|
-
<div onClick={handleClick}>Click</div>
|
|
176
|
-
|
|
177
|
-
// GOOD
|
|
178
|
-
<button onClick={handleClick}>Click</button>
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
## Debug Workflow
|
|
182
|
-
|
|
183
|
-
**Component not updating:**
|
|
184
|
-
1. State changing? (console.log)
|
|
185
|
-
2. setState called?
|
|
186
|
-
3. Mutating state? (must create new)
|
|
187
|
-
4. Memoized with stale props?
|
|
188
|
-
|
|
189
|
-
**Performance:**
|
|
190
|
-
1. Profile (React DevTools)
|
|
191
|
-
2. Identify slow component
|
|
192
|
-
3. Check: Unnecessary re-renders?
|
|
193
|
-
4. Check: Expensive computation?
|
|
194
|
-
5. Optimize bottleneck only
|
|
195
|
-
|
|
196
|
-
## Production Patterns
|
|
197
|
-
|
|
198
|
-
**Error Boundary:**
|
|
199
|
-
```javascript
|
|
200
|
-
class ErrorBoundary extends React.Component {
|
|
201
|
-
state = { hasError: false }
|
|
202
|
-
static getDerivedStateFromError() { return { hasError: true } }
|
|
203
|
-
componentDidCatch(error, info) { logError(error, info) }
|
|
204
|
-
render() {
|
|
205
|
-
return this.state.hasError ? <ErrorFallback /> : this.props.children
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
**Code Splitting:**
|
|
211
|
-
```javascript
|
|
212
|
-
const Dashboard = lazy(() => import('./Dashboard'))
|
|
213
|
-
<Suspense fallback={<Loading />}>
|
|
214
|
-
<Dashboard />
|
|
215
|
-
</Suspense>
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
## Key Decisions
|
|
219
|
-
|
|
220
|
-
**State unclear?** → useState, refactor later
|
|
221
|
-
**Performance slow?** → Profile first
|
|
222
|
-
**Form complex?** → React Hook Form
|
|
223
|
-
**Data fetching?** → React Query
|
|
224
|
-
**Not sure?** → Simpler option
|
|
225
|
-
|
|
226
|
-
## Anti-Patterns
|
|
227
|
-
|
|
228
|
-
❌ Server data in useState
|
|
229
|
-
❌ Premature optimization
|
|
230
|
-
❌ React.memo everywhere
|
|
231
|
-
❌ Missing cleanup
|
|
232
|
-
❌ Div as button
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Deployment & DevOps
|
|
3
|
-
description: Docker, CI/CD, monitoring, scaling, infrastructure
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Deployment & DevOps
|
|
7
|
-
|
|
8
|
-
## Deployment Strategies
|
|
9
|
-
|
|
10
|
-
**Blue-Green**: Two environments (blue=current, green=new) → test → switch. Zero downtime, instant rollback, 2x cost.
|
|
11
|
-
|
|
12
|
-
**Rolling**: Replace gradually (10% at a time). No extra infrastructure, lower risk, slower.
|
|
13
|
-
|
|
14
|
-
**Canary**: Route small % to new version. Test in production, minimal risk, complex routing.
|
|
15
|
-
|
|
16
|
-
**Feature Flags**: Deploy code disabled, enable via config. Decouple deploy from release, A/B testing, kill switches.
|
|
17
|
-
|
|
18
|
-
## CI/CD Pipeline
|
|
19
|
-
|
|
20
|
-
### Continuous Integration (On Every Commit)
|
|
21
|
-
1. Run linter
|
|
22
|
-
2. Run tests (unit, integration)
|
|
23
|
-
3. Build application
|
|
24
|
-
4. Security scanning
|
|
25
|
-
5. Code quality checks
|
|
26
|
-
|
|
27
|
-
**Best practices**: Fast feedback (< 10min), fail fast, keep builds green
|
|
28
|
-
|
|
29
|
-
### Continuous Deployment
|
|
30
|
-
**Stages**: CI passes → deploy staging → E2E tests → deploy production → health checks → rollback if failed
|
|
31
|
-
|
|
32
|
-
**Tools**: GitHub Actions, GitLab CI, Jenkins, CircleCI
|
|
33
|
-
|
|
34
|
-
## Containerization (Docker)
|
|
35
|
-
|
|
36
|
-
### Best Practices
|
|
37
|
-
- Multi-stage builds (build → slim runtime)
|
|
38
|
-
- Slim/alpine images
|
|
39
|
-
- Layer caching (deps before code)
|
|
40
|
-
- .dockerignore
|
|
41
|
-
- Don't run as root
|
|
42
|
-
|
|
43
|
-
## Orchestration (Kubernetes)
|
|
44
|
-
|
|
45
|
-
**Core**: Pod (containers), Deployment (replicas), Service (load balancer), Ingress (routing), ConfigMap (config), Secret (sensitive)
|
|
46
|
-
|
|
47
|
-
**Scaling**:
|
|
48
|
-
- Horizontal Pod Autoscaler: Scale based on CPU/memory, min/max replicas
|
|
49
|
-
- Cluster Autoscaler: Add/remove nodes
|
|
50
|
-
|
|
51
|
-
## Monitoring & Observability
|
|
52
|
-
|
|
53
|
-
### Logs
|
|
54
|
-
**Structured logging**: JSON format with level, timestamp, message, context (user_id, trace_id)
|
|
55
|
-
|
|
56
|
-
**Centralized**: ELK, Datadog, CloudWatch
|
|
57
|
-
**Best practices**: Log errors with context, trace IDs, don't log secrets, set retention
|
|
58
|
-
|
|
59
|
-
### Metrics
|
|
60
|
-
**Track**: Request rate, error rate, response time (latency), resource usage (CPU, memory, disk)
|
|
61
|
-
**Tools**: Prometheus, Grafana, Datadog
|
|
62
|
-
|
|
63
|
-
### Tracing
|
|
64
|
-
**Distributed tracing**: Track requests across services, identify bottlenecks
|
|
65
|
-
**Tools**: Jaeger, Zipkin, Datadog APM
|
|
66
|
-
|
|
67
|
-
### Alerting
|
|
68
|
-
**Alert on**: Error rate > threshold, response time > SLA, resource exhaustion, service down
|
|
69
|
-
**Best practices**: Actionable only, include runbooks, escalation policies, on-call rotation
|
|
70
|
-
|
|
71
|
-
## High Availability
|
|
72
|
-
|
|
73
|
-
### Load Balancing
|
|
74
|
-
**Algorithms**: Round robin (equal), least connections (least busy), IP hash (consistent)
|
|
75
|
-
**Health checks**: HTTP (/_health), TCP, check every 10-30s, remove unhealthy
|
|
76
|
-
|
|
77
|
-
### Database Replication
|
|
78
|
-
**Primary-Replica**: Writes to primary, reads from replicas, async (eventual consistency)
|
|
79
|
-
**Multi-Primary**: Write to any, conflict resolution needed, complex but highly available
|
|
80
|
-
|
|
81
|
-
### Backup & Disaster Recovery
|
|
82
|
-
**Backups**: Automated daily, retention (7 days, 4 weeks, 12 months), test restores, offsite/cross-region
|
|
83
|
-
**RTO/RPO**: RTO (recovery time), RPO (data loss acceptable)
|
|
84
|
-
|
|
85
|
-
## Security
|
|
86
|
-
|
|
87
|
-
**Network**: Firewall (whitelist), private subnets for DBs, VPN for internal, DDoS protection
|
|
88
|
-
**Secrets**: Never commit to git, use secret managers (AWS Secrets Manager, Vault), rotate regularly, least privilege
|
|
89
|
-
**SSL/TLS**: HTTPS everywhere, auto-renewal (Let's Encrypt), strong ciphers, HSTS headers
|
|
90
|
-
**Compliance**: Encryption at rest, encryption in transit, access logs, security audits
|
|
91
|
-
|
|
92
|
-
## Cost Optimization
|
|
93
|
-
|
|
94
|
-
**Right-sizing**: Monitor usage, scale down over-provisioned, spot/preemptible for non-critical
|
|
95
|
-
**Auto-scaling**: Scale down off-peak, scale up peak
|
|
96
|
-
**Reserved Instances**: 1-3 year commit for 30-70% discount (predictable workloads)
|
|
97
|
-
**Storage**: Lifecycle policies (move old to cheaper), delete unused, compress backups
|
|
98
|
-
|
|
99
|
-
## Common Patterns
|
|
100
|
-
|
|
101
|
-
**Immutable Infrastructure**: Never modify servers, deploy new, terminate old
|
|
102
|
-
**Infrastructure as Code**: Terraform, CloudFormation, Pulumi → version controlled, reproducible
|
|
103
|
-
**GitOps**: Git as truth, auto-deploy on merge, drift detection (ArgoCD, Flux)
|
|
104
|
-
|
|
105
|
-
## Best Practices
|
|
106
|
-
|
|
107
|
-
**Documentation**: Runbooks, architecture diagrams, incident response, on-call guides
|
|
108
|
-
**Change Management**: Review process, deployment windows, rollback procedures, communication
|
|
109
|
-
**Incident Response**: Detect → Triage → Mitigate → Resolve → Post-mortem
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Performance Optimization
|
|
3
|
-
description: Profiling, caching, optimization patterns across frontend and backend
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Performance Optimization
|
|
7
|
-
|
|
8
|
-
## Measure First
|
|
9
|
-
|
|
10
|
-
**Never optimize without measuring.**
|
|
11
|
-
|
|
12
|
-
### Tools
|
|
13
|
-
**Frontend**: Chrome DevTools, Lighthouse, React Profiler
|
|
14
|
-
**Backend**: APM (New Relic, Datadog), query explain plans
|
|
15
|
-
|
|
16
|
-
### Metrics
|
|
17
|
-
**Frontend**: FCP < 1.8s, LCP < 2.5s, CLS < 0.1, FID < 100ms, TTI < 3.5s
|
|
18
|
-
**Backend**: Response < 200ms (p95), error rate < 1%, DB query < 100ms
|
|
19
|
-
|
|
20
|
-
## Frontend Optimization
|
|
21
|
-
|
|
22
|
-
### Bundle Size
|
|
23
|
-
**Analyze**: webpack-bundle-analyzer
|
|
24
|
-
**Reduce**: Tree-shaking, code splitting, lighter alternatives, remove unused deps
|
|
25
|
-
|
|
26
|
-
### Loading Strategy
|
|
27
|
-
1. Inline critical CSS
|
|
28
|
-
2. Defer non-critical CSS
|
|
29
|
-
3. Async non-critical JS
|
|
30
|
-
4. Lazy load below-fold images
|
|
31
|
-
5. Code splitting: `lazy(() => import('./Heavy'))`
|
|
32
|
-
|
|
33
|
-
### Images
|
|
34
|
-
- WebP format (smaller, better quality)
|
|
35
|
-
- Responsive (srcset)
|
|
36
|
-
- Lazy loading (loading="lazy")
|
|
37
|
-
- CDN delivery
|
|
38
|
-
- Optimize: compress, resize, correct format
|
|
39
|
-
|
|
40
|
-
### Caching
|
|
41
|
-
**Browser**: Cache-Control headers, versioned assets (hash), service worker
|
|
42
|
-
**CDN**: Static assets, edge caching, geographic distribution
|
|
43
|
-
|
|
44
|
-
## React Performance
|
|
45
|
-
|
|
46
|
-
### Avoid Re-renders
|
|
47
|
-
**Identify**: React DevTools Profiler, "Why did you render" library
|
|
48
|
-
|
|
49
|
-
**Fix**: React.memo (pure components), useMemo (expensive computations), useCallback (function props), move static data outside component
|
|
50
|
-
|
|
51
|
-
### Virtualization
|
|
52
|
-
**Problem**: 10,000+ items
|
|
53
|
-
**Solution**: react-window / react-virtualized (render only visible)
|
|
54
|
-
|
|
55
|
-
### Debounce/Throttle
|
|
56
|
-
- **Debounce**: Wait for user to stop (search input)
|
|
57
|
-
- **Throttle**: Limit frequency (scroll handler)
|
|
58
|
-
|
|
59
|
-
## Backend Performance
|
|
60
|
-
|
|
61
|
-
### Database Optimization
|
|
62
|
-
|
|
63
|
-
**Indexes**: Index WHERE/JOIN/ORDER BY columns, composite for multi-column, don't over-index (slows writes)
|
|
64
|
-
|
|
65
|
-
**Queries**: EXPLAIN to analyze, avoid SELECT *, LIMIT for pagination, connection pooling, batch operations
|
|
66
|
-
|
|
67
|
-
**N+1 Problem**: See sql.md for patterns
|
|
68
|
-
|
|
69
|
-
### Caching Strategy
|
|
70
|
-
|
|
71
|
-
**What**: Query results, API responses, computed values, sessions
|
|
72
|
-
**Invalidation**: Time-based (TTL), event-based (on update), hybrid
|
|
73
|
-
**Layers**: App memory (fastest) → Redis → DB cache → CDN
|
|
74
|
-
|
|
75
|
-
### Async Processing
|
|
76
|
-
|
|
77
|
-
**Background**: Email, image processing, reports, aggregation
|
|
78
|
-
**Tools**: Job queues (Bull, BullMQ), message queues (RabbitMQ, Kafka), serverless
|
|
79
|
-
|
|
80
|
-
### Response Time
|
|
81
|
-
- Gzip compression
|
|
82
|
-
- HTTP/2 multiplexing
|
|
83
|
-
- Keep-alive connections
|
|
84
|
-
- Parallel requests
|
|
85
|
-
|
|
86
|
-
## Database Performance
|
|
87
|
-
|
|
88
|
-
### Connection Management
|
|
89
|
-
- Connection pooling (reuse)
|
|
90
|
-
- Configure pool size
|
|
91
|
-
- Monitor usage
|
|
92
|
-
- Close idle connections
|
|
93
|
-
|
|
94
|
-
### Query Performance
|
|
95
|
-
**Slow query log**: Identify > 100ms, add indexes, rewrite, consider denormalization
|
|
96
|
-
|
|
97
|
-
**Pagination**: See sql.md for cursor-based vs offset patterns
|
|
98
|
-
|
|
99
|
-
### Scaling
|
|
100
|
-
**Vertical**: Bigger server (limited)
|
|
101
|
-
**Horizontal**: Read replicas (scale reads), sharding (partition data), DB-per-service
|
|
102
|
-
|
|
103
|
-
## Monitoring
|
|
104
|
-
|
|
105
|
-
**Frontend**: RUM, synthetic monitoring, Core Web Vitals, error tracking (Sentry)
|
|
106
|
-
**Backend**: APM, log aggregation (ELK, Datadog), alerting, distributed tracing
|
|
107
|
-
|
|
108
|
-
**Continuous**:
|
|
109
|
-
1. Set budgets
|
|
110
|
-
2. Monitor metrics
|
|
111
|
-
3. Alert on regression
|
|
112
|
-
4. Profile bottlenecks
|
|
113
|
-
5. Optimize
|
|
114
|
-
6. Measure impact
|
|
115
|
-
|
|
116
|
-
## Common Pitfalls
|
|
117
|
-
|
|
118
|
-
❌ **Premature optimization**: Optimize AFTER measuring, focus on biggest bottlenecks, 80/20 rule
|
|
119
|
-
❌ **Over-caching**: Invalidation is hard, stale data bugs, memory limits → Cache stable, expensive data only
|
|
120
|
-
❌ **Ignoring network**: Minimize requests, reduce payload, use HTTP/2, consider latency
|
|
121
|
-
❌ **Blocking operations**: Never block event loop (Node), use async for I/O, worker threads for CPU tasks
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Security Best Practices
|
|
3
|
-
description: OWASP, authentication, authorization, vulnerabilities, secure coding
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Security Best Practices
|
|
7
|
-
|
|
8
|
-
## OWASP Top 10
|
|
9
|
-
|
|
10
|
-
### SQL Injection
|
|
11
|
-
**Never** concatenate user input into SQL
|
|
12
|
-
```javascript
|
|
13
|
-
// BAD: Vulnerable
|
|
14
|
-
db.query(`SELECT * FROM users WHERE id = ${userId}`)
|
|
15
|
-
|
|
16
|
-
// GOOD: Parameterized
|
|
17
|
-
db.query('SELECT * FROM users WHERE id = $1', [userId])
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### XSS (Cross-Site Scripting)
|
|
21
|
-
- Sanitize/escape user content before rendering
|
|
22
|
-
- Use CSP headers
|
|
23
|
-
- Never use `dangerouslySetInnerHTML` without sanitization
|
|
24
|
-
- Validate server-side, not just client
|
|
25
|
-
|
|
26
|
-
### Authentication & Authorization
|
|
27
|
-
- Use established libraries (Passport, NextAuth, Auth0)
|
|
28
|
-
- Hash passwords (bcrypt/argon2), never plain text
|
|
29
|
-
- Rate limit login endpoints
|
|
30
|
-
- httpOnly, secure, sameSite cookies for tokens
|
|
31
|
-
- Separate authentication (who) from authorization (what)
|
|
32
|
-
|
|
33
|
-
### CSRF (Cross-Site Request Forgery)
|
|
34
|
-
- CSRF tokens for state-changing ops
|
|
35
|
-
- Check Origin/Referer headers
|
|
36
|
-
- SameSite cookie attribute
|
|
37
|
-
|
|
38
|
-
## Secrets Management
|
|
39
|
-
**Never** commit secrets to git (.env in .gitignore)
|
|
40
|
-
- Environment variables for secrets
|
|
41
|
-
- Rotate credentials regularly
|
|
42
|
-
- Use secret managers (AWS Secrets Manager, Vault)
|
|
43
|
-
|
|
44
|
-
## Input Validation
|
|
45
|
-
- Validate server-side (client is UX only)
|
|
46
|
-
- Whitelist approach: Define allowed, reject all else
|
|
47
|
-
- Sanitize file uploads (check type, size, scan)
|
|
48
|
-
- Schema validation (Zod, Joi)
|
|
49
|
-
|
|
50
|
-
## API Security
|
|
51
|
-
- HTTPS everywhere
|
|
52
|
-
- Rate limiting
|
|
53
|
-
- Validate Content-Type headers
|
|
54
|
-
- API keys/tokens with least privilege
|
|
55
|
-
- Log security events (failed logins, unusual activity)
|
|
56
|
-
|
|
57
|
-
## Common Vulnerabilities
|
|
58
|
-
|
|
59
|
-
### Path Traversal
|
|
60
|
-
Validate file paths, never trust user input. Use path.resolve() and verify within allowed directory.
|
|
61
|
-
|
|
62
|
-
### Command Injection
|
|
63
|
-
Never pass user input to shell commands. If unavoidable, use libraries that escape properly.
|
|
64
|
-
|
|
65
|
-
### JWT Security
|
|
66
|
-
- Verify signature on every request
|
|
67
|
-
- Check expiration (exp claim)
|
|
68
|
-
- Short expiration (15min) + refresh tokens
|
|
69
|
-
- Store in httpOnly cookies, not localStorage
|
|
70
|
-
|
|
71
|
-
## Security Checklist
|
|
72
|
-
- [ ] All inputs validated/sanitized
|
|
73
|
-
- [ ] Secrets in environment variables
|
|
74
|
-
- [ ] HTTPS enforced
|
|
75
|
-
- [ ] Rate limiting on sensitive endpoints
|
|
76
|
-
- [ ] Auth + authz on protected routes
|
|
77
|
-
- [ ] CORS configured
|
|
78
|
-
- [ ] Security headers (CSP, X-Frame-Options)
|
|
79
|
-
- [ ] Dependencies updated (npm audit)
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Testing Strategies
|
|
3
|
-
description: Unit, integration, e2e, TDD, mocking, test architecture
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Testing Strategies
|
|
7
|
-
|
|
8
|
-
## Testing Pyramid
|
|
9
|
-
```
|
|
10
|
-
/\
|
|
11
|
-
/E2E\ (10% - Slow, expensive, brittle)
|
|
12
|
-
/------\
|
|
13
|
-
/Integr.\ (20% - Medium speed/cost)
|
|
14
|
-
/----------\
|
|
15
|
-
/Unit Tests \ (70% - Fast, cheap, stable)
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Unit Testing
|
|
19
|
-
|
|
20
|
-
### What to Test
|
|
21
|
-
**Do**: Business logic, edge cases, error handling, pure functions
|
|
22
|
-
**Don't**: Third-party libraries, implementation details, trivial code
|
|
23
|
-
|
|
24
|
-
### Best Practices
|
|
25
|
-
|
|
26
|
-
**AAA Pattern**: Arrange → Act → Assert
|
|
27
|
-
|
|
28
|
-
**Test names**: Describe behavior (`returns 404 when user not found`)
|
|
29
|
-
|
|
30
|
-
**One assertion per test** (ideally)
|
|
31
|
-
|
|
32
|
-
### Mocking
|
|
33
|
-
|
|
34
|
-
**When**: External APIs, databases, file system, time/date, random values
|
|
35
|
-
**How**: Mock boundaries only, not internal code
|
|
36
|
-
|
|
37
|
-
## Integration Testing
|
|
38
|
-
|
|
39
|
-
**Test**: Multiple units together, DB interactions, API endpoints, auth flows
|
|
40
|
-
|
|
41
|
-
**Database**: Use test DB, reset before each test, use transactions (rollback after)
|
|
42
|
-
|
|
43
|
-
## E2E Testing
|
|
44
|
-
|
|
45
|
-
**Test**: Critical user flows only (happy path + common errors)
|
|
46
|
-
**Example**: Login → Create → Edit → Delete → Logout
|
|
47
|
-
|
|
48
|
-
**Stability**: Use data-testid, wait for elements, retry assertions, headless in CI
|
|
49
|
-
**Speed**: Run parallel, skip UI steps (use API for setup)
|
|
50
|
-
|
|
51
|
-
## TDD (Test-Driven Development)
|
|
52
|
-
|
|
53
|
-
### Red-Green-Refactor
|
|
54
|
-
1. Write failing test
|
|
55
|
-
2. Write minimal code to pass
|
|
56
|
-
3. Refactor while keeping tests green
|
|
57
|
-
|
|
58
|
-
**Good for**: Well-defined requirements, complex logic, bug fixes
|
|
59
|
-
**Not for**: Prototypes, UI styling, simple CRUD
|
|
60
|
-
|
|
61
|
-
## Testing Patterns
|
|
62
|
-
|
|
63
|
-
### Parameterized Tests
|
|
64
|
-
```javascript
|
|
65
|
-
test.each([
|
|
66
|
-
[1, 2, 3],
|
|
67
|
-
[2, 3, 5],
|
|
68
|
-
])('adds %i + %i = %i', (a, b, expected) => {
|
|
69
|
-
expect(add(a, b)).toBe(expected)
|
|
70
|
-
})
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Test Doubles
|
|
74
|
-
- **Stub**: Returns canned response
|
|
75
|
-
- **Mock**: Verifies interactions
|
|
76
|
-
- **Spy**: Records calls
|
|
77
|
-
- **Fake**: Working implementation (in-memory DB)
|
|
78
|
-
|
|
79
|
-
## Code Coverage
|
|
80
|
-
|
|
81
|
-
**Metrics**: Line, branch, function, statement
|
|
82
|
-
**Target**: 80%+ (critical paths 100%)
|
|
83
|
-
|
|
84
|
-
**Don't chase numbers**: Coverage ≠ quality. 70% with good tests > 95% shallow tests.
|
|
85
|
-
|
|
86
|
-
## React Component Testing
|
|
87
|
-
|
|
88
|
-
**React Testing Library**: Test user interactions, not implementation
|
|
89
|
-
|
|
90
|
-
**Query priority**: getByRole > getByLabelText > getByText > getByTestId
|
|
91
|
-
|
|
92
|
-
## Performance Testing
|
|
93
|
-
|
|
94
|
-
**Load Testing Metrics**: RPS, response time (p50/p95/p99), error rate, resource usage
|
|
95
|
-
|
|
96
|
-
**Scenarios**: Baseline (normal), stress (peak 3x), spike (sudden surge), soak (sustained hours)
|
|
97
|
-
|
|
98
|
-
**Tools**: k6, Artillery, JMeter
|
|
99
|
-
|
|
100
|
-
## CI/CD Integration
|
|
101
|
-
|
|
102
|
-
**On commit**: Linting, unit tests, integration tests
|
|
103
|
-
**On PR**: Full suite, coverage report, benchmarks
|
|
104
|
-
**On deploy**: E2E (staging), smoke tests (production)
|
|
105
|
-
|
|
106
|
-
## Common Pitfalls
|
|
107
|
-
|
|
108
|
-
❌ **Testing implementation** → Test public API/behavior
|
|
109
|
-
❌ **Brittle tests** → Use semantic queries, independent tests, proper waits
|
|
110
|
-
❌ **Slow tests** → Mock external calls, parallelize, focus on unit tests
|
|
111
|
-
❌ **Flaky tests** → Investigate root cause (timing, shared state, external deps)
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Silent
|
|
3
|
-
description: Execute without narration - speak only through tool calls and commits
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Silent Execution Style
|
|
7
|
-
|
|
8
|
-
## During Execution
|
|
9
|
-
|
|
10
|
-
Use tool calls only. Do not produce text responses.
|
|
11
|
-
|
|
12
|
-
User sees your work through:
|
|
13
|
-
- Tool call executions
|
|
14
|
-
- File creation and modifications
|
|
15
|
-
- Test results
|
|
16
|
-
|
|
17
|
-
## At Completion
|
|
18
|
-
|
|
19
|
-
Document in commit message or PR description.
|
|
20
|
-
|
|
21
|
-
## Never
|
|
22
|
-
|
|
23
|
-
Do not narrate actions, explain reasoning, report status, or provide summaries during execution.
|